From 1136836d14690b97ad8ed0cd4ba11c3efd24e670 Mon Sep 17 00:00:00 2001 From: jmal Date: Mon, 8 Aug 2022 18:09:08 +0800 Subject: [PATCH] =?UTF-8?q?:fix:=20=E6=96=87=E4=BB=B6=E5=A4=B9=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E4=B8=AD=E6=9C=89=E7=89=B9=E8=AE=B8=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=96=87=E4=BB=B6=E6=89=93=E5=BC=80=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ShowFile/ShowFile.vue | 14 +++++++------- src/utils/file-config.js | 9 +++++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index f878b1b..980e1b1 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -1756,7 +1756,7 @@ export default { api.uploadFolder({ isFolder: true, filename: this.newFolderName, - currentDirectory: this.path, + currentDirectory: encodeURIComponent(this.path), username: this.$store.state.user.name, userId: this.$store.state.user.userId }).then((res) => { @@ -1967,7 +1967,7 @@ export default { keyword: key, sortableProp: this.sortable.prop, order: this.sortable.order, - currentDirectory: this.$route.query.path, + currentDirectory: encodeURIComponent(this.$route.query.path), pageIndex: this.pagination.pageIndex, pageSize: this.pagination.pageSize }).then(res => { @@ -1983,7 +1983,7 @@ export default { api.searchFileAndOpenDir({ userId: this.$store.state.user.userId, id: row.id, - currentDirectory: this.$route.query.path, + currentDirectory: encodeURIComponent(this.$route.query.path), pageIndex: this.pagination.pageIndex, pageSize: this.pagination.pageSize }).then(res => { @@ -1998,7 +1998,7 @@ export default { api.searchFileAndOpenDir({ userId: this.$store.state.user.userId, id: row.id, - currentDirectory: this.$route.query.path, + currentDirectory: encodeURIComponent(this.$route.query.path), pageIndex: this.pagination.pageIndex, pageSize: this.pagination.pageSize }).then(res => { @@ -2011,7 +2011,7 @@ export default { api.fileList({ userId: this.$store.state.user.userId, username: this.$store.state.user.name, - currentDirectory: this.$route.query.path, + currentDirectory: encodeURIComponent(this.$route.query.path), queryFileType: this.queryFileType, sortableProp: this.sortable.prop, order: this.sortable.order, @@ -2028,7 +2028,7 @@ export default { this.beforeLoadData(onLoad) api.fileList({ userId: this.$store.state.user.userId, - currentDirectory: this.path, + currentDirectory: encodeURIComponent(this.$route.query.path), pageIndex: this.pagination.pageIndex, pageSize: this.pagination.pageSize }).then(res => { @@ -2777,7 +2777,7 @@ export default { api.newFolder({ isFolder: true, filename: data.name, - currentDirectory: path, + currentDirectory: encodeURIComponent(this.$route.query.path), username: this.$store.state.user.name, userId: this.$store.state.user.userId }).then((res) => { diff --git a/src/utils/file-config.js b/src/utils/file-config.js index 0fa85e4..9f0391b 100644 --- a/src/utils/file-config.js +++ b/src/utils/file-config.js @@ -10,9 +10,14 @@ export default { // 预览文件的url previewUrl: function(username, file, token) { if (token) { - return `${this.baseUrl}/file/${username}${file.path}${encodeURIComponent(file.name)}?jmal-token=${token}` + let path = "/" + if (file.path.length > 1) { + path = encodeURIComponent(file.path.substr(1, file.path.length - 2)) + } + const filename = encodeURIComponent(file.name); + return `${this.baseUrl}/file/${username}/${path}/${filename}?jmal-token=${token}` } else { - return `${this.baseUrl}/file/${username}${file.path}${encodeURIComponent(file.name)}` + return `${this.baseUrl}/file/${username}/${path}/${filename}` } }, // mardown里上传图片后的图片预览地址