feat: 将 scanDir 持久化到 app_config 表,移除 localStorage 存储
This commit is contained in:
@@ -210,8 +210,8 @@ export default {
|
||||
starting: false, // 点完按钮后、等后端回话前的"转圈"
|
||||
moving: false, // 点完「移动文件」后等后端回话前的"转圈"
|
||||
cancelling: false, // 点完「中止扫描」后等后端确认的"转圈"
|
||||
scanDir: localStorage.getItem('scan-dir') || '', // 要扫描的目录(记住上次填的)
|
||||
destDir: localStorage.getItem('scan-dest-dir') || '', // 整理后文件放哪(记住上次填的)
|
||||
scanDir: '', // 要扫描的目录(从后端状态回填)
|
||||
destDir: '', // 整理后文件放哪(从后端状态回填)
|
||||
|
||||
// ---------- 扫描进度与状态 ----------
|
||||
status: {
|
||||
@@ -299,9 +299,10 @@ export default {
|
||||
const wasRunning = this.status.state === 'running' // 之前是不是在跑
|
||||
const isRunning = data.state === 'running' // 现在是不是在跑
|
||||
const prevLineCount = (this.status.lines || []).length
|
||||
// 第一次拿到状态时,把后端记的"上次存放目录"回填进来
|
||||
if (!this.status.initialized && data.destDir) {
|
||||
this.destDir = data.destDir
|
||||
// 第一次拿到状态时,把后端记的"上次目录"回填进来
|
||||
if (!this.status.initialized) {
|
||||
if (data.rootDir) this.scanDir = data.rootDir
|
||||
if (data.destDir) this.destDir = data.destDir
|
||||
}
|
||||
this.status = data
|
||||
this.status.initialized = true
|
||||
@@ -411,9 +412,6 @@ export default {
|
||||
async handleStart() {
|
||||
this.starting = true
|
||||
try {
|
||||
// 记住这次填的目录,下次打开页面自动填上
|
||||
localStorage.setItem('scan-dir', this.scanDir)
|
||||
localStorage.setItem('scan-dest-dir', this.destDir)
|
||||
const res = await request.post('/api/scan/start', {
|
||||
dir: this.scanDir.trim(),
|
||||
destDir: this.destDir.trim()
|
||||
@@ -476,10 +474,8 @@ export default {
|
||||
if (!this.fsData.current) return
|
||||
if (this.pickerTarget === 'dest') {
|
||||
this.destDir = this.fsData.current
|
||||
localStorage.setItem('scan-dest-dir', this.destDir)
|
||||
} else {
|
||||
this.scanDir = this.fsData.current
|
||||
localStorage.setItem('scan-dir', this.scanDir)
|
||||
}
|
||||
this.dirPickerVisible = false
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user