From d63fe2f6717d33a35fe6336d9b6990cbeabeffa1 Mon Sep 17 00:00:00 2001 From: hz4th_coder Date: Mon, 13 Jul 2026 23:18:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=8A=A8=E6=8A=93?= =?UTF-8?q?=E5=8F=96=E5=81=9C=E6=AD=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加停止按钮,自动抓取时显示 - 点击可随时终止自动抓取流程 - 显示已停止状态和已抓取数量 --- static/css/search.css | 7 +++++++ static/js/search.js | 23 +++++++++++++++++++++++ templates/search.html | 7 ++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/static/css/search.css b/static/css/search.css index d7aa407..8f7b021 100644 --- a/static/css/search.css +++ b/static/css/search.css @@ -151,6 +151,13 @@ font-size: 14px; } +.progress-info { + display: flex; + justify-content: space-between; + align-items: center; + margin-top: 10px; +} + /* 结果区域 */ .results-section { background: white; diff --git a/static/js/search.js b/static/js/search.js index e839bf4..c2818be 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -5,6 +5,9 @@ const API_BASE = ''; let searchResults = []; let currentResultIndex = -1; +// 自动流程控制 +let shouldStop = false; + // 页面加载初始化 document.addEventListener('DOMContentLoaded', () => { // 回车搜索 @@ -338,13 +341,27 @@ async function saveAllResults() { // 抓取所有结果 async function fetchAllResults(autoSave) { + shouldStop = false; // 重置停止标志 + const progress = document.getElementById('search-progress'); progress.style.display = 'block'; + document.getElementById('stop-btn').style.display = 'inline-flex'; // 显示停止按钮 const total = searchResults.length; let fetched = 0; for (let i = 0; i < searchResults.length; i++) { + // 检查是否停止 + if (shouldStop) { + document.getElementById('progress-text').textContent = `已停止(已抓取 ${fetched}/${total})`; + document.getElementById('stop-btn').style.display = 'none'; + setTimeout(() => { + progress.style.display = 'none'; + }, 2000); + showToast('自动抓取已停止', 'warning'); + return; + } + if (searchResults[i].fetched) { fetched++; continue; @@ -361,6 +378,7 @@ async function fetchAllResults(autoSave) { document.getElementById('progress-fill').style.width = '100%'; document.getElementById('progress-text').textContent = '抓取完成!'; + document.getElementById('stop-btn').style.display = 'none'; setTimeout(() => { progress.style.display = 'none'; @@ -372,6 +390,11 @@ async function fetchAllResults(autoSave) { } } +// 停止自动处理 +function stopAutoProcess() { + shouldStop = true; +} + // 显示结果详情 function showResultDetail(index) { currentResultIndex = index; diff --git a/templates/search.html b/templates/search.html index 9d9a10b..34c203a 100644 --- a/templates/search.html +++ b/templates/search.html @@ -62,7 +62,12 @@
-
正在搜索...
+
+ 正在搜索... + +