Skip to content

Commit

Permalink
Merge pull request #351 from jamebal/dev
Browse files Browse the repository at this point in the history
fix: 修复挂载文件根据位置跳转后无法返回上级目录的问题
  • Loading branch information
jamebal authored Jan 2, 2025
2 parents d4584c8 + 658b858 commit 319e538
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 12 deletions.
10 changes: 9 additions & 1 deletion src/api/file-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,22 @@ export default {
data: data
})
},
// 挂用户获取分享文件信息 /mount/file_info
// 挂用户获取分享文件信息
getMountFileInfo: function(params) {
return request({
url: '/mount/file_info',
method: 'get',
params
})
},
// 挂用户获取目录Id
getMountFolderId: function(params) {
return request({
url: '/mount/folder/id',
method: 'get',
params
})
},
// 验证提取码
validShareCode: function(data) {
return request({
Expand Down
39 changes: 32 additions & 7 deletions src/components/ShowFile/ShowFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@
<div>
<el-button size="small" @click="deleteConfirmVisible = false">取 消</el-button>
<el-button v-if="permanentDeleteDisable" type="danger" size="small" @click="sweepDeleteFile" :loading="deleteLoading">彻底删除</el-button>
<el-button v-else type="warning" size="small" @click="moveToRecycle" :loading="deleteLoading">移至回收站</el-button>
<el-button v-if="!permanentDeleteDisable" type="warning" size="small" @click="moveToRecycle" :loading="deleteLoading">移至回收站</el-button>
</div>
</span>
</el-dialog>
Expand Down Expand Up @@ -2405,7 +2405,7 @@ export default {
keywordQuery
)
},
handleLink(item, index, unPushLink, unRefresh, keywordQuery) {
async handleLink(item, index, unPushLink, unRefresh, keywordQuery) {
this.pathList.splice(
this.pathList.findIndex((v, i) => i === index + 1),
this.pathList.length - (index + 1)
Expand All @@ -2427,6 +2427,9 @@ export default {
this.path = this.path.replace(/\\/g, '/')
})
let queryFolder = localStorage.getItem('mountFileOwner') ? localStorage.getItem(this.path) : this.$route.query.folder
if (localStorage.getItem('mountFileOwner') && !queryFolder) {
queryFolder = await this.getMountFolderId(this.$route.query.folder, localStorage.getItem('mountFileOwner'), this.path)
}
let searchOpenFolder = this.$route.query.searchOpenFolder ? `&searchOpenFolder=${this.$route.query.searchOpenFolder}` : ''
if (!unPushLink) {
const queryTagId = this.$route.query.tagId
Expand All @@ -2453,6 +2456,25 @@ export default {
}
}
},
getMountFolderId(currentFolder, fileUsername, path) {
return new Promise((resolve, reject) => {
api.getMountFolderId({
otherFileId: currentFolder,
fileUsername: fileUsername,
path: path
})
.then(res => {
if (res.data) {
resolve(res.data)
} else {
resolve('')
}
})
.catch(error => {
reject('')
})
})
},
getBasePath() {
let basePath = this.$route.query.basePath
? `&basePath=${this.$route.query.basePath}`
Expand Down Expand Up @@ -4182,21 +4204,21 @@ export default {
getSelectFileList() {
const fileList = [];
this.permanentDeleteDisable = false;
const addFileToList = ({ id, suffix, name, contentType, isFolder, music, video }) => {
fileList.push({ id, suffix, name, contentType, isFolder, music, video });
const addFileToList = ({ id, suffix, name, mountFileId, contentType, isFolder, music, video }) => {
fileList.push({ id, suffix, name, mountFileId, contentType, isFolder, music, video });
};
if (this.selectRowData.length > 1 || this.menusIsMultiple) {
this.$refs.fileListTable.tableSelectData.forEach(value => addFileToList(value));
} else {
addFileToList(this.rowContextData);
}
if (fileList.length > 0) {
this.checkPermanentDelete(fileList[0].id);
this.checkPermanentDelete(fileList[0]);
}
return fileList;
},
checkPermanentDelete(fileId) {
if (/\//.test(fileId)) {
checkPermanentDelete(file) {
if (/\//.test(file.id) || file.mountFileId) {
this.permanentDeleteDisable = true
this.permanentDelete = true
}
Expand Down Expand Up @@ -4464,6 +4486,9 @@ export default {
if (this.dialogMoveOrCopyVisible) {
return true
}
if (this.deleteConfirmVisible) {
return true
}
return this.notPreviewDialogVisible;
},
determineDownload(file) {
Expand Down
15 changes: 11 additions & 4 deletions src/components/preview/FileDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,29 @@ export default {
visible(val) {
this.$emit('update:visible', val)
if (val) {
this.filepath = this.file.path
this.pathUrl = `/?path=${this.file.path}&highlight=${this.file.name}`
this.filepath = this.getLocalPath(this.file.path)
this.pathUrl = `/?path=${this.filepath}&highlight=${this.file.name}`
this.getIsSync()
if (this.fileUsername) {
fileApi.getMountFileInfo({
fileId: this.file.id,
fileUsername: this.fileUsername
}).then((res) => {
this.filepath = res.data.path
this.pathUrl = `/?path=${res.data.path}&highlight=${this.file.name}&folder=${res.data.folder}`
const path = this.getLocalPath(res.data.path)
this.filepath = path
this.pathUrl = `/?path=${path}&highlight=${this.file.name}&folder=${res.data.folder}`
})
}
}
}
},
methods: {
getLocalPath(path) {
if (path === '/') {
return path
}
return path.endsWith('/') ? path.slice(0, -1) : path
},
isOSSFile(file) {
if (!file || !file.id) {
return false
Expand Down

0 comments on commit 319e538

Please sign in to comment.