diff --git a/app/components/search-chat.tsx b/app/components/search-chat.tsx index 4d8cdbbf762..1467ceba7e5 100644 --- a/app/components/search-chat.tsx +++ b/app/components/search-chat.tsx @@ -25,21 +25,6 @@ export function SearchChatPage() { const [searchResults, setSearchResults] = useState([]); - // const setDefaultItems = () => { - // setSearchResults( - // sessions.slice(1, 7).map((session, index) => { - // return { - // id: index, - // name: session.topic, - // content: session.messages[0].content as string, //.map((m) => m.content).join("\n") - // }; - // }), - // ); - // }; - // useEffect(() => { - // setDefaultItems(); - // }, []); - const previousValueRef = useRef(""); const searchInputRef = useRef(null); const doSearch = (text: string) => { @@ -53,7 +38,7 @@ export function SearchChatPage() { const content = message.content as string; const lowerCaseContent = content.toLowerCase(); - // 全文搜索 + // full text search let pos = lowerCaseContent.indexOf(lowerCaseText); while (pos !== -1) { const start = Math.max(0, pos - 35); @@ -70,12 +55,12 @@ export function SearchChatPage() { results.push({ id: index, name: session.topic, - content: fullTextContents.join("... "), // 使用...连接不同消息中的内容 + content: fullTextContents.join("... "), // concat content with... }); } }); - // 按内容长度排序 + // sort by length of matching content results.sort((a, b) => b.content.length - a.content.length); return results; @@ -148,7 +133,15 @@ export function SearchChatPage() {
{searchResults.map((item) => ( -
+
{ + navigate(Path.Chat); + selectSession(item.id); + }} + style={{ cursor: "pointer" }} + > {/** 搜索匹配的文本 */}
@@ -161,10 +154,6 @@ export function SearchChatPage() { } text={Locale.SearchChat.Item.View} - onClick={() => { - navigate(Path.Chat); - selectSession(item.id); - }} />