parent
2b96250186
commit
1f0720c8ad
23 changed files with 29840 additions and 252 deletions
File diff suppressed because one or more lines are too long
@ -1 +1 @@ |
|||||||
.desc[data-v-82f773be]{margin-top:40px;font-size:12px}.common[data-v-673c0bf5]{margin-top:20px}.mark[data-v-a0343704]{width:100%;height:100%;overflow:hidden;position:fixed;top:0;left:0;z-index:10}h3[data-v-a0343704]{margin:40px 0 0}ul[data-v-a0343704]{list-style-type:none;padding:0}li[data-v-a0343704]{display:inline-block;margin:0 10px}a[data-v-a0343704]{color:#42b983}.box-card[data-v-a0343704]{margin-top:12px}[data-v-a0343704] .el-form-item{margin-bottom:0!important}.box-card[data-v-7f6132b8]{width:250px;height:200px;float:left;margin-left:43px;margin-top:40px}.box-card[data-v-7f6132b8]:hover{border:1px solid #409eff;cursor:pointer}.descCls[data-v-7f6132b8]{font-size:12px}.file-upload[data-v-4d46612a]{padding:20px}.upload-area[data-v-4d46612a]{border:2px dashed #dcdfe6;border-radius:6px;padding:60px 0;text-align:center;cursor:pointer;transition:all .3s;background-color:#fafafa}.upload-area[data-v-4d46612a]:hover{border-color:#409eff;background-color:#f0f7ff}.upload-content[data-v-4d46612a]{color:#909399}.upload-content i[data-v-4d46612a]{font-size:48px;margin-bottom:16px}.file-info[data-v-4d46612a]{margin-top:20px;padding:20px;border:1px solid #ebeef5;border-radius:6px;background-color:#f8f9fa}.file-item[data-v-4d46612a]{margin-bottom:20px;padding-bottom:20px;border-bottom:1px solid #ebeef5}.file-name[data-v-4d46612a]{font-size:16px;font-weight:700;color:#303133;margin-bottom:8px}.file-path[data-v-4d46612a]{font-size:12px;color:#909399;margin-bottom:4px;word-break:break-all}.file-size[data-v-4d46612a]{font-size:12px;color:#67c23a}.rename-section[data-v-4d46612a]{margin-top:20px}.file-ext[data-v-4d46612a]{background-color:#f0f0f0;padding:0 8px;color:#666}.action-buttons[data-v-4d46612a]{margin-top:20px;display:flex;gap:10px}.renamed-info[data-v-4d46612a],.upload-result[data-v-4d46612a]{margin-top:20px} |
.desc[data-v-82f773be]{margin-top:40px;font-size:12px}.common[data-v-673c0bf5]{margin-top:20px}.mark[data-v-6f30a2d4]{width:100%;height:100%;overflow:hidden;position:fixed;top:0;left:0;z-index:10}h3[data-v-6f30a2d4]{margin:40px 0 0}ul[data-v-6f30a2d4]{list-style-type:none;padding:0}li[data-v-6f30a2d4]{display:inline-block;margin:0 10px}a[data-v-6f30a2d4]{color:#42b983}.box-card[data-v-6f30a2d4]{margin-top:12px}[data-v-6f30a2d4] .el-form-item{margin-bottom:0!important}.box-card[data-v-7f6132b8]{width:250px;height:200px;float:left;margin-left:43px;margin-top:40px}.box-card[data-v-7f6132b8]:hover{border:1px solid #409eff;cursor:pointer}.descCls[data-v-7f6132b8]{font-size:12px}.file-upload[data-v-4d46612a]{padding:20px}.upload-area[data-v-4d46612a]{border:2px dashed #dcdfe6;border-radius:6px;padding:60px 0;text-align:center;cursor:pointer;transition:all .3s;background-color:#fafafa}.upload-area[data-v-4d46612a]:hover{border-color:#409eff;background-color:#f0f7ff}.upload-content[data-v-4d46612a]{color:#909399}.upload-content i[data-v-4d46612a]{font-size:48px;margin-bottom:16px}.file-info[data-v-4d46612a]{margin-top:20px;padding:20px;border:1px solid #ebeef5;border-radius:6px;background-color:#f8f9fa}.file-item[data-v-4d46612a]{margin-bottom:20px;padding-bottom:20px;border-bottom:1px solid #ebeef5}.file-name[data-v-4d46612a]{font-size:16px;font-weight:700;color:#303133;margin-bottom:8px}.file-path[data-v-4d46612a]{font-size:12px;color:#909399;margin-bottom:4px;word-break:break-all}.file-size[data-v-4d46612a]{font-size:12px;color:#67c23a}.rename-section[data-v-4d46612a]{margin-top:20px}.file-ext[data-v-4d46612a]{background-color:#f0f0f0;padding:0 8px;color:#666}.action-buttons[data-v-4d46612a]{margin-top:20px;display:flex;gap:10px}.renamed-info[data-v-4d46612a],.upload-result[data-v-4d46612a]{margin-top:20px} |
||||||
@ -1 +1 @@ |
|||||||
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="stylesheet" href="app://./element-ui/theme-chalk/index.css"><link rel="icon" href="app://./favicon.ico"><title>utils-hub-demo</title><script defer="defer" src="app://./js/chunk-vendors.8e57b122.js"></script><script defer="defer" src="app://./js/app.08bbb89f.js"></script><link href="app://./css/chunk-vendors.ccd066bc.css" rel="stylesheet"><link href="app://./css/app.e13669ee.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but utils-hub-demo doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html> |
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="stylesheet" href="app://./element-ui/theme-chalk/index.css"><link rel="icon" href="app://./favicon.ico"><title>utils-hub-demo</title><script defer="defer" src="app://./js/chunk-vendors.1c7644b8.js"></script><script defer="defer" src="app://./js/app.4109ee0c.js"></script><link href="app://./css/chunk-vendors.ccd066bc.css" rel="stylesheet"><link href="app://./css/app.9e213d8c.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but utils-hub-demo doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html> |
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,470 @@ |
|||||||
|
<template> |
||||||
|
<div class="auto-mode-container"> |
||||||
|
<div class="header"> |
||||||
|
<el-button type="text" @click="goBack()"> |
||||||
|
<i class="el-icon-arrow-left"></i> 返回选择模式 |
||||||
|
</el-button> |
||||||
|
<span class="mode-title">自动上传模式</span> |
||||||
|
</div> |
||||||
|
<div class="auto-content"> |
||||||
|
<div class="upload-status" v-if="lastUploadStatus"> |
||||||
|
<el-alert |
||||||
|
:title="lastUploadStatus.title" |
||||||
|
:type="lastUploadStatus.type" |
||||||
|
show-icon |
||||||
|
:closable="false" |
||||||
|
> |
||||||
|
</el-alert> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- 当前正在处理的文件 --> |
||||||
|
<div class="current-file" v-if="currentFile"> |
||||||
|
<el-alert |
||||||
|
:title="'正在处理文件: ' + currentFile" |
||||||
|
type="info" |
||||||
|
show-icon |
||||||
|
:closable="false" |
||||||
|
> |
||||||
|
</el-alert> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- 上传记录列表 --> |
||||||
|
<div class="upload-list"> |
||||||
|
<h3>上传记录</h3> |
||||||
|
<el-table :data="savedFileList" style="width: 100%" v-loading="tableLoading"> |
||||||
|
<el-table-column |
||||||
|
type="index" |
||||||
|
width="50" |
||||||
|
label="序号" |
||||||
|
align="center" |
||||||
|
> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column |
||||||
|
prop="orderNumber" |
||||||
|
label="订单号" |
||||||
|
width="150" |
||||||
|
show-overflow-tooltip |
||||||
|
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="设备编号" |
||||||
|
width="120" |
||||||
|
show-overflow-tooltip |
||||||
|
align="center" |
||||||
|
> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column |
||||||
|
prop="uploadType" |
||||||
|
label="上传类型" |
||||||
|
width="100" |
||||||
|
show-overflow-tooltip |
||||||
|
align="center" |
||||||
|
> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column |
||||||
|
prop="deviceModel" |
||||||
|
label="设备型号" |
||||||
|
width="120" |
||||||
|
show-overflow-tooltip |
||||||
|
align="center" |
||||||
|
> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column |
||||||
|
prop="date" |
||||||
|
label="上传日期" |
||||||
|
width="180" |
||||||
|
show-overflow-tooltip |
||||||
|
align="center" |
||||||
|
> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column |
||||||
|
prop="analysisDate" |
||||||
|
label="上传结果" |
||||||
|
align="center" |
||||||
|
show-overflow-tooltip |
||||||
|
> |
||||||
|
<template slot-scope="scope"> |
||||||
|
<span v-if="scope.row.uploading" style="color: #E6A23C;"> |
||||||
|
<i class="el-icon-loading"></i> 上传中... |
||||||
|
</span> |
||||||
|
<span v-else>{{ scope.row.analysisDate }}</span> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
</el-table> |
||||||
|
|
||||||
|
<div style="float: right; margin-top: 20px"> |
||||||
|
<el-pagination |
||||||
|
@size-change="handleSizeChange" |
||||||
|
@current-change="handleCurrentChange" |
||||||
|
:current-page="currentPage" |
||||||
|
:page-sizes="[5, 10, 20, 30, 50]" |
||||||
|
:page-size="pageSize" |
||||||
|
layout="total, sizes, prev, pager, next, jumper" |
||||||
|
:total="total" |
||||||
|
> |
||||||
|
</el-pagination> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
export default { |
||||||
|
name: "AutoMode", |
||||||
|
data() { |
||||||
|
return { |
||||||
|
configData: {}, |
||||||
|
lastUploadStatus: null, |
||||||
|
savedFileList: [], |
||||||
|
allSavedFileList: [], |
||||||
|
currentPage: 1, |
||||||
|
pageSize: 10, |
||||||
|
total: 0, |
||||||
|
tableLoading: false, |
||||||
|
isWatching: false, // 文件夹监控状态 |
||||||
|
currentFile: null, // 当前正在处理的文件 |
||||||
|
fileChangedCallback: null, // 保存回调引用,用于移除监听 |
||||||
|
}; |
||||||
|
}, |
||||||
|
async mounted() { |
||||||
|
this.configData = await window.api.getConfig(); |
||||||
|
await this.getSavedFileInfo(); |
||||||
|
|
||||||
|
// 🔥 启动自动监控和上传 |
||||||
|
console.log("自动模式:启动监控和上传"); |
||||||
|
|
||||||
|
// 最小化窗口 |
||||||
|
window.api.minimizeWindow(); |
||||||
|
|
||||||
|
// 启动文件夹监控 |
||||||
|
await this.startAutoWatch(); |
||||||
|
|
||||||
|
// 先执行一次上传 |
||||||
|
await this.autoUploadFiles(); |
||||||
|
|
||||||
|
// 设置文件变化监听器 |
||||||
|
this.fileChangedCallback = (data) => { |
||||||
|
console.log("🔥 收到文件变化通知:", data); |
||||||
|
this.handleFileChanged(data); |
||||||
|
}; |
||||||
|
window.api.onFileChanged(this.fileChangedCallback); |
||||||
|
console.log("🔥 文件变化监听器已设置"); |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
async goBack() { |
||||||
|
// 清空 searchMode 配置 |
||||||
|
try { |
||||||
|
if (this.configData && this.configData.device) { |
||||||
|
this.configData.device.searchMode = ""; |
||||||
|
await window.api.updateConfig(this.configData); |
||||||
|
console.log("已清空检索模式配置"); |
||||||
|
} |
||||||
|
} catch (err) { |
||||||
|
console.error("清空配置失败:", err); |
||||||
|
} |
||||||
|
|
||||||
|
// 停止监控 |
||||||
|
if (this.isWatching) { |
||||||
|
window.api.stopWatchFolder(); |
||||||
|
this.isWatching = false; |
||||||
|
} |
||||||
|
|
||||||
|
this.$router.push("/"); |
||||||
|
}, |
||||||
|
// 🔥 启动文件夹监控 |
||||||
|
async startAutoWatch() { |
||||||
|
try { |
||||||
|
if (!this.configData || !this.configData.device) { |
||||||
|
console.error("配置信息不存在"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
const device = this.configData.device; |
||||||
|
const folderPath = `${device.filePathDisc}:/${device.file_path}`; |
||||||
|
|
||||||
|
console.log("启动文件夹监控:", folderPath); |
||||||
|
window.api.startWatchFolder(folderPath); |
||||||
|
this.isWatching = true; |
||||||
|
|
||||||
|
} catch (err) { |
||||||
|
console.error("启动监控失败:", err); |
||||||
|
} |
||||||
|
}, |
||||||
|
// 🔥 文件变化处理 |
||||||
|
async handleFileChanged(data) { |
||||||
|
console.log("🔥 handleFileChanged 被调用,参数:", data); |
||||||
|
console.log("🔥 文件发生变化,开始自动上传..."); |
||||||
|
// 🔥 不再调用 getSavedFileInfo(),避免覆盖刚插入的数据 |
||||||
|
await this.autoUploadFiles(); |
||||||
|
}, |
||||||
|
// 🔥 自动上传文件 |
||||||
|
async autoUploadFiles() { |
||||||
|
try { |
||||||
|
console.log("🔥 开始自动上传流程..."); |
||||||
|
|
||||||
|
if (!this.configData || !this.configData.device) { |
||||||
|
console.error("🔥 配置信息不存在"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
const device = this.configData.device; |
||||||
|
const path = `${device.filePathDisc}:/${device.file_path}`; |
||||||
|
|
||||||
|
console.log("🔥 配置的文件路径:", path); |
||||||
|
console.log("🔥 设备信息:", device); |
||||||
|
|
||||||
|
// 读取文件夹获取最新文件 |
||||||
|
console.log("🔥 正在读取文件夹..."); |
||||||
|
const res = await window.api.readCFolder({ |
||||||
|
path: path, |
||||||
|
orderNum: this.getCurrentDateTime().replace(/[:\s]/g, ''), |
||||||
|
}); |
||||||
|
|
||||||
|
console.log("🔥 readCFolder 返回结果:", res); |
||||||
|
|
||||||
|
if (res.success && res.data) { |
||||||
|
console.log("🔥 自动上传获取的文件:", res.data); |
||||||
|
console.log("🔥 文件名:", res.data.fileName); |
||||||
|
|
||||||
|
// 🔥 设置当前正在处理的文件 |
||||||
|
this.currentFile = res.data.fileName; |
||||||
|
|
||||||
|
// 🔥 立即将文件信息插入到列表头部 |
||||||
|
const newRecord = { |
||||||
|
deviceId: device.code, |
||||||
|
orderNumber: res.data.fileName.replace(/\.[^/.]+$/, ""), |
||||||
|
deviceModel: device.codeType, |
||||||
|
fileName: res.data.fileName, |
||||||
|
analysisDate: "", |
||||||
|
type: "auto", |
||||||
|
date: this.getCurrentDateTime(), |
||||||
|
uploadType: "自动上传", |
||||||
|
uploading: true, // 上传中标识 |
||||||
|
}; |
||||||
|
|
||||||
|
console.log("🔥 准备插入新记录:", newRecord); |
||||||
|
this.allSavedFileList.unshift(newRecord); |
||||||
|
this.total = this.allSavedFileList.length; |
||||||
|
this.updateCurrentPageData(); |
||||||
|
console.log("🔥 已插入列表,当前总数:", this.total); |
||||||
|
|
||||||
|
// 调用上传接口 |
||||||
|
await this.uploadFile(res.data, newRecord); |
||||||
|
|
||||||
|
// 清空当前文件状态 |
||||||
|
this.currentFile = null; |
||||||
|
} else { |
||||||
|
console.error("🔥 读取文件失败或无数据:", res.msg || "未知错误"); |
||||||
|
if (res.msg) { |
||||||
|
this.lastUploadStatus = { title: res.msg, type: "error" }; |
||||||
|
} |
||||||
|
} |
||||||
|
} catch (err) { |
||||||
|
console.error("🔥 自动上传失败:", err); |
||||||
|
this.lastUploadStatus = { title: `上传失败:${err.message}`, type: "error" }; |
||||||
|
this.currentFile = null; |
||||||
|
} |
||||||
|
}, |
||||||
|
// 🔥 上传文件到服务器 |
||||||
|
async uploadFile(file, record) { |
||||||
|
try { |
||||||
|
const device = this.configData.device; |
||||||
|
|
||||||
|
// 创建 Blob 对象 |
||||||
|
const fileBlob = new Blob([file.fileBuffer], { |
||||||
|
type: "application/octet-stream" |
||||||
|
}); |
||||||
|
|
||||||
|
// 构建 FormData |
||||||
|
const formData = new FormData(); |
||||||
|
formData.append("file", fileBlob, file.fileName); |
||||||
|
formData.append("token", device.username); |
||||||
|
formData.append("deviceId", device.code); |
||||||
|
formData.append("orderNumber", file.fileName.replace(/\.[^/.]+$/, "")); |
||||||
|
formData.append("deviceModel", device.codeType); |
||||||
|
|
||||||
|
console.log("上传参数:", { |
||||||
|
fileName: file.fileName, |
||||||
|
token: device.username, |
||||||
|
deviceId: device.code, |
||||||
|
orderNumber: file.fileName.replace(/\.[^/.]+$/, ""), |
||||||
|
deviceModel: device.codeType, |
||||||
|
uploadUrl: device.address + "/upper/send" |
||||||
|
}); |
||||||
|
|
||||||
|
// 上传到服务器 |
||||||
|
const controller = new AbortController(); |
||||||
|
const timeoutId = setTimeout(() => controller.abort(), 10000); |
||||||
|
|
||||||
|
const response = await fetch(device.address + "/upper/send", { |
||||||
|
method: "POST", |
||||||
|
body: formData, |
||||||
|
signal: controller.signal, |
||||||
|
}); |
||||||
|
|
||||||
|
clearTimeout(timeoutId); |
||||||
|
|
||||||
|
if (!response.ok) { |
||||||
|
throw new Error(`HTTP error! status: ${response.status}`); |
||||||
|
} |
||||||
|
|
||||||
|
const result = await response.json(); |
||||||
|
console.log("上传接口返回:", result); |
||||||
|
|
||||||
|
if (result.code == 0) { |
||||||
|
// 🔥 更新列表中的记录状态 |
||||||
|
record.uploading = false; |
||||||
|
record.analysisDate = JSON.stringify(result.data); |
||||||
|
|
||||||
|
// 保存上传记录到本地 |
||||||
|
await window.api.saveFileInfo([{ |
||||||
|
deviceId: device.code, |
||||||
|
orderNumber: file.fileName.replace(/\.[^/.]+$/, ""), |
||||||
|
deviceModel: device.codeType, |
||||||
|
fileName: file.fileName, |
||||||
|
analysisDate: JSON.stringify(result.data), |
||||||
|
type: "auto", |
||||||
|
date: this.getCurrentDateTime(), |
||||||
|
uploadType: "自动上传", |
||||||
|
}]); |
||||||
|
console.log("自动上传成功"); |
||||||
|
this.lastUploadStatus = { title: "上传成功", type: "success" }; |
||||||
|
} else { |
||||||
|
// 🔥 更新列表中的记录状态为失败 |
||||||
|
record.uploading = false; |
||||||
|
record.analysisDate = "上传失败: " + result.msg; |
||||||
|
console.error("上传失败:", result.msg); |
||||||
|
this.lastUploadStatus = { title: result.msg, type: "error" }; |
||||||
|
} |
||||||
|
} catch (err) { |
||||||
|
// 🔥 更新列表中的记录状态为失败 |
||||||
|
record.uploading = false; |
||||||
|
|
||||||
|
if (err.name === "AbortError") { |
||||||
|
console.error("请求超时,请检查网络或服务器状态"); |
||||||
|
record.analysisDate = "上传失败: 请求超时"; |
||||||
|
this.lastUploadStatus = { title: "请求超时", type: "error" }; |
||||||
|
} else { |
||||||
|
console.error("上传异常:", err); |
||||||
|
record.analysisDate = "上传失败: " + (err.message || "上传异常"); |
||||||
|
this.lastUploadStatus = { title: err.message || "上传异常", type: "error" }; |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
// 读取本地存储的文件信息 |
||||||
|
async getSavedFileInfo() { |
||||||
|
try { |
||||||
|
this.tableLoading = true; |
||||||
|
const res = await window.api.getSavedFileInfo(); |
||||||
|
if (res.success) { |
||||||
|
// 只显示自动上传的记录 |
||||||
|
this.allSavedFileList = res.data.filter( |
||||||
|
(item) => item.uploadType === "自动上传" |
||||||
|
); |
||||||
|
this.total = this.allSavedFileList.length; |
||||||
|
this.updateCurrentPageData(); |
||||||
|
console.log(`成功读取${this.total}条自动上传记录`); |
||||||
|
} else { |
||||||
|
console.error("读取文件信息失败:", res.msg); |
||||||
|
} |
||||||
|
} catch (err) { |
||||||
|
console.error("读取本地数据失败:", err); |
||||||
|
} finally { |
||||||
|
this.tableLoading = false; |
||||||
|
} |
||||||
|
}, |
||||||
|
updateCurrentPageData() { |
||||||
|
const start = (this.currentPage - 1) * this.pageSize; |
||||||
|
const end = start + this.pageSize; |
||||||
|
this.savedFileList = this.allSavedFileList.slice(start, end); |
||||||
|
}, |
||||||
|
handleSizeChange(val) { |
||||||
|
this.pageSize = val; |
||||||
|
this.currentPage = 1; |
||||||
|
this.updateCurrentPageData(); |
||||||
|
}, |
||||||
|
handleCurrentChange(val) { |
||||||
|
this.currentPage = val; |
||||||
|
this.updateCurrentPageData(); |
||||||
|
}, |
||||||
|
getCurrentDateTime() { |
||||||
|
const now = new Date(); |
||||||
|
const year = now.getFullYear(); |
||||||
|
const month = String(now.getMonth() + 1).padStart(2, "0"); |
||||||
|
const day = String(now.getDate()).padStart(2, "0"); |
||||||
|
const hours = String(now.getHours()).padStart(2, "0"); |
||||||
|
const minutes = String(now.getMinutes()).padStart(2, "0"); |
||||||
|
const seconds = String(now.getSeconds()).padStart(2, "0"); |
||||||
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
||||||
|
}, |
||||||
|
}, |
||||||
|
beforeDestroy() { |
||||||
|
// 停止监控 |
||||||
|
if (this.isWatching) { |
||||||
|
window.api.stopWatchFolder(); |
||||||
|
} |
||||||
|
// 🔥 移除文件变化监听器 |
||||||
|
if (this.fileChangedCallback) { |
||||||
|
window.api.removeFileChangedListener(this.fileChangedCallback); |
||||||
|
console.log("🔥 已移除文件变化监听器"); |
||||||
|
} |
||||||
|
}, |
||||||
|
}; |
||||||
|
</script> |
||||||
|
|
||||||
|
<style scoped> |
||||||
|
.auto-mode-container { |
||||||
|
padding: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.header { |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
margin-bottom: 30px; |
||||||
|
} |
||||||
|
|
||||||
|
.mode-title { |
||||||
|
font-size: 20px; |
||||||
|
font-weight: bold; |
||||||
|
margin-left: 20px; |
||||||
|
color: #333; |
||||||
|
} |
||||||
|
|
||||||
|
.auto-content { |
||||||
|
max-width: 1200px; |
||||||
|
margin: 0 auto; |
||||||
|
} |
||||||
|
|
||||||
|
.upload-status { |
||||||
|
margin-bottom: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.current-file { |
||||||
|
margin-bottom: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.upload-list { |
||||||
|
background: #fff; |
||||||
|
padding: 20px; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1); |
||||||
|
} |
||||||
|
|
||||||
|
.upload-list h3 { |
||||||
|
margin: 0 0 20px 0; |
||||||
|
font-size: 18px; |
||||||
|
color: #333; |
||||||
|
border-bottom: 2px solid #409eff; |
||||||
|
padding-bottom: 10px; |
||||||
|
} |
||||||
|
</style> |
||||||
@ -0,0 +1,147 @@ |
|||||||
|
<template> |
||||||
|
<div class="mode-select-container"> |
||||||
|
<div class="mode-select-card"> |
||||||
|
<h2 class="title">文件上传</h2> |
||||||
|
<p class="subtitle">请选择操作模式</p> |
||||||
|
<div class="mode-buttons"> |
||||||
|
<el-button type="primary" class="mode-btn" @click="selectMode('auto')"> |
||||||
|
<i class="el-icon-cpu"></i> |
||||||
|
<span>自动模式</span> |
||||||
|
</el-button> |
||||||
|
<el-button type="success" class="mode-btn" @click="selectMode('manual')"> |
||||||
|
<i class="el-icon-edit"></i> |
||||||
|
<span>手动模式</span> |
||||||
|
</el-button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
export default { |
||||||
|
name: "ModeSelect", |
||||||
|
data() { |
||||||
|
return { |
||||||
|
configData: null, |
||||||
|
isWatching: false, |
||||||
|
}; |
||||||
|
}, |
||||||
|
async mounted() { |
||||||
|
// 检测配置中的检索模式 |
||||||
|
try { |
||||||
|
this.configData = await window.api.getConfig(); |
||||||
|
|
||||||
|
// 🔥 如果配置为自动检索模式,直接执行自动模式 |
||||||
|
if (this.configData && this.configData.device && this.configData.device.searchMode === "auto") { |
||||||
|
console.log("配置检测:自动检索模式,直接启动"); |
||||||
|
await this.selectMode('auto'); |
||||||
|
return; // 不再继续执行后续代码 |
||||||
|
} |
||||||
|
|
||||||
|
// 如果配置为手动检索模式,跳转到手动页面 |
||||||
|
if (this.configData && this.configData.device && this.configData.device.searchMode === "manual") { |
||||||
|
console.log("配置检测:手动检索模式,跳转到手动页面"); |
||||||
|
// this.$router.replace("/manual"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 设置文件变化监听器 |
||||||
|
window.api.onFileChanged((data) => { |
||||||
|
console.log("收到文件变化通知:", data); |
||||||
|
this.handleFileChanged(data); |
||||||
|
}); |
||||||
|
} catch (err) { |
||||||
|
console.error("读取配置失败:", err); |
||||||
|
} |
||||||
|
}, |
||||||
|
beforeDestroy() { |
||||||
|
// 停止监控 |
||||||
|
if (this.isWatching) { |
||||||
|
window.api.stopWatchFolder(); |
||||||
|
} |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
async selectMode(mode) { |
||||||
|
try { |
||||||
|
// 保存选择的模式到配置 |
||||||
|
if (this.configData && this.configData.device) { |
||||||
|
this.configData.device.searchMode = mode; |
||||||
|
await window.api.updateConfig(this.configData); |
||||||
|
console.log(`已保存模式配置: ${mode}`); |
||||||
|
} |
||||||
|
|
||||||
|
if (mode === "auto") { |
||||||
|
console.log("选择自动模式"); |
||||||
|
// 跳转到自动模式页面,所有自动监控逻辑在 AutoMode.vue 中执行 |
||||||
|
this.$router.replace("/auto"); |
||||||
|
} else { |
||||||
|
// 手动模式 - 跳转到手动页面 |
||||||
|
this.$router.push("/manual"); |
||||||
|
} |
||||||
|
} catch (err) { |
||||||
|
console.error("保存配置失败:", err); |
||||||
|
} |
||||||
|
}, |
||||||
|
}, |
||||||
|
}; |
||||||
|
</script> |
||||||
|
|
||||||
|
<style scoped> |
||||||
|
.mode-select-container { |
||||||
|
width: 100%; |
||||||
|
height: 100vh; |
||||||
|
display: flex; |
||||||
|
justify-content: center; |
||||||
|
align-items: center; |
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); |
||||||
|
} |
||||||
|
|
||||||
|
.mode-select-card { |
||||||
|
background: white; |
||||||
|
padding: 60px 80px; |
||||||
|
border-radius: 16px; |
||||||
|
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
.title { |
||||||
|
margin: 0 0 15px 0; |
||||||
|
font-size: 32px; |
||||||
|
color: #333; |
||||||
|
font-weight: 600; |
||||||
|
} |
||||||
|
|
||||||
|
.subtitle { |
||||||
|
margin: 0 0 40px 0; |
||||||
|
font-size: 16px; |
||||||
|
color: #666; |
||||||
|
} |
||||||
|
|
||||||
|
.mode-buttons { |
||||||
|
display: flex; |
||||||
|
gap: 30px; |
||||||
|
justify-content: center; |
||||||
|
} |
||||||
|
|
||||||
|
.mode-btn { |
||||||
|
width: 160px; |
||||||
|
height: 160px; |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
justify-content: center; |
||||||
|
align-items: center; |
||||||
|
font-size: 16px; |
||||||
|
border-radius: 12px; |
||||||
|
transition: all 0.3s ease; |
||||||
|
} |
||||||
|
|
||||||
|
.mode-btn i { |
||||||
|
font-size: 48px; |
||||||
|
margin-bottom: 15px; |
||||||
|
} |
||||||
|
|
||||||
|
.mode-btn:hover { |
||||||
|
transform: translateY(-5px); |
||||||
|
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2); |
||||||
|
} |
||||||
|
</style> |
||||||
Loading…
Reference in new issue