refactor: 统一 target name/description 可空语义,前端展示 fallback 到 id
- schema: name/description 允许省略或显式 null,TypeBox Union([Null, String]) - 类型: RawTargetConfig/ResolvedTargetBase/子类型/StoredTarget/TargetStatus name 改为 string | null - checker resolve: name: t.name ?? null,不再 fallback 到 id - 语义校验: 拒绝空字符串和纯空白 name - SQLite: targets.name 列改为可空 TEXT - 前端: 新增 getTargetDisplayName(target) 展示 name ?? id - 测试: 覆盖 name/description null 全场景,查找改为按 id - 文档: 更新 README/DEVELOPMENT 和 6 个 openspec specs
This commit is contained in:
@@ -5,6 +5,7 @@ import { DateRangePicker, Drawer, RadioGroup, Space, Tabs, Tag, Typography } fro
|
||||
|
||||
import type { HistoryResponse, TargetMetricsResponse, TargetStatus } from "../../shared/api";
|
||||
|
||||
import { getTargetDisplayName } from "../utils/target";
|
||||
import { subtractHours } from "../utils/time";
|
||||
import { HistoryTab } from "./HistoryTab";
|
||||
import { OverviewTab } from "./OverviewTab";
|
||||
@@ -90,7 +91,7 @@ export function TargetDetailDrawer({
|
||||
target ? (
|
||||
<Space align="center" size={12}>
|
||||
<StatusDot up={!!isUp} />
|
||||
<Typography.Text strong>{target.name}</Typography.Text>
|
||||
<Typography.Text strong>{getTargetDisplayName(target)}</Typography.Text>
|
||||
<Tag size="small" theme="primary" variant="light-outline">
|
||||
{target.type}
|
||||
</Tag>
|
||||
|
||||
@@ -6,6 +6,7 @@ import type { TargetStatus } from "../../shared/api";
|
||||
|
||||
import { StatusBar } from "../components/StatusBar";
|
||||
import { StatusDot } from "../components/StatusDot";
|
||||
import { getTargetDisplayName } from "../utils/target";
|
||||
import { getAvailabilityProgressColor } from "./color-threshold";
|
||||
import { statusFilter } from "./target-table-filters";
|
||||
import { availabilitySorter, latencySorter } from "./target-table-sorters";
|
||||
@@ -22,6 +23,7 @@ export function createTargetTableColumns(checkerTypes: string[]): Array<PrimaryT
|
||||
width: 60,
|
||||
},
|
||||
{
|
||||
cell: ({ row }: PrimaryTableCellParams<TargetStatus>) => getTargetDisplayName(row),
|
||||
colKey: "name",
|
||||
ellipsis: true,
|
||||
title: "名称",
|
||||
|
||||
5
src/web/utils/target.ts
Normal file
5
src/web/utils/target.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { TargetStatus } from "../../shared/api";
|
||||
|
||||
export function getTargetDisplayName(target: TargetStatus): string {
|
||||
return target.name ?? target.id;
|
||||
}
|
||||
Reference in New Issue
Block a user