fix(search): 外部引擎模式不再过滤本地内容

只有站内搜索模式才把输入用于本地过滤;Google 等模式保持页面内容不变,仅回车调用对应引擎
This commit is contained in:
2026-11-04 19:18:43 +08:00
parent aa6f341505
commit 4862f8fb6b
+5 -3
View File
@@ -335,6 +335,8 @@ export default function AppNext() {
searchEngines.find((engine) => engine.id === searchEngineId) ?? searchEngines.find((engine) => engine.id === searchEngineId) ??
searchEngines.find((engine) => engine.id === site.search.default) ?? searchEngines.find((engine) => engine.id === site.search.default) ??
INTERNAL_SEARCH INTERNAL_SEARCH
/** 只有站内搜索模式才用输入内容过滤本地内容 */
const localKeyword = searchEngine.id === 'internal' ? keywordLower : ''
// 配色:本机偏好优先于站点默认,写在 <html data-scheme> 上, // 配色:本机偏好优先于站点默认,写在 <html data-scheme> 上,
// 深色由组件库的令牌块接管,页面与组件都不用改 // 深色由组件库的令牌块接管,页面与组件都不用改
@@ -484,7 +486,7 @@ export default function AppNext() {
entries: Record<string, unknown>[], entries: Record<string, unknown>[],
options: { detail?: boolean; limit?: number } = {}, options: { detail?: boolean; limit?: number } = {},
) { ) {
const filtered = entries.filter((entry) => matches(entry, keywordLower)) const filtered = entries.filter((entry) => matches(entry, localKeyword))
const limit = options.limit ?? filtered.length const limit = options.limit ?? filtered.length
const items = filtered.slice(0, limit) const items = filtered.slice(0, limit)
const open = (itemId: string) => navigate(`/g/${encodeURIComponent(group.key)}/i/${encodeURIComponent(itemId)}`) const open = (itemId: string) => navigate(`/g/${encodeURIComponent(group.key)}/i/${encodeURIComponent(itemId)}`)
@@ -516,7 +518,7 @@ export default function AppNext() {
const source = rootGroup const source = rootGroup
? (group.entries as unknown as Record<string, unknown>[]) ? (group.entries as unknown as Record<string, unknown>[])
: collectEntries(group) : collectEntries(group)
const all = source.filter((entry) => matches(entry, keywordLower)) const all = source.filter((entry) => matches(entry, localKeyword))
if (all.length === 0) return null if (all.length === 0) return null
return ( return (
<div key={group.key} className="card-group-block"> <div key={group.key} className="card-group-block">
@@ -585,7 +587,7 @@ export default function AppNext() {
{cards.map((card) => {cards.map((card) =>
card.key === 'local-service' ? renderLocalService(card) : renderCard(card), card.key === 'local-service' ? renderLocalService(card) : renderCard(card),
)} )}
{keywordLower !== '' && cards.length > 0 && ( {localKeyword !== '' && cards.length > 0 && (
<Notice title={`搜索结果:${keyword.trim()}`}>在卡片与分组内按标题过滤。</Notice> <Notice title={`搜索结果:${keyword.trim()}`}>在卡片与分组内按标题过滤。</Notice>
)} )}
</div> </div>