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 @@
-
正在搜索...
+
+ 正在搜索... + +