fix: 拼音搜索补充字映射 + 结果按匹配度排序
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 16s
Test / e2e-test (push) Failing after 55s

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 14:27:09 +00:00
parent a66ba3a0d9
commit 413abf60ba
2 changed files with 23 additions and 1 deletions

View File

@@ -677,9 +677,17 @@ function handleSmartPaste() {
function filteredOilNames(search) {
if (!search) return oils.oilNames
const q = search.toLowerCase()
return oils.oilNames.filter(name =>
const results = oils.oilNames.filter(name =>
name.toLowerCase().includes(q) || matchesPinyinInitials(name, q)
)
// Sort: pinyin prefix match first, then name contains, then rest
results.sort((a, b) => {
const aPin = matchesPinyinInitials(a, q) ? 0 : 1
const bPin = matchesPinyinInitials(b, q) ? 0 : 1
if (aPin !== bPin) return aPin - bPin
return a.localeCompare(b, 'zh')
})
return results
}
function selectOil(ing, name) {