This commit is contained in:
selfrelease
2025-12-22 16:49:58 +08:00
parent e9822f5c92
commit 639344dc45
46 changed files with 2015 additions and 5170 deletions
+7 -6
View File
@@ -5,6 +5,7 @@ import { createContext, useContext, useState, useCallback, useEffect, useRef, Su
import type { FamilyMember, FamilyTreeData } from "@/types/family"
import { useSession } from "next-auth/react"
import { useSearchParams } from "next/navigation"
import { matchesPinyin } from "@/lib/pinyin-utils"
interface FamilyTreeInfo {
id: string
@@ -428,14 +429,14 @@ function FamilyProviderInner({ children }: { children: React.ReactNode }) {
return
}
const lowerQuery = query.toLowerCase()
// 在内存中的 treeData 上执行搜索,简单快速
// 在内存中的 treeData 上执行搜索
// 支持中文直接匹配和拼音匹配(全拼、首字母)
const results = Object.values(treeData.members).filter(
(member) =>
member.fullName.includes(lowerQuery) ||
member.givenName.includes(lowerQuery) ||
member.courtesyName?.includes(lowerQuery) ||
member.artName?.includes(lowerQuery),
matchesPinyin(query, member.fullName) ||
matchesPinyin(query, member.givenName) ||
(member.courtesyName && matchesPinyin(query, member.courtesyName)) ||
(member.artName && matchesPinyin(query, member.artName)),
)
setSearchResults(results)
},