fix(web): 链相位语义色/失败可重试 + 模板填入中文标签/删除可撤销/工具卡文案 + 模板库 PageHeader
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
previewRows,
|
||||
resolveLegacyRoute,
|
||||
templateFillTarget,
|
||||
toolKeyOptions,
|
||||
} from "./toolbox";
|
||||
|
||||
const field = (over: Partial<ToolInputFieldView> = {}): ToolInputFieldView => ({
|
||||
@@ -210,6 +211,22 @@ describe("isLegacyTool", () => {
|
||||
isLegacyTool(tool({ is_legacy: false, legacy_route: "/x/{id}" })),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("maps descriptors to key/title options", () => {
|
||||
expect(
|
||||
toolKeyOptions([
|
||||
tool({ key: "idea", title: "脑洞生成器" }),
|
||||
tool({ key: "title", title: "书名生成器" }),
|
||||
]),
|
||||
).toEqual([
|
||||
{ key: "idea", title: "脑洞生成器" },
|
||||
{ key: "title", title: "书名生成器" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("returns empty array for undefined tools", () => {
|
||||
expect(toolKeyOptions(undefined)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("templateFillTarget", () => {
|
||||
|
||||
@@ -320,3 +320,17 @@ export function resolveLegacyRoute(
|
||||
export function isLegacyTool(tool: Readonly<ToolDescriptorView>): boolean {
|
||||
return tool.is_legacy && !!tool.legacy_route;
|
||||
}
|
||||
|
||||
// —— 「关联工具」下拉选项 ——
|
||||
// 工具描述符 → 下拉选项(value=key 用于 tool_key 关联,label=中文标题供展示,不暴露英文 key)。
|
||||
// 模板库「关联生成器」字段据此从纯文本框升级为 Select。
|
||||
export interface ToolKeyOption {
|
||||
key: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
export function toolKeyOptions(
|
||||
tools: readonly ToolDescriptorView[] | undefined,
|
||||
): ToolKeyOption[] {
|
||||
return (tools ?? []).map((tool) => ({ key: tool.key, title: tool.title }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user