From 00fc797d5a8ef961f32bb7b0dd294937aa68cb32 Mon Sep 17 00:00:00 2001 From: JSR Date: Wed, 18 Mar 2026 19:07:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B9=9D=E5=AE=AB=E6=A0=BC?= =?UTF-8?q?=E9=A6=96=E5=AD=97=E6=AF=8DT9=E5=8C=B9=E9=85=8D=E9=81=97?= =?UTF-8?q?=E6=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Home.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/Home.tsx b/src/components/Home.tsx index 03f3c6e..bb6951c 100644 --- a/src/components/Home.tsx +++ b/src/components/Home.tsx @@ -13,6 +13,7 @@ interface student { avatarUrl?: string | null pinyinName?: string pinyinFirst?: string + pinyinInitials?: string } interface reason { @@ -103,6 +104,7 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => { ...s, avatarUrl: getAvatarFromExtraJson(s.extra_json), pinyinName: pinyin(s.name, { toneType: "none" }).toLowerCase(), + pinyinInitials: pinyin(s.name, { pattern: "first", toneType: "none" }).toLowerCase(), pinyinFirst: getFirstLetter(s.name), })) setStudents(enrichedStudents) @@ -181,17 +183,23 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => { const pyLower = s.pinyinName || "" if (pyLower.includes(q0)) return true + const pyInitialsLower = s.pinyinInitials || "" + if (pyInitialsLower.includes(q0)) return true const q1 = q0.replace(/\s+/g, "") const isT9Query = /^[2-9]+$/.test(q1) if (isT9Query) { const pyDigits = toT9Digits(pyLower.replace(/[^a-z]/g, "")) + const pyInitialsDigits = toT9Digits(pyInitialsLower.replace(/[^a-z]/g, "")) if (pyDigits.includes(q1)) return true + if (pyInitialsDigits.includes(q1)) return true } if ( q1 && - (nameLower.replace(/\s+/g, "").includes(q1) || pyLower.replace(/\s+/g, "").includes(q1)) + (nameLower.replace(/\s+/g, "").includes(q1) || + pyLower.replace(/\s+/g, "").includes(q1) || + pyInitialsLower.replace(/\s+/g, "").includes(q1)) ) return true