1、手动上传文件tab,修改选中文件夹里面的数据

2、倒计时上传和手动获取最新文件上传tab,需要递归往下寻找修改时间最新的文件夹,如果是文件夹就往下接着查询,一直查询到最新的非文件夹的文件
3、配置页面加一个  username的配置   上传的时候加个字段
master
姜雪 3 weeks ago
parent bbb65c626e
commit 07e05bed0d
  1. 7
      config.json
  2. 737
      dist_electron/index.js
  3. 2
      dist_electron/preload.js
  4. 28259
      package-lock.json
  5. 69
      src/listener.js
  6. 6
      src/views/config/configFile.vue
  7. 8
      src/views/index.vue

@ -13,12 +13,13 @@
"code": "Z139009/202402",
"model": "1",
"address": "http://10.1.19.52:9999",
"file_path": "测试",
"file_path": "ai",
"no_report_path": "未上传记录",
"codeType": "dd",
"reconnect_time": "3",
"deviceAddress": "http://124.221.142.15:8088/api",
"filePathDisc": "C",
"updateFileName": "1"
"filePathDisc": "D",
"updateFileName": "1",
"username": "1"
}
}

File diff suppressed because one or more lines are too long

@ -104,7 +104,7 @@ eval("const { contextBridge, ipcRenderer } = __webpack_require__(/*! electron */
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("module.exports = __webpack_require__(/*! E:\\shuojinkeji\\WJSC\\utils-hub-demo\\src\\preload.js */\"./src/preload.js\");\n\n\n//# sourceURL=webpack:///multi_./src/preload.js?");
eval("module.exports = __webpack_require__(/*! C:\\Users\\jiangxue\\Desktop\\sjapp\\file-upload-application-qiutian\\src\\preload.js */\"./src/preload.js\");\n\n\n//# sourceURL=webpack:///multi_./src/preload.js?");
/***/ }),

28259
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -100,24 +100,57 @@ ipcMain.handle('watch-upload-analysis-file', async (e, id) => {
}
});
// 递归获取所有文件(包括子文件夹中的文件)
function getAllFilesRecursively(dir, fileList = []) {
console.log(`扫描目录: ${dir}`);
try {
const files = fs.readdirSync(dir);
console.log(`找到 ${files.length} 个项目:`, files);
files.forEach(file => {
const fullPath = path.join(dir, file);
try {
const stat = fs.statSync(fullPath);
if (stat.isDirectory()) {
// 如果是文件夹,递归查找
console.log(` 发现子文件夹: ${file}`);
getAllFilesRecursively(fullPath, fileList);
} else if (stat.isFile()) {
// 如果是文件,添加到列表
console.log(` 发现文件: ${file}, 大小: ${stat.size} bytes, 修改时间: ${stat.mtime}`);
fileList.push({
file: file,
fullPath: fullPath,
stat: stat
});
}
} catch (err) {
console.warn(`无法访问文件: ${fullPath}`, err.message);
}
});
} catch (err) {
console.error(`读取目录失败 ${dir}:`, err.message);
}
return fileList;
}
// 注册IPC方法:读取C盘指定文件夹的文件列表
ipcMain.handle('read-c-folder', async (event, folderPath) => {
try {
let dataJson = loadConfig()
const { path: targetPath, orderNum } = folderPath;
console.log('开始扫描目录:', targetPath);
// const targetPath = folderPath;
if (!fs.existsSync(targetPath)) {
return { success: false, msg: `文件夹不存在:${targetPath}` };
}
// 读取所有文件(过滤掉目录)
const files = fs.readdirSync(targetPath).map(file => {
const fullPath = path.join(targetPath, file);
const stat = fs.statSync(fullPath);
return { file, fullPath, stat };
})
.filter(item => item.stat.isFile());
// 递归读取所有文件(包括子文件夹中的文件)
const files = getAllFilesRecursively(targetPath);
console.log(`总共找到 ${files.length} 个文件`);
if (files.length === 0) {
return { success: false, msg: '文件夹中没有文件' };
@ -128,14 +161,16 @@ ipcMain.handle('read-c-folder', async (event, folderPath) => {
return current.stat.mtimeMs > prev.stat.mtimeMs ? current : prev;
});
console.log(`最新文件: ${latestFile.file}, 路径: ${latestFile.fullPath}, 修改时间: ${latestFile.stat.mtime}`);
const { file: oldName, fullPath: oldPath, stat } = latestFile;
console.log('latestFile', latestFile);
// 获取文件所在目录(可能是子文件夹)
const fileDir = path.dirname(oldPath);
// 如果未提供 orderNum
const ext = path.extname(oldName); // 保留原扩展名,如 .txt
const baseNewName = orderNum;
const newName = baseNewName + (ext.startsWith('.') ? ext : '');
const newPath = path.join(targetPath, newName);
const newPath = path.join(fileDir, newName);
console.log('newPath', newPath, dataJson.device.updateFileName == '1');
if (dataJson.device.updateFileName == '1') {
fs.renameSync(oldPath, newPath);
@ -156,10 +191,7 @@ ipcMain.handle('read-c-folder', async (event, folderPath) => {
};
} else {
fs.renameSync(oldPath, oldPath);
// 执行重命名
// 可选:读取文件 Buffer(注意大文件内存问题)
// 如果不需要内容,可移除 fileBuffer 字段
// 不重命名,直接使用原文件
const fileBuffer = fs.readFileSync(oldPath);
return {
@ -175,6 +207,7 @@ ipcMain.handle('read-c-folder', async (event, folderPath) => {
}
} catch (err) {
console.error('read-c-folder 错误:', err);
return { success: false, msg: `读取最新文件失败:${err.message}` };
}
});
@ -286,17 +319,15 @@ ipcMain.handle('rename-file', async (event, data) => {
};
} else {
fs.renameSync(oldPath, oldPath);
// 执行重命名
// 可选:读取文件 Buffer(注意大文件内存问题)
// 如果不需要内容,可移除 fileBuffer 字段
const fileBuffer = fs.readFileSync(oldPath);
// 不重命名,直接使用原文件
const oldName = path.basename(filePath);
const fileBuffer = fs.readFileSync(filePath);
return {
success: true,
data: {
fileName: oldName,
filePath: oldPath,
filePath: filePath,
fileSize: (stat.size / 1024).toFixed(2) + 'KB',
updateTime: new Date(stat.mtime).toLocaleString(),
fileBuffer: fileBuffer // 若不需要,可删除此行

@ -51,6 +51,11 @@
label-width="150px"
style="margin-top: 20px"
>
<el-col :span="12">
<el-form-item label="token">
<el-input size="mini" v-model="device.username"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="设备编号">
<el-input size="mini" v-model="device.code"></el-input>
@ -107,6 +112,7 @@ export default {
return {
loading: false,
device: {
username:'',
code: "0P0123",
codeType: "ER-HUIN", //
reconnect_time: "10",

@ -61,6 +61,13 @@
align="center"
>
</el-table-column>
<el-table-column
prop="fileName"
label="文件名"
show-overflow-tooltip
align="center"
>
</el-table-column>
<el-table-column
prop="deviceId"
label="设备编号"
@ -293,6 +300,7 @@ export default {
deviceId: this.configData.device.code,
orderNumber: id,
deviceModel: this.configData.device.codeType,
fileName: file.fileName,
analysisDate: JSON.stringify(result.data),
type: this.activeName,
date: this.getCurrentDateTime(),

Loading…
Cancel
Save