fix(web): stale-closure + focus trap + 去边界强转 + a11y/性能打磨 + 类型化客户端
P1-6 useStyleLearn/useKimiOauth 修 stale-closure 依赖。 P1-7 CommandPalette/Drawer 加 focus trap(新 lib/a11y/focusTrap)。 P1-8 SSE 解析与 server.ts 去 as 强转改类型守卫/运行时校验。 P2 删冗余强转、开 noUncheckedIndexedAccess、Toast 清理+稳定 key、列表 key 稳定化、 rel=noopener、useMemo 大文本、ConflictCard role=group、useInjection 加锁、 client.test 真断言。 codegen 重生成 schema.d.ts + 消费 DimensionEntry/ReviewConflictView 强类型。
This commit is contained in:
@@ -18,26 +18,22 @@ function asOptionalString(v: unknown): string | null {
|
||||
return typeof v === "string" ? v : null;
|
||||
}
|
||||
|
||||
function asStringArray(v: unknown): string[] {
|
||||
if (!Array.isArray(v)) return [];
|
||||
return v.filter((x): x is string => typeof x === "string");
|
||||
}
|
||||
|
||||
function asIntArray(v: unknown): number[] {
|
||||
if (!Array.isArray(v)) return [];
|
||||
return v.filter((x): x is number => typeof x === "number" && Number.isFinite(x));
|
||||
}
|
||||
|
||||
// 把一条留痕的 conflicts 收紧(缺字段给安全默认;保持顺序=下标身份,对齐冲突 gate)。
|
||||
// 把一条留痕的 conflicts(ReviewConflictView[],已强类型)映射成 ReviewConflict。
|
||||
// 保持顺序=下标身份(对齐冲突 gate);type 空串回退「未分类」,refs 容忍缺省。
|
||||
export function normalizeConflicts(
|
||||
item: ReviewHistoryItem | undefined,
|
||||
): ReviewConflict[] {
|
||||
const raw = item?.conflicts ?? [];
|
||||
return raw.map((c) => ({
|
||||
type: asString(c["type"], "未分类"),
|
||||
where: asString(c["where"]),
|
||||
refs: asStringArray(c["refs"]),
|
||||
suggestion: asString(c["suggestion"]),
|
||||
type: c.type || "未分类",
|
||||
where: c.where,
|
||||
refs: c.refs ?? [],
|
||||
suggestion: c.suggestion,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user