fix: 修复收藏、标签等页面拖拽上传路径错误的问题

This commit is contained in:
jmal 2025-08-04 15:57:45 +08:00
parent 1e831d221b
commit 9809322f61
2 changed files with 25 additions and 20 deletions

View File

@ -1209,6 +1209,12 @@ export default {
case 'msg/file/change': case 'msg/file/change':
this.onmessage(msg.data) this.onmessage(msg.data)
break break
case 'getUploadParams':
this.$store.dispatch('updateMessage', {
event: 'onUploadParams',
data: this.getUploadParams(),
})
break
} }
}, },
searchFileName(newValue) { searchFileName(newValue) {
@ -2325,26 +2331,14 @@ export default {
// 打开文件选择框 // 打开文件选择框
this.$store.dispatch('updateMessage', { this.$store.dispatch('updateMessage', {
event: 'openUploader', event: 'openUploader',
data: { data: this.getUploadParams(),
// 传入的参数
folder: this.$route.query.searchOpenFolder || this.$route.query.folder,
currentDirectory: this.getQueryPath(),
username: this.$store.state.user.name,
userId: this.$store.state.user.userId,
},
}) })
}, },
uploadFolder() { uploadFolder() {
if (window.uploader.supportDirectory) { if (window.uploader.supportDirectory) {
this.$store.dispatch('updateMessage', { this.$store.dispatch('updateMessage', {
event: 'uploadFolder', event: 'uploadFolder',
data: { data: this.getUploadParams(),
// 传入的参数
folder: this.$route.query.searchOpenFolder || this.$route.query.folder,
currentDirectory: this.getQueryPath(),
username: this.$store.state.user.name,
userId: this.$store.state.user.userId,
},
}) })
} else { } else {
this.$message({ this.$message({
@ -2353,6 +2347,14 @@ export default {
}) })
} }
}, },
getUploadParams() {
return {
folder: this.$route.query.searchOpenFolder || this.$route.query.folder,
currentDirectory: this.getQueryPath(),
username: this.$store.state.user.name,
userId: this.$store.state.user.userId,
}
},
// 浏览器的返回事件 // 浏览器的返回事件
goBack() { goBack() {
if (this.pathList.length <= 1) { if (this.pathList.length <= 1) {

View File

@ -229,6 +229,9 @@ export default {
$('#folder-uploader-btn').click() $('#folder-uploader-btn').click()
} }
break break
case 'onUploadParams':
this.params = msg.data || {}
break
} }
} }
}, },
@ -309,18 +312,17 @@ export default {
}); });
}, },
onDragenter(e) { onDragenter(e) {
this.params = { this.$store.dispatch('updateMessage', {event: 'getUploadParams'})
currentDirectory: this.$route.query.path || '/',
username: this.$store.state.user.name,
userId: this.$store.state.user.userId,
folder: this.$route.query.searchOpenFolder || this.$route.query.folder
}
}, },
isPath(str) { isPath(str) {
// 这个正则表达式检测路径中的斜杠字符 // 这个正则表达式检测路径中的斜杠字符
return /[/\\]/.test(str); return /[/\\]/.test(str);
}, },
async onFilesAdded(files) { async onFilesAdded(files) {
// 等待50ms
setTimeout(async () => await this.doFilesAdded(files), 50)
},
async doFilesAdded(files) {
if (files.length === 0) { if (files.length === 0) {
return return
} }
@ -337,6 +339,7 @@ export default {
filenames: filenames, filenames: filenames,
...this.params ...this.params
} }
console.log('上传文件', query)
const res = await api.checkExist(query) const res = await api.checkExist(query)
if (res.data.exist) { if (res.data.exist) {
this.$confirm('文件已存在,是否覆盖?', '提示', { this.$confirm('文件已存在,是否覆盖?', '提示', {