MCPcopy Create free account
hub / github.com/experdot/pointer / Search

Function Search

src/renderer/src/components/panels/Search/index.tsx:11–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9import './index.css'
10
11export function Search(): React.JSX.Element {
12 const { query, results, totalCount, isSearching, setSelectedIndex, expandAll, collapseAll } =
13 useGlobalSearchStore()
14 const { navigateToResult } = useGlobalSearch()
15
16 const handleItemClick = useCallback(
17 (match: GlobalSearchMatch, pageIndex: number, messageIndex: number, matchIndex: number) => {
18 setSelectedIndex([pageIndex, messageIndex, matchIndex])
19 navigateToResult(match)
20 },
21 [setSelectedIndex, navigateToResult]
22 )
23
24 return (
25 <div className="search-panel">
26 <div className="search-panel-header">
27 <SearchInput />
28 <SearchOptions />
29 </div>
30
31 <div className="search-panel-body">
32 {isSearching && (
33 <div className="search-loading">
34 <Spin size="small" />
35 <span>搜索中...</span>
36 </div>
37 )}
38
39 {!isSearching && totalCount > 0 && (
40 <div className="search-summary">
41 <span>
42 共 {totalCount} 个结果,来自 {results.length} 个会话
43 </span>
44 <div className="search-summary-actions">
45 <Button type="text" size="small" onClick={expandAll}>
46 展开
47 </Button>
48 <Button type="text" size="small" onClick={collapseAll}>
49 折叠
50 </Button>
51 </div>
52 </div>
53 )}
54
55 {!isSearching && totalCount > 0 && (
56 <SearchResults results={results} onItemClick={handleItemClick} />
57 )}
58
59 {!isSearching && query && totalCount === 0 && (
60 <Empty description="未找到匹配结果" image={Empty.PRESENTED_IMAGE_SIMPLE} />
61 )}
62
63 {!isSearching && !query && (
64 <div className="search-placeholder">
65 <p>输入关键词搜索所有会话</p>
66 </div>
67 )}
68 </div>

Callers

nothing calls this directly

Calls 1

useGlobalSearchFunction · 0.90

Tested by

no test coverage detected