Compare commits

...
1 Commits
Author SHA1 Message Date
hz4th_coder b0d98b78d9 修复停止按钮:搜索开始时即显示
- 搜索开始就显示停止按钮
- 搜索完成后隐藏,自动抓取时再显示
- 整个流程中都可以随时停止
2026-07-13 23:22:02 +08:00
+18 -5
View File
@@ -45,9 +45,11 @@ async function doSearch() {
updateStatus('searching', `正在通过 ${engineNames[engine]} 搜索...`);
document.getElementById('search-btn').disabled = true;
// 显示进度
// 显示进度和停止按钮
shouldStop = false;
const progress = document.getElementById('search-progress');
progress.style.display = 'block';
document.getElementById('stop-btn').style.display = 'inline-flex';
document.getElementById('progress-fill').style.width = '0%';
document.getElementById('progress-text').textContent = '正在搜索...';
@@ -70,6 +72,14 @@ async function doSearch() {
displayResults();
// 检查是否被停止
if (shouldStop) {
document.getElementById('stop-btn').style.display = 'none';
document.getElementById('progress-text').textContent = '已停止';
updateStatus('warning', '搜索已停止');
return;
}
// 显示缓存状态
if (data.cached) {
updateStatus('success', `找到 ${searchResults.length} 条结果(使用缓存)`);
@@ -83,25 +93,28 @@ async function doSearch() {
document.getElementById('progress-fill').style.width = '100%';
document.getElementById('progress-text').textContent = '搜索完成!';
document.getElementById('stop-btn').style.display = 'none'; // 隐藏停止按钮
// 自动抓取和保存
if (autoFetch && searchResults.length > 0) {
setTimeout(() => fetchAllResults(autoSave), 500);
} else {
setTimeout(() => {
progress.style.display = 'none';
}, 1000);
}
} else {
document.getElementById('stop-btn').style.display = 'none';
updateStatus('error', '搜索失败');
showToast('搜索失败: ' + data.error, 'error');
}
} catch (error) {
document.getElementById('stop-btn').style.display = 'none';
updateStatus('error', '搜索出错');
showToast('搜索出错', 'error');
console.error(error);
}
setTimeout(() => {
progress.style.display = 'none';
}, 1000);
document.getElementById('search-btn').disabled = false;
}