Skip to main content

Module search

Module search 

Source
Expand description

全文搜索结果页 /search?q=:顶部 Composer,结果按相关度或时间排列,命中词高亮。

输入停顿后自动检索,回车立即提交;编辑与清空会立即作废旧请求。输入框里按 ↓ 进入结果,结果间 ↑↓ 移动,↑ 越过第一条回到输入框。未输入时给出常用标签。

搜索请求只在浏览器发起(Effect / 事件处理里 spawn_local),页面没有 SSR 数据, 因此路由使用默认 SsrMode。服务端与水合首帧都按 ?q= 渲染输入框、不渲染结果; 历史记录里保存的状态在挂载后的 Effect 里恢复,保证两端首帧 DOM 一致。

Structs§

MarkedProps 🔒
Props for the Marked component.
SearchHistoryState 🔒
Only settled responses are persisted; request IDs and pending work belong to the mounted page and must never be revived by browser Back.
SearchPageProps 🔒
Props for the SearchPage component.
SearchResultItemProps 🔒
Props for the SearchResultItem component.
SearchRoute
搜索路由,对应 /search(查询参数 q)。没有 SSR 数据,请求全部在浏览器发起。
SuggestedTagsProps 🔒
Props for the SuggestedTags component.

Enums§

SortOrder 🔒

Constants§

RESULT_LIMIT 🔒
服务端最多返回的条数。
RESULT_TAGS 🔒
每条结果最多列出的标签数。
SEARCH_DEBOUNCE_MS 🔒
SNIPPET_RADIUS 🔒
摘要片段在命中词两侧保留的字数。
SUGGESTED_TAGS 🔒
未输入时推荐的标签数。

Functions§

Marked 🔒
命中词用 <mark> 标出的一段文字。
SearchPage 🔒
搜索页。q 来自 /search?q=:历史记录里没有保存的查询时用它作为初始查询并立即搜索。
SearchResultItem 🔒
Required Props
SuggestedTags 🔒
未输入时的「试试这些标签」。标签接口失败时不显示。
__SearchRoute_View 🔒
focus_result 🔒
focused_result 🔒
当前获得焦点的结果序号(仅 wasm;服务端渲染时没有焦点)。
ordered 🔒
服务端已按相关度排序;「最新」在浏览器里按发布时间重排,同时间按 id 稳定。
result_id 🔒
results_view 🔒
搜索完成后的内容:无结果提示,或工具栏(计数 + 排序)与结果列表。

Type Aliases§

SearchResult 🔒
搜索结果:成功的响应,或失败。