mirror of
https://github.com/RhenCloud/Cloud-Index.git
synced 2025-12-06 15:26:10 +08:00
feat: 优化下载功能,支持路径编码和直接下载链接
This commit is contained in:
@@ -12,7 +12,12 @@ function attachDownloadButtonListeners() {
|
||||
button.addEventListener("click", () => {
|
||||
const key = button.dataset.downloadKey;
|
||||
const name = button.dataset.downloadName;
|
||||
downloadFile(`/download/${key}`, name);
|
||||
// 对路径分段编码,保留路径分隔符,避免 # ? 等字符破坏 URL
|
||||
const encoded = key
|
||||
.split("/")
|
||||
.map((seg) => encodeURIComponent(seg))
|
||||
.join("/");
|
||||
downloadFile(`/download/${encoded}`, name);
|
||||
});
|
||||
button.dataset.listenerAttached = "true";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user