From 2765fc0b51ca74c4dd6c298bec1a6a1bb4d43b8f Mon Sep 17 00:00:00 2001 From: jmal Date: Sun, 29 Jun 2025 12:13:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor(file-config):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=96=87=E4=BB=B6=20URL=20=E7=94=9F=E6=88=90?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -简化了直接文件 URL 的生成逻辑,提高了代码的可读性和可维护性 - 使用 encodeURIComponent 替代 encodeURI,确保文件名中的特殊字符被正确编码- 通过拼接变量的方式优化了 URL 的构建过程,提高了代码的灵活性 --- src/utils/file-config.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/utils/file-config.js b/src/utils/file-config.js index e41b78b..a839812 100644 --- a/src/utils/file-config.js +++ b/src/utils/file-config.js @@ -144,10 +144,8 @@ export default { return null; }, directFileUrl: function(mark, file) { - if (file.isFolder) { - return window.location.origin + `${this.baseUrl}/direct-file/${mark}/${encodeURI(file.name)}.zip` - } else { - return window.location.origin + `${this.baseUrl}/direct-file/${mark}/${encodeURI(file.name)}` - } + const encodedName = encodeURIComponent(file.name); + const suffix = file.isFolder ? '.zip' : ''; + return `${window.location.origin}${this.baseUrl}/direct-file/${mark}/${encodedName}${suffix}` } }