修改配置文件

This commit is contained in:
2026-06-18 21:59:07 +08:00 Unverified
parent fc76f9949f
commit ed2ef30d22
23 changed files with 270 additions and 137 deletions
+11 -28
View File
@@ -4,28 +4,11 @@
// ============================================================================
// 配置区域 - 请根据实际情况修改
// ============================================================================
const CONFIG = {
apiKey: "2uxQzk7eD2GBCljdSmIiuU3ause7UK9n", // ⚠️ 建议使用 Search-Only API Key
server: {
host: "typesense.biss.click",
port: "443",
protocol: "https"
},
indexName: "blogs",
searchParams: {
query_by: "title,content",
highlight_full_fields: "title,content",
per_page: 8,
num_typos: 1,
typo_tokens_threshold: 1,
prefix: true
},
ui: {
maxRetries: 10,
retryDelay: 100,
animationDuration: 300
}
};
const CONFIG = window.SITE_CONFIG?.search;
if (!CONFIG) {
console.warn('Typesense 搜索配置未加载');
return;
}
// ============================================================================
// 状态管理
@@ -34,7 +17,7 @@
let isInitialized = false;
let isSearchOpen = false;
let initRetryCount = 0;
const MAX_INIT_RETRIES = 30; // 最多重试30次 (3秒)
const MAX_INIT_RETRIES = CONFIG.ui.maxInitRetries || 30; // 最多重试30次 (3秒)
// ============================================================================
// 错误提示函数
@@ -326,7 +309,7 @@
setTimeout(function() {
mask.style.display = 'none';
document.body.style.overflow = '';
}, CONFIG.ui.animationDuration);
}, CONFIG.ui.animationDuration || 300);
}
function focusSearchInput(retryCount) {
@@ -335,10 +318,10 @@
if (input) {
input.focus();
input.select();
} else if (retryCount < CONFIG.ui.maxRetries) {
} else if (retryCount < (CONFIG.ui.maxRetries || 10)) {
setTimeout(function() {
focusSearchInput(retryCount + 1);
}, CONFIG.ui.retryDelay);
}, CONFIG.ui.retryDelay || 100);
}
}
@@ -443,7 +426,7 @@
searchInstance.addWidgets([
instantsearch.widgets.searchBox({
container: '#searchbox',
placeholder: '输入关键词寻找故事...',
placeholder: CONFIG.ui.placeholder || '输入关键词寻找故事...',
autofocus: true,
showReset: true,
showSubmit: false,
@@ -542,4 +525,4 @@
getInstance: function() { return searchInstance; }
};
})();
})();