refactor(file-config): 重构直接文件 URL 生成逻辑

-简化了直接文件 URL 的生成逻辑,提高了代码的可读性和可维护性
- 使用 encodeURIComponent 替代 encodeURI,确保文件名中的特殊字符被正确编码- 通过拼接变量的方式优化了 URL 的构建过程,提高了代码的灵活性
This commit is contained in:
jmal 2025-06-29 12:13:57 +08:00
parent 912ece879e
commit 2765fc0b51

View File

@ -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}`
}
}