已移除多余按钮,仅保留一个“排队下载”按钮,并删除其对应旧事件监听。现在该按钮同时承担“下载/排队”逻辑:当有任务时入队,无任务时直接下载并显示进度。
Browse files
server.py
CHANGED
|
@@ -82,7 +82,7 @@ def root():
|
|
| 82 |
<h1>番茄小说下载器</h1>
|
| 83 |
<label for=\"book_ids\">小说ID列表(逗号或空格分隔):</label><br/>
|
| 84 |
<textarea id=\"book_ids\" rows=\"4\" cols=\"50\"></textarea><br/>
|
| 85 |
-
<button id=
|
| 86 |
<div id=\"progress\" style=\"display:none;margin-top:10px;\">\n <progress id=\"progBar\" value=\"0\" max=\"100\"></progress>\n <span id=\"progText\">0%</span>\n </div>\n <div id="downloadResult" style="margin-top:10px;"></div>
|
| 87 |
<div id="queueSection" style="margin-top:20px;">
|
| 88 |
<h2>下载队列</h2>
|
|
@@ -212,18 +212,7 @@ def root():
|
|
| 212 |
fetchCompleted(name);
|
| 213 |
});
|
| 214 |
|
| 215 |
-
|
| 216 |
-
document.getElementById('enqueueBtn').addEventListener('click', function(){
|
| 217 |
-
const book_ids = document.getElementById('book_ids').value;
|
| 218 |
-
if (!book_ids) return;
|
| 219 |
-
const ids = book_ids.split(/[\s,;]+/).filter(id => id);
|
| 220 |
-
ids.forEach(bid => {
|
| 221 |
-
fetch(`/enqueue?book_id=${encodeURIComponent(bid)}`)
|
| 222 |
-
.then(res => res.json())
|
| 223 |
-
.then(() => fetchTasks())
|
| 224 |
-
.catch(console.error);
|
| 225 |
-
});
|
| 226 |
-
});
|
| 227 |
// 初始化
|
| 228 |
fetchTasks();
|
| 229 |
fetchCompleted();
|
|
|
|
| 82 |
<h1>番茄小说下载器</h1>
|
| 83 |
<label for=\"book_ids\">小说ID列表(逗号或空格分隔):</label><br/>
|
| 84 |
<textarea id=\"book_ids\" rows=\"4\" cols=\"50\"></textarea><br/>
|
| 85 |
+
<button id="downloadBtn">排队下载</button>
|
| 86 |
<div id=\"progress\" style=\"display:none;margin-top:10px;\">\n <progress id=\"progBar\" value=\"0\" max=\"100\"></progress>\n <span id=\"progText\">0%</span>\n </div>\n <div id="downloadResult" style="margin-top:10px;"></div>
|
| 87 |
<div id="queueSection" style="margin-top:20px;">
|
| 88 |
<h2>下载队列</h2>
|
|
|
|
| 212 |
fetchCompleted(name);
|
| 213 |
});
|
| 214 |
|
| 215 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
// 初始化
|
| 217 |
fetchTasks();
|
| 218 |
fetchCompleted();
|