From 092a0084d0c7ff82a0325acbb1d48348716f4bf1 Mon Sep 17 00:00:00 2001 From: jmal Date: Wed, 3 May 2023 11:58:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dwindows=E4=B8=8B?= =?UTF-8?q?=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 | 12 +++++++++--- src/components/input/UploadImageInput.vue | 2 +- src/utils/file-config.js | 8 +++++--- src/views/markdown/index.vue | 4 ++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index ea19577..244e938 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -973,7 +973,7 @@ export default { this.selectPin = true } // ctrl + A / cmd + A - if (this.isCmd && keyCode == 65) { + if (this.isCmd && keyCode === 65) { if (this.inputting || this.editingIndex !== -1) { event.target.select() } else { @@ -999,7 +999,6 @@ export default { onmessageFault(msg) { if ('fault' === msg) { this.getFileList() - return } }, onmessage(msg) { @@ -1024,10 +1023,14 @@ export default { } if (fileDoc) { if (fileDoc.$set) { - if (this.path + '/' === fileDoc.$set.path) { + let path = fileDoc.$set.path + path = path.replace(/\\/g, '/') + if (this.path + '/' === path) { this.getFileList() } } else { + let path = fileDoc.path + path = path.replace(/\\/g, '/') if (this.path + '/' === fileDoc.path) { this.getFileList() } @@ -1740,6 +1743,7 @@ export default { } else { this.path += '/' + this.pathList[number].folder } + this.path = this.path.replace(/\\/g, '/') }) if (!unPushLink) { if (!this.$route.query.path) { @@ -2069,6 +2073,7 @@ export default { this.listModeSearchOpenDir = row }) this.path = row.path + row.name + this.path = this.path.replace(/\\/g, '/') }, openDir(row, onLoad) { this.beforeLoadData(onLoad) @@ -2083,6 +2088,7 @@ export default { this.loadData(res, onLoad) }) this.path = row.path + row.name + this.path = this.path.replace(/\\/g, '/') }, getFileList(onLoad) { this.beforeLoadData(onLoad) diff --git a/src/components/input/UploadImageInput.vue b/src/components/input/UploadImageInput.vue index 61b3ebd..dd03e1b 100644 --- a/src/components/input/UploadImageInput.vue +++ b/src/components/input/UploadImageInput.vue @@ -175,7 +175,7 @@ export default { this.fileList = fileList }, format(filepath){ - this.currentValue = fileConfig.mardownPreviewUrl(filepath) + this.currentValue = fileConfig.markdownPreviewUrl(filepath) this.change(this.currentValue) }, // url转blob diff --git a/src/utils/file-config.js b/src/utils/file-config.js index 4265197..1fed9ab 100644 --- a/src/utils/file-config.js +++ b/src/utils/file-config.js @@ -21,6 +21,7 @@ export default { // 预览文件的url previewUrl: function(username, file, token, shareToken) { let fileUrl = `${this.baseUrl}/file/${username}${encodeURI(file.path)}${encodeURI(file.name)}` + fileUrl = fileUrl.replace(/%5C/g, '/') if (token) { return `${fileUrl}?jmal-token=${token}&name=${username}` } @@ -29,13 +30,14 @@ export default { } return fileUrl }, - // mardown里上传图片后的图片预览地址 - mardownPreviewUrl: function (path){ + // markdown里上传图片后的图片预览地址 + markdownPreviewUrl: function (path){ return window.location.origin + `${this.baseUrl}${path}` }, // 预览文件 preview: function(username, file, token) { - const url = this.previewUrl(username, file, token) + let url = this.previewUrl(username, file, token) + url = url.replace(/%5C/g, '/') window.open(url, '_blank') }, // 下载文件 diff --git a/src/views/markdown/index.vue b/src/views/markdown/index.vue index 4e86ec8..947782f 100644 --- a/src/views/markdown/index.vue +++ b/src/views/markdown/index.vue @@ -393,7 +393,7 @@ export default { let response = JSON.parse(responseText) let succMap = {} response.data.forEach(map => { - succMap[map.filename] = fileConfig.mardownPreviewUrl(map.filepath) + succMap[map.filename] = fileConfig.markdownPreviewUrl(map.filepath) }) response.data = {} response.data['succMap'] = succMap @@ -405,7 +405,7 @@ export default { linkToImgUrl: '/api/upload-markdown-link-image', linkToImgFormat(responseText) { let response = JSON.parse(responseText) - response.data['url'] = fileConfig.mardownPreviewUrl(response.data.url) + response.data['url'] = fileConfig.markdownPreviewUrl(response.data.url) return JSON.stringify(response) }, }