From add2cea545cbf5afb13554766abafb836c7e44d0 Mon Sep 17 00:00:00 2001 From: hz4th_coder Date: Tue, 11 Aug 2026 15:33:19 +0800 Subject: [PATCH] =?UTF-8?q?v1.0.6:=20=E5=AF=BC=E5=85=A5=E7=BD=91=E5=9D=80?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A2=9E=E5=8A=A0=E8=BF=BD=E5=8A=A0/?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E5=A4=84=E7=90=86=E6=96=B9=E5=BC=8F=E9=80=89?= =?UTF-8?q?=E6=8B=A9(=E9=BB=98=E8=AE=A4=E8=BF=BD=E5=8A=A0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- static/app.js | 15 +++++++++++---- static/index.html | 6 +++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b7ce483..9365f55 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,10 @@ - 运行中的任务参数支持**热更新**(修改后从下一页起生效) ### 2. 批量爬取模式 -一次粘贴多个网址(每行一个,`#` 注释),或点击「📂 导入网址文件」上传 .txt 文件批量导入(自动识别 UTF-8/GBK 编码、自动去重、自动清理行内注释): +一次粘贴多个网址(每行一个,`#` 注释),或点击「📂 导入网址文件」上传 .txt 文件批量导入: +- **处理方式可选**:追加(保留已有,默认)或覆盖(清空已有) +- 自动识别 UTF-8/GBK 编码、自动去重、自动清理行内注释 +可配置: - 项目名称、输出目录(默认 `out/<任务ID>`,可填绝对路径) - 爬取间隔(随机秒数区间,防封 IP)、单页超时 - 失败重试次数 / 重试间隔 diff --git a/static/app.js b/static/app.js index bd7d21a..0c8d1aa 100644 --- a/static/app.js +++ b/static/app.js @@ -174,10 +174,12 @@ async function readFileSmart(file) { return text; } -function importUrlsText(text) { +function importUrlsText(text, mode) { const ta = $("taskForm").elements["urls"]; const clean = (s) => s.split(" #")[0].trim(); // 去掉行内注释 (URL 不含空格, 安全) - const existing = new Set(ta.value.split(/\r?\n/).map(clean).filter(Boolean)); + const existing = new Set( + mode === "overwrite" ? [] : ta.value.split(/\r?\n/).map(clean).filter(Boolean) + ); const fresh = text.split(/\r?\n/).map(clean).filter(Boolean); let added = 0; for (const line of fresh) { @@ -198,9 +200,14 @@ $("urlFileInput").onchange = async (e) => { } try { const text = await readFileSmart(file); - const r = importUrlsText(text); + const mode = $("importMode").value; + const r = importUrlsText(text, mode); formDirty = true; - toast(`已导入 ${file.name}:共 ${r.total} 行,新增 ${r.added} 条网址`); + if (mode === "overwrite") { + toast(`已导入 ${file.name}:共 ${r.total} 行(覆盖原列表,新增 ${r.added} 条)`); + } else { + toast(`已导入 ${file.name}:共 ${r.total} 行,新增 ${r.added} 条网址(追加)`); + } } catch (err) { toast("文件读取失败: " + err.message, true); } diff --git a/static/index.html b/static/index.html index ad53684..4816059 100644 --- a/static/index.html +++ b/static/index.html @@ -77,7 +77,11 @@
- 支持 UTF-8 / GBK 编码,自动去重追加 + + 支持 UTF-8 / GBK,自动去重