diff --git a/src/components/FancyTree/index.vue b/src/components/FancyTree/index.vue index 90db727..5de7604 100644 --- a/src/components/FancyTree/index.vue +++ b/src/components/FancyTree/index.vue @@ -243,7 +243,7 @@ }).then(() => { api.delFile({ username: this.$store.state.user.name, - path: encodeURI(data.path) + path: encodeURIComponent(data.path) }).then(()=>{ this.$emit('removeFile', data.path) let node = this.tree.getActiveNode() @@ -261,7 +261,7 @@ let path = this.currentPath.substring(0,this.currentPath.length-title.length) api.upperLevelList({ username: this.$store.state.user.name, - path: encodeURI(path), + path: encodeURIComponent(path), }).then(res => { this.tree.reload(this.convert(res.data)) }) @@ -271,7 +271,7 @@ api.listfiles({ userId: this.$store.state.user.userId, username: this.$store.state.user.name, - path: encodeURI(this.currentPath), + path: encodeURIComponent(this.currentPath), }).then(res => { this.tree.reload(this.convert(res.data)) }) @@ -292,7 +292,7 @@ api.listfiles({ userId: this.$store.state.user.userId, username: this.$store.state.user.name, - path: encodeURI(node.path), + path: encodeURIComponent(node.path), }).then(res => { loading.close() if(res.data.length === 0){ @@ -311,7 +311,7 @@ api.listfiles({ userId: this.$store.state.user.userId, username: this.$store.state.user.name, - path: encodeURI(treeData.path), + path: encodeURIComponent(treeData.path), }).then(res => { let oldname = treeData.name let data = res.data.map(doc => { @@ -350,10 +350,10 @@ } } api.addFile({ - fileName: encodeURI(fileName), + fileName: encodeURIComponent(fileName), isFolder: node.folder, username: this.$store.state.user.name, - parentPath: encodeURI(parentPath) + parentPath: encodeURIComponent(parentPath) }).then((res)=>{ let str = node.folder?'文件夹':'文件' this.$message.success(`新建${str}成功`) @@ -429,7 +429,7 @@ api.renameByPath({ newFileName: newFileName, username: this.$store.state.user.name, - path: encodeURI(node.data.path) + path: encodeURIComponent(node.data.path) }).then(res => { row.oldName = node.data.name row.name = newFileName @@ -466,7 +466,7 @@ return new Promise(function(resolve) { api.listfiles({ username: that.$store.state.user.name, - path: encodeURI(data.path), + path: encodeURIComponent(data.path), }).then(res => { resolve(that.convert(res.data)) }) diff --git a/src/components/FileTree/DirTree.vue b/src/components/FileTree/DirTree.vue index a20de83..0eb1bdb 100644 --- a/src/components/FileTree/DirTree.vue +++ b/src/components/FileTree/DirTree.vue @@ -174,8 +174,8 @@ export default { } api.newFolder({ isFolder: true, - filename: encodeURI(data.name), - currentDirectory: encodeURI(path), + filename: encodeURIComponent(data.name), + currentDirectory: encodeURIComponent(path), username: this.$store.state.user.name, userId: this.$store.state.user.userId }).then((res) => { diff --git a/src/components/FileTree/index.vue b/src/components/FileTree/index.vue index 9b840be..3d995f3 100644 --- a/src/components/FileTree/index.vue +++ b/src/components/FileTree/index.vue @@ -136,7 +136,7 @@ export default { api .listfiles({ username: this.$store.state.user.name, - path: encodeURI(node.data.path), + path: encodeURIComponent(node.data.path), tempDir: this.tempDir }) .then(res => { @@ -205,8 +205,8 @@ export default { let newFolderName = document.getElementById("treeInput").value api.newFolder({ isFolder: true, - filename: encodeURI(newFolderName), - currentDirectory: encodeURI(path), + filename: encodeURIComponent(newFolderName), + currentDirectory: encodeURIComponent(path), username: this.$store.state.user.name, userId: this.$store.state.user.userId }).then((res) => { diff --git a/src/components/HistoryPopover/index.vue b/src/components/HistoryPopover/index.vue index a90e779..3c6afba 100644 --- a/src/components/HistoryPopover/index.vue +++ b/src/components/HistoryPopover/index.vue @@ -155,7 +155,7 @@ export default { if (!this.$store.getters.token) return this.resetState() this.loadApiFunction = historyApi.fileHistoryPathList - this.loadApiParams = { path: encodeURI(pathname), username: this.$store.state.user.name } + this.loadApiParams = { path: encodeURIComponent(pathname), username: this.$store.state.user.name } this._internalLoadHistory() }, diff --git a/src/components/Minder/minder.vue b/src/components/Minder/minder.vue index 51cb2f9..35fcac3 100644 --- a/src/components/Minder/minder.vue +++ b/src/components/Minder/minder.vue @@ -187,7 +187,7 @@ export default { fileId: this.file.id, id: this.file.id, fileName: this.file.name, - path: encodeURI(this.file.path), + path: encodeURIComponent(this.file.path), username: this.$store.state.user.name, content: true, }).then((res) => { @@ -391,7 +391,7 @@ export default { update(value) { this.saveBtnUpdating = true txtApi.editMarkdownByPath({ - relativePath: encodeURI(this.file.path + this.file.name), + relativePath: encodeURIComponent(this.file.path + this.file.name), userId: this.$store.state.user.userId, username: this.$store.state.user.name, mountFileId: this.$store.state.user.userId !== this.file.userId ? this.file.id : '', diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index 1258067..6793a70 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -2366,7 +2366,7 @@ export default { : '' const basePath = this.getBasePath() this.$router.push( - `/?vmode=${this.vmode}&path=${encodeURI( + `/?vmode=${this.vmode}&path=${encodeURIComponent( this.path )}${queryTagId}${basePath}${keyword}` ) @@ -2431,7 +2431,7 @@ export default { keywordQuery = '' searchOpenFolder = '' } - this.$router.push(`?vmode=${this.vmode}&path=${encodeURI(this.path).replaceAll('#', '%23')}${queryFolder ? '&folder=' + queryFolder : ''}${queryTagId}${basePath}${keywordQuery}${searchOpenFolder}`) + this.$router.push(`?vmode=${this.vmode}&path=${encodeURIComponent(this.path).replaceAll('#', '%23')}${queryFolder ? '&folder=' + queryFolder : ''}${queryTagId}${basePath}${keywordQuery}${searchOpenFolder}`) } if (!unRefresh) { this.pagination.pageIndex = 1 @@ -2565,7 +2565,7 @@ export default { api .uploadFolder({ isFolder: true, - filename: encodeURI(this.newFolderName), + filename: encodeURIComponent(this.newFolderName), currentDirectory: this.getQueryPath(), folder: this.$route.query.searchOpenFolder || this.$route.query.folder, username: this.$store.state.user.name, @@ -2629,11 +2629,11 @@ export default { let suffix = newFileName.substring(newFileName.lastIndexOf('.') + 1) api .addFile({ - fileName: encodeURI(newFileName), + fileName: encodeURIComponent(newFileName), isFolder: false, folder: this.$route.query.searchOpenFolder || this.$route.query.folder, username: this.$store.state.user.name, - parentPath: encodeURI(parentPath), + parentPath: encodeURIComponent(parentPath), }) .then(res => { this.createFileLoading = false @@ -2881,7 +2881,7 @@ export default { const basePath = this.getBasePath() const keyword = key ? `&keyword=${key}` : '' const path = this.path - ? encodeURI(this.path.replace(this.basePath, '/')) + ? encodeURIComponent(this.path.replace(this.basePath, '/')) : '/' this.$router.push( `?vmode=${ @@ -3032,7 +3032,7 @@ export default { basePath = basePath.substring(0, basePath.length - 1) } } - return encodeURI(basePath + this.$route.query.path) + return encodeURIComponent(basePath + this.$route.query.path) }, tableBodyScroll(table, e) { this.fileListScrollTop = e.target.scrollTop @@ -3359,7 +3359,7 @@ export default { } api .rename({ - newFileName: encodeURI(newFileName), + newFileName: encodeURIComponent(newFileName), username: this.$store.state.user.name, folder: this.$route.query.searchOpenFolder || this.$route.query.folder, id: row.id, @@ -4033,7 +4033,7 @@ export default { api .newFolder({ isFolder: true, - filename: encodeURI(newFolderName), + filename: encodeURIComponent(newFolderName), currentDirectory: this.getQueryPath(), folder: this.$route.query.searchOpenFolder || this.$route.query.folder, username: this.$store.state.user.name, @@ -4423,8 +4423,7 @@ export default { this.path = this.path.replace(/\/\//g, '/') // 去掉this.path开头的this.basePath this.path = this.path.replace(this.basePath, '/') - const path = encodeURI(this.path).replaceAll('#', '%23') - + const path = encodeURIComponent(this.path).replaceAll('#', '%23') const item = { folder: row.name, shareBase: row.shareBase } this.pathList.push(item) this.pagination.pageIndex = 1 diff --git a/src/components/office/Drawio.vue b/src/components/office/Drawio.vue index 39b2776..5d48734 100644 --- a/src/components/office/Drawio.vue +++ b/src/components/office/Drawio.vue @@ -111,7 +111,7 @@ export default { fileId: this.file.id, id: this.file.id, fileName: this.file.name, - path: encodeURI(this.file.path), + path: encodeURIComponent(this.file.path), username: this.$store.state.user.name, content: true, }).then(async (res) => { @@ -225,7 +225,7 @@ export default { update(value) { this.saveBtnUpdating = true txtApi.editMarkdownByPath({ - relativePath: encodeURI(this.file.path + this.file.name), + relativePath: encodeURIComponent(this.file.path + this.file.name), userId: this.$store.state.user.userId, username: this.$store.state.user.name, mountFileId: this.$store.state.user.userId !== this.file.userId ? this.file.id : '', diff --git a/src/components/office/ExcalidrawEditor.vue b/src/components/office/ExcalidrawEditor.vue index 032acb3..233cda1 100644 --- a/src/components/office/ExcalidrawEditor.vue +++ b/src/components/office/ExcalidrawEditor.vue @@ -123,7 +123,7 @@ export default { fileId: this.file.id, id: this.file.id, fileName: this.file.name, - path: encodeURI(this.file.path), + path: encodeURIComponent(this.file.path), username: this.$store.state.user.name, content: true, }).then(async (res) => { @@ -234,7 +234,7 @@ export default { this.saveBtnUpdating = true this.currentContext = JSON.stringify(this.excalidrawData) txtApi.editMarkdownByPath({ - relativePath: encodeURI(this.file.path + this.file.name), + relativePath: encodeURIComponent(this.file.path + this.file.name), userId: this.$store.state.user.userId, username: this.$store.state.user.name, mountFileId: this.$store.state.user.userId !== this.file.userId ? this.file.id : '', diff --git a/src/components/preview/SimTextPreview.vue b/src/components/preview/SimTextPreview.vue index 9e5deee..979faf8 100644 --- a/src/components/preview/SimTextPreview.vue +++ b/src/components/preview/SimTextPreview.vue @@ -344,7 +344,7 @@ fileId: file.id, id: file.id, fileName: file.name, - path: encodeURI(file.path), + path: encodeURIComponent(file.path), username: this.$store.state.user.name } api[request](params).then((res) => { @@ -733,7 +733,7 @@ message: '  正在加载数据...' }) const params = { - path: encodeURI(row.path), + path: encodeURIComponent(row.path), fileName: row.name, username: this.$store.state.user.name } @@ -976,7 +976,7 @@ update(value,path,index) { this.updating = true markdownApi.editMarkdownByPath({ - relativePath: encodeURI(path), + relativePath: encodeURIComponent(path), userId: this.$store.state.user.userId, username: this.$store.state.user.name, mountFileId: this.mountFileId, diff --git a/src/utils/file-config.js b/src/utils/file-config.js index a839812..3853745 100644 --- a/src/utils/file-config.js +++ b/src/utils/file-config.js @@ -36,12 +36,12 @@ export default { // 预览文件的url previewUrl: function(username, file, token, shareToken, serverUrl) { let baseUrl = serverUrl || this.baseUrl - let fileUrl = `${baseUrl}/file/${store.getters.name}${encodeURI(file.path)}${encodeURI(file.name)}` + let fileUrl = `${baseUrl}/file/${store.getters.name}${encodeURIComponent(file.path)}${encodeURIComponent(file.name)}` fileUrl = fileUrl.replaceAll('#', '%23') fileUrl = fileUrl.replaceAll(/%5C/g, '/') if (file.userId !== store.getters.userId && token && !shareToken) { - return `${baseUrl}/pre-file/${file.id}/${encodeURI(file.name)}?jmal-token=${token}&name=${username}` + return `${baseUrl}/pre-file/${file.id}/${encodeURIComponent(file.name)}?jmal-token=${token}&name=${username}` } if (token) { @@ -51,12 +51,12 @@ export default { if (isFilePath(file.id)) { return `${fileUrl}?share-token=${shareToken}` } - return `${baseUrl}/share-file/${file.id}/${shareToken}/${encodeURI(file.name)}` + return `${baseUrl}/share-file/${file.id}/${shareToken}/${encodeURIComponent(file.name)}` } if (isFilePath(file.id)) { return fileUrl } - return `${baseUrl}/share-file/${file.id}/${encodeURI(file.name)}` + return `${baseUrl}/share-file/${file.id}/${encodeURIComponent(file.name)}` }, // 预览历史文件 previewHistoryUrl: function(historyId, name, token) { diff --git a/src/utils/path.js b/src/utils/path.js index c9859bc..b806173 100644 --- a/src/utils/path.js +++ b/src/utils/path.js @@ -6,6 +6,6 @@ export function encodeIfNeeded(str) { if (isEncoded(str)) { return str; } else { - return encodeURI(str); + return encodeURIComponent(str); } } diff --git a/src/views/home/mobile/index.vue b/src/views/home/mobile/index.vue index f050a63..64d62c2 100644 --- a/src/views/home/mobile/index.vue +++ b/src/views/home/mobile/index.vue @@ -603,7 +603,7 @@ export default { } api.rename({ - newFileName: encodeURI(newFileName), + newFileName: encodeURIComponent(newFileName), username: this.$store.state.user.name, folder: this.$route.query.folder, id: row.id @@ -771,7 +771,7 @@ export default { // 浏览器的返回事件 goBack() { if (this.pathList.length <= 1) { - this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}`) + this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}`) return } this.clickBack() @@ -881,9 +881,9 @@ export default { let queryFolder = localStorage.getItem(this.path) if (!unPushLink) { if (!this.$route.query.path) { - this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`) + this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`) } else { - this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`) + this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`) } } if (!unRefresh) { @@ -939,7 +939,7 @@ export default { api.fileList({ username: this.$store.state.user.name, userId: this.$store.state.user.userId, - currentDirectory: encodeURI(this.$route.query.path), + currentDirectory: encodeURIComponent(this.$route.query.path), folder: this.$route.query.folder, queryFileType: this.queryFileType, sortableProp: this.sortableProp, @@ -963,7 +963,7 @@ export default { userId: this.$store.state.user.userId, username: this.$store.state.user.name, keyword: key, - currentDirectory: encodeURI(this.$route.query.path), + currentDirectory: encodeURIComponent(this.$route.query.path), pageIndex: this.pagination.pageIndex, pageSize: this.pagination.pageSize }).then(res => { @@ -1136,7 +1136,7 @@ export default { this.$router.push(`?vmode=${this.vmode}${path}${keyword}${folder}`); this.getFileList() } else { - const path = encodeURI(this.path); + const path = encodeURIComponent(this.path); if (this.$store.getters.userId !== row.userId) { row.mountFileId = row.id } @@ -1280,7 +1280,7 @@ export default { return { // 传入的参数 folder: this.$route.query.folder, - currentDirectory: encodeURI(this.path), + currentDirectory: encodeURIComponent(this.path), username: this.$store.state.user.name, userId: this.$store.state.user.userId } @@ -1291,9 +1291,9 @@ export default { if (this.newFolderName) { api.uploadFolder({ isFolder: true, - filename: encodeURI(this.newFolderName), + filename: encodeURIComponent(this.newFolderName), folder: this.$route.query.folder, - currentDirectory: encodeURI(this.path), + currentDirectory: encodeURIComponent(this.path), username: this.$store.state.user.name, userId: this.$store.state.user.userId }).then((res) => { diff --git a/src/views/markdown/index.vue b/src/views/markdown/index.vue index 1f8ea3c..97e65b0 100644 --- a/src/views/markdown/index.vue +++ b/src/views/markdown/index.vue @@ -377,7 +377,7 @@ export default { fileId: this.$route.query.id, userId: this.$store.state.user.userId, username: this.$store.state.user.name, - filename: encodeURI(this.filename + ".md"), + filename: encodeURIComponent(this.filename + ".md"), cover: this.file.cover, isDraft: this.draft, isRelease: this.file.release,