@tencentcloud/sdk-mcp 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/resource/doc/chatuikit/android/features/theme.md +363 -0
- package/resource/doc/chatuikit/android/workflow.md +0 -0
- package/resource/doc/chatuikit/{android/client_api_android.md → faq/android_sdk/client-api.md} +0 -1
- package/resource/doc/chatuikit/faq/{native_sdk/faq.md → common/product.md} +8 -0
- package/resource/doc/chatuikit/faq/flutter_sdk/faq.md +54 -0
- package/resource/doc/chatuikit/faq/web_sdk/faq.md +1 -1
- package/resource/doc/chatuikit/flutter/features/theme.md +379 -0
- package/resource/doc/chatuikit/flutter/workflow.md +816 -0
- package/resource/doc/chatuikit/iOS/features/theme.md +416 -0
- package/resource/doc/chatuikit/iOS/workflow.md +0 -0
- package/resource/doc/chatuikit/react/components/chat-setting.md +124 -0
- package/resource/doc/chatuikit/react/components/contact-list.md +1331 -0
- package/resource/doc/chatuikit/react/components/search.md +885 -0
- package/resource/doc/chatuikit/vue/components/chat-setting.md +88 -0
- package/resource/doc/chatuikit/vue/components/contact-list.md +679 -0
- package/resource/doc/chatuikit/vue/components/search.md +1384 -0
- package/resource/doc/livekit/live/android/workflow.md +137 -4
- package/resource/doc/livekit/live/flutter/live-audience-list.md +337 -0
- package/resource/doc/livekit/live/flutter/live-audio-effect.md +739 -0
- package/resource/doc/livekit/live/flutter/live-barrage.md +578 -0
- package/resource/doc/livekit/live/flutter/live-base-beauty.md +484 -0
- package/resource/doc/livekit/live/flutter/live-co-guest-interaction.md +606 -0
- package/resource/doc/livekit/live/flutter/live-gift.md +812 -0
- package/resource/doc/livekit/live/flutter/live-host-interaction.md +1113 -0
- package/resource/doc/livekit/live/flutter/live-integration.md +1029 -0
- package/resource/doc/livekit/live/flutter/live-live-list.md +861 -0
- package/resource/doc/livekit/live/ios/live-audience-list.md +335 -0
- package/resource/doc/livekit/live/ios/live-audio-effect.md +373 -0
- package/resource/doc/livekit/live/ios/live-barrage.md +529 -0
- package/resource/doc/livekit/live/ios/live-base-beauty.md +237 -0
- package/resource/doc/livekit/live/ios/live-co-guest-interaction.md +483 -0
- package/resource/doc/livekit/live/ios/live-gift.md +785 -0
- package/resource/doc/livekit/live/ios/live-host-interaction.md +743 -0
- package/resource/doc/livekit/live/ios/live-integration.md +822 -0
- package/resource/doc/livekit/live/ios/live-live-list.md +535 -0
- package/resource/doc/livekit/live/ios/workflow.md +352 -0
- package/resource/doc/rtcengine/faq/web/web.md +2 -2
- package/resource/doc/rtcengine/web/how_to_integrated_web_sdk.md +2 -2
- package/resource/doc/rtcengine/web/plugin/20-advanced-customized-capture-rendering.md +84 -0
- package/resource/doc/rtcengine/web/plugin/21-advanced-auto-play-policy.md +86 -0
- package/resource/doc/rtcengine/web/plugin/22-advanced-audio-mixer.md +220 -0
- package/resource/doc/rtcengine/web/plugin/23-advanced-support-detection.md +217 -0
- package/resource/doc/rtcengine/web/plugin/24-advanced-network-quality.md +137 -0
- package/resource/doc/rtcengine/web/plugin/25-advanced-device-change.md +97 -0
- package/resource/doc/rtcengine/web/plugin/26-advanced-publish-cdn-stream.md +453 -0
- package/resource/doc/rtcengine/web/plugin/27-advanced-small-stream.md +180 -0
- package/resource/doc/rtcengine/web/plugin/28-advanced-beauty.md +349 -0
- package/resource/doc/rtcengine/web/plugin/29-advanced-water-mark.md +149 -0
- package/resource/doc/rtcengine/web/plugin/30-advanced-cross-room-link.md +96 -0
- package/resource/doc/rtcengine/web/plugin/31-advanced-plugins-overview.md +405 -0
- package/resource/doc/rtcengine/web/plugin/34-advanced-proxy.md +244 -0
- package/resource/doc/rtcengine/web/plugin/35-advanced-ai-denoiser.md +84 -0
- package/resource/doc/rtcengine/web/plugin/36-advanced-virtual-background.md +202 -0
- package/resource/doc/rtcengine/web/plugin/37-advanced-voice-changer.md +98 -0
- package/resource/doc/rtcengine/web/plugin/38-advanced-basic-beauty.md +95 -0
- package/resource/doc/rtcengine/web/plugin/39-advanced-video-decoder.md +33 -0
- package/resource/doc/rtcengine/web/plugin/40-advanced-video-mixer.md +380 -0
- package/resource/doc/rtcengine/web/plugin/41-advanced-small-stream-auto-switcher.md +91 -0
- package/resource/doc/rtcengine/web/plugin/42-advanced-realtime-transcriber.md +314 -0
- package/resource/doc/rtcengine/web/plugin/43-advanced-face-detection.md +180 -0
- package/tools/chat/get-native-chat-feature-detail.js +30 -0
- package/tools/chat/get-native-chat-feature-detail.js.map +1 -0
- package/tools/chat/get-native-chat-integration.js +30 -12
- package/tools/chat/get-native-chat-integration.js.map +1 -1
- package/tools/common/get-faq.js +2 -4
- package/tools/common/get-faq.js.map +1 -1
- package/tools/definitions/get_native_chat_feature_detail_def.js +32 -0
- package/tools/definitions/get_native_chat_feature_detail_def.js.map +1 -0
- package/tools/definitions/get_native_chat_uikit_integration_def.js +18 -6
- package/tools/definitions/get_native_chat_uikit_integration_def.js.map +1 -1
- package/tools/definitions/{get_native_live_extra_features_def.js → get_native_live_uikit_extra_features_def.js} +3 -3
- package/tools/definitions/get_native_live_uikit_extra_features_def.js.map +1 -0
- package/tools/definitions/{get_native_live_interaction_def.js → get_native_live_uikit_interaction_def.js} +3 -3
- package/tools/definitions/get_native_live_uikit_interaction_def.js.map +1 -0
- package/tools/definitions/get_web_chat_uikit_component_detail_def.js +46 -7
- package/tools/definitions/get_web_chat_uikit_component_detail_def.js.map +1 -1
- package/tools/index.js +6 -4
- package/tools/index.js.map +1 -1
- package/tools/live/{get_native_live_extra_features.js → get_native_live_uikit_extra_features.js} +4 -4
- package/tools/live/get_native_live_uikit_extra_features.js.map +1 -0
- package/tools/live/{get_native_live_interaction.js → get_native_live_uikit_interaction.js} +4 -4
- package/tools/live/get_native_live_uikit_interaction.js.map +1 -0
- package/tools/rtcengine/get-trtc-web-sdk-faq.js +1 -1
- package/tools/rtcengine/get-trtc-web-sdk-plugin.js +45 -0
- package/tools/rtcengine/get-trtc-web-sdk-plugin.js.map +1 -0
- package/utils/handle-component-name.js +0 -16
- package/utils/handle-component-name.js.map +1 -1
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
- package/resource/doc/chatuikit/android/integrate_tuichat_only_android.md +0 -382
- package/resource/doc/chatuikit/android/ui_api_android.md +0 -418
- package/resource/doc/chatuikit/iOS/integrate_tuichat_only_iOS.md +0 -993
- package/resource/doc/chatuikit/iOS/ui_api_iOS.md +0 -526
- package/tools/definitions/get_native_live_extra_features_def.js.map +0 -1
- package/tools/definitions/get_native_live_interaction_def.js.map +0 -1
- package/tools/live/get_native_live_extra_features.js.map +0 -1
- package/tools/live/get_native_live_interaction.js.map +0 -1
- /package/resource/doc/chatuikit/android/{integrate_tuikit_android.md → integration.md} +0 -0
- /package/resource/doc/chatuikit/{flutter/client_api_Flutter.md → faq/flutter_sdk/client-api.md} +0 -0
- /package/resource/doc/chatuikit/{iOS/client_api_iOS.md → faq/ios_sdk/client-api.md} +0 -0
- /package/resource/doc/chatuikit/flutter/{integrate_tuikit_Flutter.md → integration.md} +0 -0
- /package/resource/doc/chatuikit/iOS/{integrate_tuikit_iOS.md → integration.md} +0 -0
- /package/resource/doc/chatuikit/react/components/{chatheader.md → chat-header.md} +0 -0
- /package/resource/doc/chatuikit/vue/components/{chatheader.md → chat-header.md} +0 -0
|
@@ -0,0 +1,885 @@
|
|
|
1
|
+
## 组件概述
|
|
2
|
+
|
|
3
|
+
Search 是一个功能完整的搜索解决方案,包含了搜索框、搜索结果展示、高级搜索等功能的完整组件集合。适用于即时通讯、在线会议、在线教育等场景的用户、群组、消息搜索。
|
|
4
|
+
|
|
5
|
+
> **说明:**
|
|
6
|
+
>
|
|
7
|
+
|
|
8
|
+
> 此功能属于增值服务,需要您购买云端搜索插件,请点击 [购买](https://console.cloud.tencent.com/im/plugin/TUICloudSearch)。
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 组件架构
|
|
16
|
+
``` bash
|
|
17
|
+
Search (主组件)
|
|
18
|
+
├── SearchBar # 搜索框组件
|
|
19
|
+
├── SearchResults # 搜索结果组件
|
|
20
|
+
├── SearchAdvanced # 高级搜索组件
|
|
21
|
+
└── SearchResultsItem # 搜索结果项组件
|
|
22
|
+
├── User # 用户结果项
|
|
23
|
+
├── Group # 群组结果项
|
|
24
|
+
├── Message # 消息结果项
|
|
25
|
+
└── Conversation # 会话结果项
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 搜索模式
|
|
29
|
+
<table>
|
|
30
|
+
<tr>
|
|
31
|
+
<td rowspan="1" colSpan="1" >**迷你模式**</td>
|
|
32
|
+
|
|
33
|
+
<td rowspan="1" colSpan="1" >**标准模式**</td>
|
|
34
|
+
|
|
35
|
+
<td rowspan="1" colSpan="1" >**嵌入式模式**</td>
|
|
36
|
+
</tr>
|
|
37
|
+
|
|
38
|
+
<tr>
|
|
39
|
+
<td rowspan="1" colSpan="1" >- 适用于侧边栏或小容器<br>- 显示有限结果数量<br>- 支持展开查看更多</td>
|
|
40
|
+
|
|
41
|
+
<td rowspan="1" colSpan="1" >- 适用于全屏搜索界面<br>- 完整功能展示<br>- 支持高级搜索</td>
|
|
42
|
+
|
|
43
|
+
<td rowspan="1" colSpan="1" >- 适用于聊天界面<br>- 专注消息搜索<br>- 优化的布局</td>
|
|
44
|
+
</tr>
|
|
45
|
+
|
|
46
|
+
<tr>
|
|
47
|
+
<td rowspan="1" colSpan="1" ><br></td>
|
|
48
|
+
|
|
49
|
+
<td rowspan="1" colSpan="1" ><br></td>
|
|
50
|
+
|
|
51
|
+
<td rowspan="1" colSpan="1" ><br></td>
|
|
52
|
+
</tr>
|
|
53
|
+
</table>
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Props
|
|
57
|
+
<table>
|
|
58
|
+
<tr>
|
|
59
|
+
<td rowspan="1" colSpan="1" >属性名</td>
|
|
60
|
+
|
|
61
|
+
<td rowspan="1" colSpan="1" >类型</td>
|
|
62
|
+
|
|
63
|
+
<td rowspan="1" colSpan="1" >默认值</td>
|
|
64
|
+
|
|
65
|
+
<td rowspan="1" colSpan="1" >说明</td>
|
|
66
|
+
</tr>
|
|
67
|
+
|
|
68
|
+
<tr>
|
|
69
|
+
<td rowspan="1" colSpan="1" >variant</td>
|
|
70
|
+
|
|
71
|
+
<td rowspan="1" colSpan="1" >`VariantType`</td>
|
|
72
|
+
|
|
73
|
+
<td rowspan="1" colSpan="1" >`VariantType.MINI`</td>
|
|
74
|
+
|
|
75
|
+
<td rowspan="1" colSpan="1" >搜索模式:`mini`(迷你)、`standard`(标准)、`embedded`(嵌入式)</td>
|
|
76
|
+
</tr>
|
|
77
|
+
|
|
78
|
+
<tr>
|
|
79
|
+
<td rowspan="1" colSpan="1" >SearchBar</td>
|
|
80
|
+
|
|
81
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType<SearchBarProps>`</td>
|
|
82
|
+
|
|
83
|
+
<td rowspan="1" colSpan="1" >`DefaultSearchBar`</td>
|
|
84
|
+
|
|
85
|
+
<td rowspan="1" colSpan="1" >自定义搜索框组件</td>
|
|
86
|
+
</tr>
|
|
87
|
+
|
|
88
|
+
<tr>
|
|
89
|
+
<td rowspan="1" colSpan="1" >SearchResults</td>
|
|
90
|
+
|
|
91
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType<SearchResultsProps>`</td>
|
|
92
|
+
|
|
93
|
+
<td rowspan="1" colSpan="1" >`DefaultSearchResults`</td>
|
|
94
|
+
|
|
95
|
+
<td rowspan="1" colSpan="1" >自定义搜索结果组件</td>
|
|
96
|
+
</tr>
|
|
97
|
+
|
|
98
|
+
<tr>
|
|
99
|
+
<td rowspan="1" colSpan="1" >SearchAdvanced</td>
|
|
100
|
+
|
|
101
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType<SearchAdvancedProps>`</td>
|
|
102
|
+
|
|
103
|
+
<td rowspan="1" colSpan="1" >`DefaultSearchAdvanced`</td>
|
|
104
|
+
|
|
105
|
+
<td rowspan="1" colSpan="1" >自定义高级搜索组件</td>
|
|
106
|
+
</tr>
|
|
107
|
+
|
|
108
|
+
<tr>
|
|
109
|
+
<td rowspan="1" colSpan="1" >SearchResultsPresearch</td>
|
|
110
|
+
|
|
111
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType`</td>
|
|
112
|
+
|
|
113
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
114
|
+
|
|
115
|
+
<td rowspan="1" colSpan="1" >搜索前占位符组件</td>
|
|
116
|
+
</tr>
|
|
117
|
+
|
|
118
|
+
<tr>
|
|
119
|
+
<td rowspan="1" colSpan="1" >SearchResultsLoading</td>
|
|
120
|
+
|
|
121
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType`</td>
|
|
122
|
+
|
|
123
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
124
|
+
|
|
125
|
+
<td rowspan="1" colSpan="1" >加载中占位符组件</td>
|
|
126
|
+
</tr>
|
|
127
|
+
|
|
128
|
+
<tr>
|
|
129
|
+
<td rowspan="1" colSpan="1" >SearchResultsEmpty</td>
|
|
130
|
+
|
|
131
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType`</td>
|
|
132
|
+
|
|
133
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
134
|
+
|
|
135
|
+
<td rowspan="1" colSpan="1" >空结果占位符组件</td>
|
|
136
|
+
</tr>
|
|
137
|
+
|
|
138
|
+
<tr>
|
|
139
|
+
<td rowspan="1" colSpan="1" >SearchResultItem</td>
|
|
140
|
+
|
|
141
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType<ResultItemProps>`</td>
|
|
142
|
+
|
|
143
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
144
|
+
|
|
145
|
+
<td rowspan="1" colSpan="1" >自定义搜索结果项组件</td>
|
|
146
|
+
</tr>
|
|
147
|
+
|
|
148
|
+
<tr>
|
|
149
|
+
<td rowspan="1" colSpan="1" >debounceTime</td>
|
|
150
|
+
|
|
151
|
+
<td rowspan="1" colSpan="1" >`number`</td>
|
|
152
|
+
|
|
153
|
+
<td rowspan="1" colSpan="1" >`300`</td>
|
|
154
|
+
|
|
155
|
+
<td rowspan="1" colSpan="1" >搜索防抖时间(毫秒)</td>
|
|
156
|
+
</tr>
|
|
157
|
+
|
|
158
|
+
<tr>
|
|
159
|
+
<td rowspan="1" colSpan="1" >autoFocus</td>
|
|
160
|
+
|
|
161
|
+
<td rowspan="1" colSpan="1" >`boolean`</td>
|
|
162
|
+
|
|
163
|
+
<td rowspan="1" colSpan="1" >`false`</td>
|
|
164
|
+
|
|
165
|
+
<td rowspan="1" colSpan="1" >是否自动聚焦搜索框</td>
|
|
166
|
+
</tr>
|
|
167
|
+
|
|
168
|
+
<tr>
|
|
169
|
+
<td rowspan="1" colSpan="1" >className</td>
|
|
170
|
+
|
|
171
|
+
<td rowspan="1" colSpan="1" >`string`</td>
|
|
172
|
+
|
|
173
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
174
|
+
|
|
175
|
+
<td rowspan="1" colSpan="1" >自定义样式类名</td>
|
|
176
|
+
</tr>
|
|
177
|
+
|
|
178
|
+
<tr>
|
|
179
|
+
<td rowspan="1" colSpan="1" >style</td>
|
|
180
|
+
|
|
181
|
+
<td rowspan="1" colSpan="1" >`React.CSSProperties`</td>
|
|
182
|
+
|
|
183
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
184
|
+
|
|
185
|
+
<td rowspan="1" colSpan="1" >自定义样式</td>
|
|
186
|
+
</tr>
|
|
187
|
+
|
|
188
|
+
<tr>
|
|
189
|
+
<td rowspan="1" colSpan="1" >onKeywordChange</td>
|
|
190
|
+
|
|
191
|
+
<td rowspan="1" colSpan="1" >`(keyword: string) => void`</td>
|
|
192
|
+
|
|
193
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
194
|
+
|
|
195
|
+
<td rowspan="1" colSpan="1" >搜索关键词变化回调</td>
|
|
196
|
+
</tr>
|
|
197
|
+
|
|
198
|
+
<tr>
|
|
199
|
+
<td rowspan="1" colSpan="1" >onSearchComplete</td>
|
|
200
|
+
|
|
201
|
+
<td rowspan="1" colSpan="1" >`(results: Map<SearchType, SearchResult>) => void`</td>
|
|
202
|
+
|
|
203
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
204
|
+
|
|
205
|
+
<td rowspan="1" colSpan="1" >搜索完成回调</td>
|
|
206
|
+
</tr>
|
|
207
|
+
|
|
208
|
+
<tr>
|
|
209
|
+
<td rowspan="1" colSpan="1" >onResultItemClick</td>
|
|
210
|
+
|
|
211
|
+
<td rowspan="1" colSpan="1" >`(data: SearchResultItem, type: SearchType) => void`</td>
|
|
212
|
+
|
|
213
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
214
|
+
|
|
215
|
+
<td rowspan="1" colSpan="1" >搜索结果点击回调</td>
|
|
216
|
+
</tr>
|
|
217
|
+
|
|
218
|
+
<tr>
|
|
219
|
+
<td rowspan="1" colSpan="1" >onError</td>
|
|
220
|
+
|
|
221
|
+
<td rowspan="1" colSpan="1" >`(error: Error) => void`</td>
|
|
222
|
+
|
|
223
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
224
|
+
|
|
225
|
+
<td rowspan="1" colSpan="1" >搜索错误回调</td>
|
|
226
|
+
</tr>
|
|
227
|
+
</table>
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
## 基础使用
|
|
231
|
+
``` typescript
|
|
232
|
+
import { Search, VariantType } from '@tencentcloud/chat-uikit-react';
|
|
233
|
+
|
|
234
|
+
function App() {
|
|
235
|
+
return (
|
|
236
|
+
<Search
|
|
237
|
+
variant={VariantType.STANDARD}
|
|
238
|
+
onResultItemClick={(data, type) => {
|
|
239
|
+
console.log('搜索结果点击:', data, type);
|
|
240
|
+
}}
|
|
241
|
+
/>
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## 自定义能力
|
|
247
|
+
|
|
248
|
+
`Search` 为用户自定义提供了丰富且多维度的 Props 接口,允许用户自定义功能、UI、模块等。
|
|
249
|
+
|
|
250
|
+
`Search` 组件提供了多个可替换的子组件,允许用户自定义 `SearchBar`, `SearchResults`, `SearchAdvanced`, `SearchResultItem`, `SearchResultsPresearch`, `SearchResultsLoading`, `SearchResultsEmpty`, 等。同时,用户还可以利用默认子组件进行二次开发定制。
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
【自定义 SearchBar】
|
|
255
|
+
|
|
256
|
+
**Props**
|
|
257
|
+
<table>
|
|
258
|
+
<tr>
|
|
259
|
+
<td rowspan="1" colSpan="1" >属性名</td>
|
|
260
|
+
|
|
261
|
+
<td rowspan="1" colSpan="1" >类型</td>
|
|
262
|
+
|
|
263
|
+
<td rowspan="1" colSpan="1" >默认值</td>
|
|
264
|
+
|
|
265
|
+
<td rowspan="1" colSpan="1" >说明</td>
|
|
266
|
+
</tr>
|
|
267
|
+
|
|
268
|
+
<tr>
|
|
269
|
+
<td rowspan="1" colSpan="1" >data</td>
|
|
270
|
+
|
|
271
|
+
<td rowspan="1" colSpan="1" >`SearchResultItem`</td>
|
|
272
|
+
|
|
273
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
274
|
+
|
|
275
|
+
<td rowspan="1" colSpan="1" >搜索结果数据</td>
|
|
276
|
+
</tr>
|
|
277
|
+
|
|
278
|
+
<tr>
|
|
279
|
+
<td rowspan="1" colSpan="1" >type</td>
|
|
280
|
+
|
|
281
|
+
<td rowspan="1" colSpan="1" >`SearchType`</td>
|
|
282
|
+
|
|
283
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
284
|
+
|
|
285
|
+
<td rowspan="1" colSpan="1" >搜索结果类型</td>
|
|
286
|
+
</tr>
|
|
287
|
+
|
|
288
|
+
<tr>
|
|
289
|
+
<td rowspan="1" colSpan="1" >keyword</td>
|
|
290
|
+
|
|
291
|
+
<td rowspan="1" colSpan="1" >`string`</td>
|
|
292
|
+
|
|
293
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
294
|
+
|
|
295
|
+
<td rowspan="1" colSpan="1" >搜索关键词</td>
|
|
296
|
+
</tr>
|
|
297
|
+
|
|
298
|
+
<tr>
|
|
299
|
+
<td rowspan="1" colSpan="1" >onClick</td>
|
|
300
|
+
|
|
301
|
+
<td rowspan="1" colSpan="1" >`(data: SearchResultItem, type: SearchType) => void`</td>
|
|
302
|
+
|
|
303
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
304
|
+
|
|
305
|
+
<td rowspan="1" colSpan="1" >点击回调</td>
|
|
306
|
+
</tr>
|
|
307
|
+
|
|
308
|
+
<tr>
|
|
309
|
+
<td rowspan="1" colSpan="1" >className</td>
|
|
310
|
+
|
|
311
|
+
<td rowspan="1" colSpan="1" >`string`</td>
|
|
312
|
+
|
|
313
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
314
|
+
|
|
315
|
+
<td rowspan="1" colSpan="1" >自定义样式类名</td>
|
|
316
|
+
</tr>
|
|
317
|
+
</table>
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
**示例**
|
|
321
|
+
``` typescript
|
|
322
|
+
const CustomSearchBar = ({ value, onChange, onClear, placeholder }) => (
|
|
323
|
+
<div className="custom-search-bar">
|
|
324
|
+
<input
|
|
325
|
+
type="text"
|
|
326
|
+
value={value}
|
|
327
|
+
onChange={onChange}
|
|
328
|
+
placeholder={placeholder}
|
|
329
|
+
/>
|
|
330
|
+
{value && <button onClick={onClear}>清除</button>}
|
|
331
|
+
</div>
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
<Search SearchBar={CustomSearchBar} />
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
【自定义 SearchResults】
|
|
338
|
+
|
|
339
|
+
**Props**
|
|
340
|
+
<table>
|
|
341
|
+
<tr>
|
|
342
|
+
<td rowspan="1" colSpan="1" >属性名</td>
|
|
343
|
+
|
|
344
|
+
<td rowspan="1" colSpan="1" >类型</td>
|
|
345
|
+
|
|
346
|
+
<td rowspan="1" colSpan="1" >默认值</td>
|
|
347
|
+
|
|
348
|
+
<td rowspan="1" colSpan="1" >说明</td>
|
|
349
|
+
</tr>
|
|
350
|
+
|
|
351
|
+
<tr>
|
|
352
|
+
<td rowspan="1" colSpan="1" >results</td>
|
|
353
|
+
|
|
354
|
+
<td rowspan="1" colSpan="1" >`Map<SearchType, SearchResult>`</td>
|
|
355
|
+
|
|
356
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
357
|
+
|
|
358
|
+
<td rowspan="1" colSpan="1" >搜索结果数据</td>
|
|
359
|
+
</tr>
|
|
360
|
+
|
|
361
|
+
<tr>
|
|
362
|
+
<td rowspan="1" colSpan="1" >isLoading</td>
|
|
363
|
+
|
|
364
|
+
<td rowspan="1" colSpan="1" >`boolean`</td>
|
|
365
|
+
|
|
366
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
367
|
+
|
|
368
|
+
<td rowspan="1" colSpan="1" >是否正在加载</td>
|
|
369
|
+
</tr>
|
|
370
|
+
|
|
371
|
+
<tr>
|
|
372
|
+
<td rowspan="1" colSpan="1" >error</td>
|
|
373
|
+
|
|
374
|
+
<td rowspan="1" colSpan="1" >`Error \| null`</td>
|
|
375
|
+
|
|
376
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
377
|
+
|
|
378
|
+
<td rowspan="1" colSpan="1" >错误信息</td>
|
|
379
|
+
</tr>
|
|
380
|
+
|
|
381
|
+
<tr>
|
|
382
|
+
<td rowspan="1" colSpan="1" >keyword</td>
|
|
383
|
+
|
|
384
|
+
<td rowspan="1" colSpan="1" >`string`</td>
|
|
385
|
+
|
|
386
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
387
|
+
|
|
388
|
+
<td rowspan="1" colSpan="1" >搜索关键词</td>
|
|
389
|
+
</tr>
|
|
390
|
+
|
|
391
|
+
<tr>
|
|
392
|
+
<td rowspan="1" colSpan="1" >typeLabels</td>
|
|
393
|
+
|
|
394
|
+
<td rowspan="1" colSpan="1" >`Record<SearchType, string>`</td>
|
|
395
|
+
|
|
396
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
397
|
+
|
|
398
|
+
<td rowspan="1" colSpan="1" >搜索类型标签</td>
|
|
399
|
+
</tr>
|
|
400
|
+
|
|
401
|
+
<tr>
|
|
402
|
+
<td rowspan="1" colSpan="1" >onLoadMore</td>
|
|
403
|
+
|
|
404
|
+
<td rowspan="1" colSpan="1" >`(type: SearchType) => void`</td>
|
|
405
|
+
|
|
406
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
407
|
+
|
|
408
|
+
<td rowspan="1" colSpan="1" >加载更多回调</td>
|
|
409
|
+
</tr>
|
|
410
|
+
|
|
411
|
+
<tr>
|
|
412
|
+
<td rowspan="1" colSpan="1" >onResultItemClick</td>
|
|
413
|
+
|
|
414
|
+
<td rowspan="1" colSpan="1" >`(data: SearchResultItem, type: SearchType) => void`</td>
|
|
415
|
+
|
|
416
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
417
|
+
|
|
418
|
+
<td rowspan="1" colSpan="1" >结果项点击回调</td>
|
|
419
|
+
</tr>
|
|
420
|
+
|
|
421
|
+
<tr>
|
|
422
|
+
<td rowspan="1" colSpan="1" >SearchResultsLoading</td>
|
|
423
|
+
|
|
424
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType`</td>
|
|
425
|
+
|
|
426
|
+
<td rowspan="1" colSpan="1" >`Loading`</td>
|
|
427
|
+
|
|
428
|
+
<td rowspan="1" colSpan="1" >自定义加载组件</td>
|
|
429
|
+
</tr>
|
|
430
|
+
|
|
431
|
+
<tr>
|
|
432
|
+
<td rowspan="1" colSpan="1" >SearchResultsPresearch</td>
|
|
433
|
+
|
|
434
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType`</td>
|
|
435
|
+
|
|
436
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
437
|
+
|
|
438
|
+
<td rowspan="1" colSpan="1" >搜索前占位符组件</td>
|
|
439
|
+
</tr>
|
|
440
|
+
|
|
441
|
+
<tr>
|
|
442
|
+
<td rowspan="1" colSpan="1" >SearchResultsEmpty</td>
|
|
443
|
+
|
|
444
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType`</td>
|
|
445
|
+
|
|
446
|
+
<td rowspan="1" colSpan="1" >`EmptyResult`</td>
|
|
447
|
+
|
|
448
|
+
<td rowspan="1" colSpan="1" >空结果占位符组件</td>
|
|
449
|
+
</tr>
|
|
450
|
+
|
|
451
|
+
<tr>
|
|
452
|
+
<td rowspan="1" colSpan="1" >SearchResultItem</td>
|
|
453
|
+
|
|
454
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType<ResultItemProps>`</td>
|
|
455
|
+
|
|
456
|
+
<td rowspan="1" colSpan="1" >`DefaultSearchResultsItem`</td>
|
|
457
|
+
|
|
458
|
+
<td rowspan="1" colSpan="1" >自定义结果项组件</td>
|
|
459
|
+
</tr>
|
|
460
|
+
|
|
461
|
+
<tr>
|
|
462
|
+
<td rowspan="1" colSpan="1" >variant</td>
|
|
463
|
+
|
|
464
|
+
<td rowspan="1" colSpan="1" >`VariantType`</td>
|
|
465
|
+
|
|
466
|
+
<td rowspan="1" colSpan="1" >`VariantType.STANDARD`</td>
|
|
467
|
+
|
|
468
|
+
<td rowspan="1" colSpan="1" >显示模式</td>
|
|
469
|
+
</tr>
|
|
470
|
+
|
|
471
|
+
<tr>
|
|
472
|
+
<td rowspan="1" colSpan="1" >searchType</td>
|
|
473
|
+
|
|
474
|
+
<td rowspan="1" colSpan="1" >`SearchType \| 'all'`</td>
|
|
475
|
+
|
|
476
|
+
<td rowspan="1" colSpan="1" >`'all'`</td>
|
|
477
|
+
|
|
478
|
+
<td rowspan="1" colSpan="1" >当前搜索类型</td>
|
|
479
|
+
</tr>
|
|
480
|
+
</table>
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
**示例**
|
|
484
|
+
``` typescript
|
|
485
|
+
const CustomSearchResults = ({ results, keyword, onResultItemClick }) => (
|
|
486
|
+
<div className="custom-results">
|
|
487
|
+
{Array.from(results.entries()).map(([type, result]) => (
|
|
488
|
+
<div key={type}>
|
|
489
|
+
<h3>{type}</h3>
|
|
490
|
+
{result.resultList.map((item, index) => (
|
|
491
|
+
<div key={index} onClick={() => onResultItemClick(item, type)}>
|
|
492
|
+
{/* 自定义结果项 */}
|
|
493
|
+
</div>
|
|
494
|
+
))}
|
|
495
|
+
</div>
|
|
496
|
+
))}
|
|
497
|
+
</div>
|
|
498
|
+
);
|
|
499
|
+
|
|
500
|
+
<Search SearchResults={CustomSearchResults} />
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
【自定义 SearchAdvanced】
|
|
504
|
+
|
|
505
|
+
**Props**
|
|
506
|
+
<table>
|
|
507
|
+
<tr>
|
|
508
|
+
<td rowspan="1" colSpan="1" >属性名</td>
|
|
509
|
+
|
|
510
|
+
<td rowspan="1" colSpan="1" >类型</td>
|
|
511
|
+
|
|
512
|
+
<td rowspan="1" colSpan="1" >默认值</td>
|
|
513
|
+
|
|
514
|
+
<td rowspan="1" colSpan="1" >说明</td>
|
|
515
|
+
</tr>
|
|
516
|
+
|
|
517
|
+
<tr>
|
|
518
|
+
<td rowspan="1" colSpan="1" >variant</td>
|
|
519
|
+
|
|
520
|
+
<td rowspan="1" colSpan="1" >`VariantType`</td>
|
|
521
|
+
|
|
522
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
523
|
+
|
|
524
|
+
<td rowspan="1" colSpan="1" >显示模式</td>
|
|
525
|
+
</tr>
|
|
526
|
+
|
|
527
|
+
<tr>
|
|
528
|
+
<td rowspan="1" colSpan="1" >searchType</td>
|
|
529
|
+
|
|
530
|
+
<td rowspan="1" colSpan="1" >`SearchTabType`</td>
|
|
531
|
+
|
|
532
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
533
|
+
|
|
534
|
+
<td rowspan="1" colSpan="1" >当前搜索类型</td>
|
|
535
|
+
</tr>
|
|
536
|
+
|
|
537
|
+
<tr>
|
|
538
|
+
<td rowspan="1" colSpan="1" >advancedParams</td>
|
|
539
|
+
|
|
540
|
+
<td rowspan="1" colSpan="1" >`Map<SearchType, SearchParamsMap[SearchType]>`</td>
|
|
541
|
+
|
|
542
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
543
|
+
|
|
544
|
+
<td rowspan="1" colSpan="1" >高级搜索参数</td>
|
|
545
|
+
</tr>
|
|
546
|
+
|
|
547
|
+
<tr>
|
|
548
|
+
<td rowspan="1" colSpan="1" >onAdvancedParamsChange</td>
|
|
549
|
+
|
|
550
|
+
<td rowspan="1" colSpan="1" >`(type: SearchType, params: SearchParamsMap[SearchType]) => void`</td>
|
|
551
|
+
|
|
552
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
553
|
+
|
|
554
|
+
<td rowspan="1" colSpan="1" >参数变化回调</td>
|
|
555
|
+
</tr>
|
|
556
|
+
</table>
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
**示例**
|
|
560
|
+
``` typescript
|
|
561
|
+
const CustomSearchAdvanced = ({ variant, searchType, advancedParams, onAdvancedParamsChange }) => (
|
|
562
|
+
<div className="custom-advanced">
|
|
563
|
+
{/* 自定义高级搜索功能 */}
|
|
564
|
+
</div>
|
|
565
|
+
);
|
|
566
|
+
|
|
567
|
+
<Search SearchAdvanced={CustomSearchAdvanced} />
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
【自定义 SearchResultItem】
|
|
571
|
+
|
|
572
|
+
**Props**
|
|
573
|
+
<table>
|
|
574
|
+
<tr>
|
|
575
|
+
<td rowspan="1" colSpan="1" >属性名</td>
|
|
576
|
+
|
|
577
|
+
<td rowspan="1" colSpan="1" >类型</td>
|
|
578
|
+
|
|
579
|
+
<td rowspan="1" colSpan="1" >默认值</td>
|
|
580
|
+
|
|
581
|
+
<td rowspan="1" colSpan="1" >说明</td>
|
|
582
|
+
</tr>
|
|
583
|
+
|
|
584
|
+
<tr>
|
|
585
|
+
<td rowspan="1" colSpan="1" >data</td>
|
|
586
|
+
|
|
587
|
+
<td rowspan="1" colSpan="1" >`SearchResultItem`</td>
|
|
588
|
+
|
|
589
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
590
|
+
|
|
591
|
+
<td rowspan="1" colSpan="1" >搜索结果数据</td>
|
|
592
|
+
</tr>
|
|
593
|
+
|
|
594
|
+
<tr>
|
|
595
|
+
<td rowspan="1" colSpan="1" >type</td>
|
|
596
|
+
|
|
597
|
+
<td rowspan="1" colSpan="1" >`SearchType`</td>
|
|
598
|
+
|
|
599
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
600
|
+
|
|
601
|
+
<td rowspan="1" colSpan="1" >搜索结果类型</td>
|
|
602
|
+
</tr>
|
|
603
|
+
|
|
604
|
+
<tr>
|
|
605
|
+
<td rowspan="1" colSpan="1" >keyword</td>
|
|
606
|
+
|
|
607
|
+
<td rowspan="1" colSpan="1" >`string`</td>
|
|
608
|
+
|
|
609
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
610
|
+
|
|
611
|
+
<td rowspan="1" colSpan="1" >搜索关键词</td>
|
|
612
|
+
</tr>
|
|
613
|
+
|
|
614
|
+
<tr>
|
|
615
|
+
<td rowspan="1" colSpan="1" >onClick</td>
|
|
616
|
+
|
|
617
|
+
<td rowspan="1" colSpan="1" >`(data: SearchResultItem, type: SearchType) => void`</td>
|
|
618
|
+
|
|
619
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
620
|
+
|
|
621
|
+
<td rowspan="1" colSpan="1" >点击回调</td>
|
|
622
|
+
</tr>
|
|
623
|
+
|
|
624
|
+
<tr>
|
|
625
|
+
<td rowspan="1" colSpan="1" >className</td>
|
|
626
|
+
|
|
627
|
+
<td rowspan="1" colSpan="1" >`string`</td>
|
|
628
|
+
|
|
629
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
630
|
+
|
|
631
|
+
<td rowspan="1" colSpan="1" >自定义样式类名</td>
|
|
632
|
+
</tr>
|
|
633
|
+
</table>
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
**示例**
|
|
637
|
+
``` typescript
|
|
638
|
+
const CustomSearchItem = ({ data, type, keyword, onClick }) => (
|
|
639
|
+
<div className="custom-item">
|
|
640
|
+
{type === SearchType.MESSAGE && (
|
|
641
|
+
<Conversation
|
|
642
|
+
data={data}
|
|
643
|
+
keyword={keyword}
|
|
644
|
+
onClick={onClick}
|
|
645
|
+
/>
|
|
646
|
+
)}
|
|
647
|
+
{type === SearchType.USER && (
|
|
648
|
+
<User
|
|
649
|
+
data={data}
|
|
650
|
+
keyword={keyword}
|
|
651
|
+
onClick={onClick}
|
|
652
|
+
/>
|
|
653
|
+
)}
|
|
654
|
+
{type === SearchType.GROUP && (
|
|
655
|
+
<Group
|
|
656
|
+
data={data}
|
|
657
|
+
keyword={keyword}
|
|
658
|
+
onClick={onClick}
|
|
659
|
+
/>
|
|
660
|
+
)}
|
|
661
|
+
{type === SearchType.CHAT_MESSAGE && (
|
|
662
|
+
<Message
|
|
663
|
+
data={data}
|
|
664
|
+
keyword={keyword}
|
|
665
|
+
onClick={onClick}
|
|
666
|
+
/>
|
|
667
|
+
)}
|
|
668
|
+
</div>
|
|
669
|
+
);
|
|
670
|
+
|
|
671
|
+
<Search SearchResultItem={CustomSearchItem} />
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
【自定义占位组件】
|
|
675
|
+
|
|
676
|
+
**Props**
|
|
677
|
+
<table>
|
|
678
|
+
<tr>
|
|
679
|
+
<td rowspan="1" colSpan="1" >属性名</td>
|
|
680
|
+
|
|
681
|
+
<td rowspan="1" colSpan="1" >类型</td>
|
|
682
|
+
|
|
683
|
+
<td rowspan="1" colSpan="1" >默认值</td>
|
|
684
|
+
|
|
685
|
+
<td rowspan="1" colSpan="1" >说明</td>
|
|
686
|
+
</tr>
|
|
687
|
+
|
|
688
|
+
<tr>
|
|
689
|
+
<td rowspan="1" colSpan="1" >SearchResultsPresearch</td>
|
|
690
|
+
|
|
691
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType`</td>
|
|
692
|
+
|
|
693
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
694
|
+
|
|
695
|
+
<td rowspan="1" colSpan="1" >搜索前占位符组件</td>
|
|
696
|
+
</tr>
|
|
697
|
+
|
|
698
|
+
<tr>
|
|
699
|
+
<td rowspan="1" colSpan="1" >SearchResultsLoading</td>
|
|
700
|
+
|
|
701
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType`</td>
|
|
702
|
+
|
|
703
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
704
|
+
|
|
705
|
+
<td rowspan="1" colSpan="1" >加载中占位符组件</td>
|
|
706
|
+
</tr>
|
|
707
|
+
|
|
708
|
+
<tr>
|
|
709
|
+
<td rowspan="1" colSpan="1" >SearchResultsEmpty</td>
|
|
710
|
+
|
|
711
|
+
<td rowspan="1" colSpan="1" >`React.ComponentType`</td>
|
|
712
|
+
|
|
713
|
+
<td rowspan="1" colSpan="1" >-</td>
|
|
714
|
+
|
|
715
|
+
<td rowspan="1" colSpan="1" >空结果占位符组件</td>
|
|
716
|
+
</tr>
|
|
717
|
+
</table>
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
**示例**
|
|
721
|
+
``` typescript
|
|
722
|
+
<Search
|
|
723
|
+
SearchResultsPresearch={() => <div>输入关键词开始搜索</div>}
|
|
724
|
+
SearchResultsLoading={() => <div>搜索中...</div>}
|
|
725
|
+
SearchResultsEmpty={() => <div>未找到相关结果</div>}
|
|
726
|
+
/>
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
## SearchState
|
|
730
|
+
|
|
731
|
+
SearchState 是基于 Zustand 的搜索状态管理钩子,为 Search 组件提供完整的状态管理能力。它支持多种搜索模式(标准模式、嵌入式模式),管理搜索关键词、搜索结果、加载状态、错误处理等功能。如果自定义组件能力不能支持您的业务,可以使用 SearchState 实现您的需求。
|
|
732
|
+
|
|
733
|
+
#### 数据
|
|
734
|
+
<table>
|
|
735
|
+
<tr>
|
|
736
|
+
<td rowspan="1" colSpan="1" >属性名</td>
|
|
737
|
+
|
|
738
|
+
<td rowspan="1" colSpan="1" >类型</td>
|
|
739
|
+
|
|
740
|
+
<td rowspan="1" colSpan="1" >说明</td>
|
|
741
|
+
</tr>
|
|
742
|
+
|
|
743
|
+
<tr>
|
|
744
|
+
<td rowspan="1" colSpan="1" >keyword</td>
|
|
745
|
+
|
|
746
|
+
<td rowspan="1" colSpan="1" >`string`</td>
|
|
747
|
+
|
|
748
|
+
<td rowspan="1" colSpan="1" >当前搜索关键词</td>
|
|
749
|
+
</tr>
|
|
750
|
+
|
|
751
|
+
<tr>
|
|
752
|
+
<td rowspan="1" colSpan="1" >results</td>
|
|
753
|
+
|
|
754
|
+
<td rowspan="1" colSpan="1" >`Map<SearchType, SearchResult<SearchType>>`</td>
|
|
755
|
+
|
|
756
|
+
<td rowspan="1" colSpan="1" >搜索结果集合</td>
|
|
757
|
+
</tr>
|
|
758
|
+
|
|
759
|
+
<tr>
|
|
760
|
+
<td rowspan="1" colSpan="1" >isLoading</td>
|
|
761
|
+
|
|
762
|
+
<td rowspan="1" colSpan="1" >`boolean`</td>
|
|
763
|
+
|
|
764
|
+
<td rowspan="1" colSpan="1" >是否正在搜索</td>
|
|
765
|
+
</tr>
|
|
766
|
+
|
|
767
|
+
<tr>
|
|
768
|
+
<td rowspan="1" colSpan="1" >error</td>
|
|
769
|
+
|
|
770
|
+
<td rowspan="1" colSpan="1" >`Error \| null`</td>
|
|
771
|
+
|
|
772
|
+
<td rowspan="1" colSpan="1" >搜索错误信息</td>
|
|
773
|
+
</tr>
|
|
774
|
+
|
|
775
|
+
<tr>
|
|
776
|
+
<td rowspan="1" colSpan="1" >searchAdvancedParams</td>
|
|
777
|
+
|
|
778
|
+
<td rowspan="1" colSpan="1" >`Map<ISearchType, SearchParamsMap[SearchType]>`</td>
|
|
779
|
+
|
|
780
|
+
<td rowspan="1" colSpan="1" >高级搜索参数</td>
|
|
781
|
+
</tr>
|
|
782
|
+
|
|
783
|
+
<tr>
|
|
784
|
+
<td rowspan="1" colSpan="1" >selectedSearchType</td>
|
|
785
|
+
|
|
786
|
+
<td rowspan="1" colSpan="1" >`SearchType \| 'all'`</td>
|
|
787
|
+
|
|
788
|
+
<td rowspan="1" colSpan="1" >当前选中的搜索类型</td>
|
|
789
|
+
</tr>
|
|
790
|
+
</table>
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
#### 操作方法
|
|
794
|
+
<table>
|
|
795
|
+
<tr>
|
|
796
|
+
<td rowspan="1" colSpan="1" >方法名</td>
|
|
797
|
+
|
|
798
|
+
<td rowspan="1" colSpan="1" >类型</td>
|
|
799
|
+
|
|
800
|
+
<td rowspan="1" colSpan="1" >说明</td>
|
|
801
|
+
</tr>
|
|
802
|
+
|
|
803
|
+
<tr>
|
|
804
|
+
<td rowspan="1" colSpan="1" >setKeyword</td>
|
|
805
|
+
|
|
806
|
+
<td rowspan="1" colSpan="1" >`(k: string) => void`</td>
|
|
807
|
+
|
|
808
|
+
<td rowspan="1" colSpan="1" >设置搜索关键词</td>
|
|
809
|
+
</tr>
|
|
810
|
+
|
|
811
|
+
<tr>
|
|
812
|
+
<td rowspan="1" colSpan="1" >loadMore</td>
|
|
813
|
+
|
|
814
|
+
<td rowspan="1" colSpan="1" >`(type?: SearchType) => Promise<void>`</td>
|
|
815
|
+
|
|
816
|
+
<td rowspan="1" colSpan="1" >加载更多搜索结果</td>
|
|
817
|
+
</tr>
|
|
818
|
+
|
|
819
|
+
<tr>
|
|
820
|
+
<td rowspan="1" colSpan="1" >setSelectedType</td>
|
|
821
|
+
|
|
822
|
+
<td rowspan="1" colSpan="1" >`(type: SearchType \| 'all') => void`</td>
|
|
823
|
+
|
|
824
|
+
<td rowspan="1" colSpan="1" >设置搜索类型</td>
|
|
825
|
+
</tr>
|
|
826
|
+
|
|
827
|
+
<tr>
|
|
828
|
+
<td rowspan="1" colSpan="1" >setSearchMessageAdvancedParams</td>
|
|
829
|
+
|
|
830
|
+
<td rowspan="1" colSpan="1" >`(params: SearchCloudMessagesParams) => void`</td>
|
|
831
|
+
|
|
832
|
+
<td rowspan="1" colSpan="1" >设置消息搜索高级参数</td>
|
|
833
|
+
</tr>
|
|
834
|
+
|
|
835
|
+
<tr>
|
|
836
|
+
<td rowspan="1" colSpan="1" >setSearchUserAdvancedParams</td>
|
|
837
|
+
|
|
838
|
+
<td rowspan="1" colSpan="1" >`(params: SearchCloudUsersParams) => void`</td>
|
|
839
|
+
|
|
840
|
+
<td rowspan="1" colSpan="1" >设置用户搜索高级参数</td>
|
|
841
|
+
</tr>
|
|
842
|
+
|
|
843
|
+
<tr>
|
|
844
|
+
<td rowspan="1" colSpan="1" >setSearchGroupAdvancedParams</td>
|
|
845
|
+
|
|
846
|
+
<td rowspan="1" colSpan="1" >`(params: SearchCloudGroupsParams) => void`</td>
|
|
847
|
+
|
|
848
|
+
<td rowspan="1" colSpan="1" >设置群组搜索高级参数</td>
|
|
849
|
+
</tr>
|
|
850
|
+
</table>
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
## 使用示例
|
|
854
|
+
``` typescript
|
|
855
|
+
import { useSearchState, VariantType } from '@tencentcloud/chat-uikit-react';
|
|
856
|
+
const {
|
|
857
|
+
keyword,
|
|
858
|
+
results,
|
|
859
|
+
isLoading,
|
|
860
|
+
error,
|
|
861
|
+
setKeyword,
|
|
862
|
+
setSelectedType,
|
|
863
|
+
loadMore
|
|
864
|
+
} = useSearchState(VariantType.STANDARD);
|
|
865
|
+
|
|
866
|
+
```
|
|
867
|
+
|
|
868
|
+
## 常见问题
|
|
869
|
+
|
|
870
|
+
### Q: 如何自定义搜索结果的显示格式?
|
|
871
|
+
|
|
872
|
+
A: 使用 `SearchResultItem` 属性传入自定义组件。
|
|
873
|
+
|
|
874
|
+
### Q: 如何处理搜索性能问题?
|
|
875
|
+
|
|
876
|
+
A: 调整 `debounceTime`,使用 React.memo,考虑结果缓存。
|
|
877
|
+
|
|
878
|
+
### Q: 移动端如何优化?
|
|
879
|
+
|
|
880
|
+
A: 组件自动适配移动端,也可通过 CSS 进一步定制。
|
|
881
|
+
|
|
882
|
+
### Q: 如何支持多语言?
|
|
883
|
+
|
|
884
|
+
A: 组件内置国际化支持,通过 `useUIKit` 获取翻译。
|
|
885
|
+
|