Merge pull request #150 from Autumn-27/feat/broadcast-search-node-id
feat(web): 播报板搜索支持按节点 id 筛选
This commit is contained in:
4 files changed
+65
-3
No files matched your search
@@ -573,7 +573,7 @@ export function BroadcastTab({ taskId }: { taskId: string }) {
|
||||
<Input
|
||||
value={queryInput}
|
||||
onChange={(e) => setQueryInput(e.target.value)}
|
||||
placeholder="搜索播报内容 / 来源"
|
||||
placeholder="搜索内容 / 来源 / 节点 id"
|
||||
className="h-8 pl-8"
|
||||
aria-label="搜索播报"
|
||||
/>
|
||||
|
||||
@@ -2168,7 +2168,12 @@ function route(m: string, path: string, seg: string[], q: URLSearchParams, b: Re
|
||||
const rank = (id: string) => all.findIndex((n) => n.id === id);
|
||||
const matched = all
|
||||
.filter((n) => (kinds.size === 0 || kinds.has(n.type)) && (states.size === 0 || states.has(n.state)))
|
||||
.filter((n) => !needle || `${n.payload ?? ""} ${n.origin}`.toLowerCase().includes(needle))
|
||||
.filter(
|
||||
(n) =>
|
||||
!needle ||
|
||||
// 内容 / 来源 / 节点 id 任一命中即可(id 兼容「#41」写法)。
|
||||
`${n.payload ?? ""} ${n.origin} ${n.id}`.toLowerCase().includes(needle.replace(/^#/, "")),
|
||||
)
|
||||
.sort((a, b) => {
|
||||
const d = Date.parse(a.ts) - Date.parse(b.ts) || rank(a.id) - rank(b.id);
|
||||
return asc ? d : -d;
|
||||
|
||||
Reference in new issue
Block a user