互联网搜索支持多搜索引擎选择

- 新增搜索引擎选择下拉框
- 支持 Bing 中国(默认)、Bing 国际、Google、百度
- 后端 API 支持 engine 参数
- 添加百度搜索结果解析方法
This commit is contained in:
2026-07-13 17:03:26 +08:00
parent 9d6481bd06
commit c3eef4fa21
5 changed files with 95 additions and 12 deletions
+9 -2
View File
@@ -19,6 +19,7 @@ document.addEventListener('DOMContentLoaded', () => {
async function doSearch() {
const keyword = document.getElementById('search-keyword').value.trim();
const maxResults = parseInt(document.getElementById('search-count').value) || 10;
const engine = document.getElementById('search-engine').value;
const autoFetch = document.getElementById('auto-fetch').checked;
const autoSave = document.getElementById('auto-save').checked;
@@ -28,7 +29,13 @@ async function doSearch() {
}
// 更新状态
updateStatus('searching', '搜索中...');
const engineNames = {
'bing_cn': 'Bing 中国',
'bing_global': 'Bing 国际',
'google': 'Google',
'baidu': '百度'
};
updateStatus('searching', `正在通过 ${engineNames[engine]} 搜索...`);
document.getElementById('search-btn').disabled = true;
// 显示进度
@@ -41,7 +48,7 @@ async function doSearch() {
const response = await fetch(`${API_BASE}/api/articles/internet-search`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ keyword, max_results: maxResults })
body: JSON.stringify({ keyword, max_results: maxResults, engine })
});
const data = await response.json();