refactor: 将文件移动改为独立接口,扫描完成后手动触发
This commit is contained in:
@@ -60,7 +60,12 @@
|
||||
<div v-else class="running-hint">
|
||||
<span>
|
||||
<i class="el-icon-loading"></i>
|
||||
扫描整理中,已运行 {{ status.elapsed }} 秒...({{ stageText }} {{ progressText }})
|
||||
<template v-if="status.stage === 'move'">
|
||||
移动文件中,已运行 {{ status.elapsed }} 秒...({{ progressText }})
|
||||
</template>
|
||||
<template v-else>
|
||||
扫描整理中,已运行 {{ status.elapsed }} 秒...({{ stageText }} {{ progressText }})
|
||||
</template>
|
||||
<span v-if="etaText" class="eta-text">预计剩余 {{ etaText }}</span>
|
||||
</span>
|
||||
<el-progress
|
||||
@@ -78,6 +83,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="status.state === 'done'" class="move-actions">
|
||||
<el-button
|
||||
type="warning"
|
||||
size="medium"
|
||||
icon="el-icon-s-promotion"
|
||||
:loading="moving"
|
||||
@click="handleMove">移动文件到分类目录</el-button>
|
||||
<span class="move-hint">根据扫描归类结果,将文件移动到「存放目录」下的分类子目录</span>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="status.state === 'cancelled'"
|
||||
title="扫描已中止"
|
||||
@@ -193,6 +208,7 @@ export default {
|
||||
return {
|
||||
// ---------- 开始扫描 ----------
|
||||
starting: false, // 点完按钮后、等后端回话前的"转圈"
|
||||
moving: false, // 点完「移动文件」后等后端回话前的"转圈"
|
||||
cancelling: false, // 点完「中止扫描」后等后端确认的"转圈"
|
||||
scanDir: localStorage.getItem('scan-dir') || '', // 要扫描的目录(记住上次填的)
|
||||
destDir: localStorage.getItem('scan-dest-dir') || '', // 整理后文件放哪(记住上次填的)
|
||||
@@ -422,6 +438,18 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// 触发文件移动:根据扫描归类的结果,将文件移动到分类目录
|
||||
async handleMove() {
|
||||
this.moving = true
|
||||
try {
|
||||
const res = await request.post('/api/scan/move')
|
||||
this.applyStatus(res.data)
|
||||
this.$message.success('已开始移动文件')
|
||||
} finally {
|
||||
this.moving = false
|
||||
}
|
||||
},
|
||||
|
||||
// ==================== 目录选择弹窗 ====================
|
||||
|
||||
// 打开弹窗;target 决定这次选的是"扫描目录"还是"存放目录"
|
||||
@@ -607,6 +635,22 @@ export default {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.move-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
padding: 12px 16px;
|
||||
background: #fffbe6;
|
||||
border: 1px solid #ffe58f;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.move-hint {
|
||||
color: #8c6900;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.running-hint {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in New Issue
Block a user