mirror of
https://github.com/RhenCloud/Cloud-Index.git
synced 2025-12-06 15:26:10 +08:00
refactor: 模块化前端代码 - 将 main.js 和 main.css 拆分为专用模块
- 移除 main.js 并替换为8个 JS 模块 - 移除 main.css 并替换为7个 CSS 模块 - 更新 base.html 以加载模块化文件 - 通过 index.css 保持完全向后兼容 - 改进代码组织、可维护性和可复用性
This commit is contained in:
27
static/js/download.js
Normal file
27
static/js/download.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 下载按钮事件处理
|
||||
*/
|
||||
|
||||
/**
|
||||
* 绑定下载按钮监听器
|
||||
*/
|
||||
function attachDownloadButtonListeners() {
|
||||
const downloadButtons = document.querySelectorAll("[data-download-key]");
|
||||
downloadButtons.forEach((button) => {
|
||||
if (!button.dataset.listenerAttached) {
|
||||
button.addEventListener("click", () => {
|
||||
const key = button.dataset.downloadKey;
|
||||
const name = button.dataset.downloadName;
|
||||
downloadFile(`/download/${key}`, name);
|
||||
});
|
||||
button.dataset.listenerAttached = "true";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出到全局作用域
|
||||
*/
|
||||
window.DownloadUtils = {
|
||||
attachDownloadButtonListeners,
|
||||
};
|
||||
Reference in New Issue
Block a user