refactor(file-config): 重构直接文件 URL 生成逻辑
-简化了直接文件 URL 的生成逻辑,提高了代码的可读性和可维护性 - 使用 encodeURIComponent 替代 encodeURI,确保文件名中的特殊字符被正确编码- 通过拼接变量的方式优化了 URL 的构建过程,提高了代码的灵活性
This commit is contained in:
parent
912ece879e
commit
2765fc0b51
@ -144,10 +144,8 @@ export default {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
directFileUrl: function(mark, file) {
|
directFileUrl: function(mark, file) {
|
||||||
if (file.isFolder) {
|
const encodedName = encodeURIComponent(file.name);
|
||||||
return window.location.origin + `${this.baseUrl}/direct-file/${mark}/${encodeURI(file.name)}.zip`
|
const suffix = file.isFolder ? '.zip' : '';
|
||||||
} else {
|
return `${window.location.origin}${this.baseUrl}/direct-file/${mark}/${encodedName}${suffix}`
|
||||||
return window.location.origin + `${this.baseUrl}/direct-file/${mark}/${encodeURI(file.name)}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user