mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-03 12:21:50 +08:00
feat(web): 任务发现 tab 支持严重度筛选与排序
对齐全局发现页:共用 severity chip、Case 列表 sort=severity, 原始上报列表前端按严重度过滤并排序。
This commit is contained in:
1 parent
620ca5d96c
commit
0ecaea2fb2
5 files changed
+134
-26
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import type { Finding, Severity } from "./types";
|
||||
|
||||
const SEVERITY_RANK: Record<Severity, number> = { critical: 4, high: 3, medium: 2, low: 1 };
|
||||
|
||||
export function filterAndSortFindings(
|
||||
findings: readonly Finding[],
|
||||
severity: "all" | Severity,
|
||||
timeDirection: "asc" | "desc",
|
||||
): Finding[] {
|
||||
return findings
|
||||
.filter((finding) => severity === "all" || finding.severity === severity)
|
||||
.sort((a, b) => {
|
||||
const severityCompared = (SEVERITY_RANK[b.severity] ?? 0) - (SEVERITY_RANK[a.severity] ?? 0);
|
||||
if (severityCompared !== 0) return severityCompared;
|
||||
const timeCompared = Date.parse(a.ts) - Date.parse(b.ts);
|
||||
if (timeCompared !== 0) return timeDirection === "asc" ? timeCompared : -timeCompared;
|
||||
return b.id.localeCompare(a.id, undefined, { numeric: true });
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user