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':
this.onmessage(msg.data)
break
case 'getUploadParams':
this.$store.dispatch('updateMessage', {
event: 'onUploadParams',
data: this.getUploadParams(),
})
break
}
},
searchFileName(newValue) {
@ -2325,26 +2331,14 @@ export default {
// 打开文件选择框
this.$store.dispatch('updateMessage', {
event: 'openUploader',
data: {
// 传入的参数
folder: this.$route.query.searchOpenFolder || this.$route.query.folder,
currentDirectory: this.getQueryPath(),
username: this.$store.state.user.name,
userId: this.$store.state.user.userId,
},
data: this.getUploadParams(),
})
},
uploadFolder() {
if (window.uploader.supportDirectory) {
this.$store.dispatch('updateMessage', {
event: 'uploadFolder',
data: {
// 传入的参数
folder: this.$route.query.searchOpenFolder || this.$route.query.folder,
currentDirectory: this.getQueryPath(),
username: this.$store.state.user.name,
userId: this.$store.state.user.userId,
},
data: this.getUploadParams(),
})
} else {
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() {
if (this.pathList.length <= 1) {

View File

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