feat(web): naming template form for global, library root and work overrides (FE-3)

- template editor per movie / tv / variety with variable insertion, live preview by segment role, error line:col and reset to default
- settings > library: global templates, lockFileNameForBound and per-root overrides
- work detail: naming override dialog (preview uses the existing path binding)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-28 16:06:16 +08:00
1 parent b908b4a0c9
commit 2c6a89f309
7 files changed
+993 -1

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import type { NamingKind, NamingOverride } from "@umt/contracts";
// 命名模板表单的纯函数:保存错误拆分、覆盖请求体、来源文案。
export const NAMING_KINDS: NamingKind[] = ["movie", "tv", "variety"];
export const SOURCE_LABEL = { global: "全局", root: "库根", entity: "作品" } as const;
/** 422 消息 "movie: 1:3 …; tv: …" → 按类型拆开,行列号改写成中文 */
export function splitNamingErrors(message: string): Partial<Record<NamingKind, string>> | null {
const out: Partial<Record<NamingKind, string>> = {};
for (const m of message.matchAll(/(movie|tv|variety):\s*([^;]+)/g)) {
const [, k, msg] = m;
const pos = /^(\d+):(\d+)\s*(.*)$/.exec((msg ?? "").trim());
out[k as NamingKind] = pos ? `第 ${pos[1]} 行第 ${pos[2]} 列:${pos[3]}` : (msg ?? "").trim();
}
return Object.keys(out).length ? out : null;
}
/** 覆盖草稿 → 请求体;全部留空 = null(清除覆盖) */
export function overrideBody(draft: Partial<Record<NamingKind, string>>): NamingOverride | null {
const o: NamingOverride = {};
for (const k of NAMING_KINDS) {
const v = draft[k];
if (v?.trim()) o[k] = v;
}
return Object.keys(o).length ? o : null;
}