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里上传图片后的图片预览地址