ai-chatbot/lib/agents/workflow-showcase-config.ts
Your Name 1f078d5b37
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
feat: polish agent workflow showcase and layout
2026-03-18 01:18:58 +08:00

48 lines
1.6 KiB
TypeScript

import type { AgentWorkflowShowcaseConfig } from "@/types/agent";
export const AGENT_WORKFLOW_SHOWCASE_CONFIG_KEY = "agent_workflow_showcase_config";
export const defaultAgentWorkflowShowcaseConfig: AgentWorkflowShowcaseConfig = {
enabled: true,
title: "三倍速出片,电影级质感",
subtitle: "第一步:风格选择 第二步:生图模式",
actionText: "我要创作",
videoUrl: "",
posterUrl: "",
overlayText: "让每一步选择,都能直达高质感成片",
footerText: "用户作品",
};
function sanitizeText(value: unknown, maxLength: number) {
return String(value || "").trim().slice(0, maxLength);
}
export function normalizeAgentWorkflowShowcaseConfig(
value: unknown
): AgentWorkflowShowcaseConfig {
if (!value || typeof value !== "object" || Array.isArray(value)) {
return defaultAgentWorkflowShowcaseConfig;
}
const raw = value as Record<string, unknown>;
return {
enabled:
typeof raw.enabled === "boolean"
? raw.enabled
: defaultAgentWorkflowShowcaseConfig.enabled,
title:
sanitizeText(raw.title, 200) || defaultAgentWorkflowShowcaseConfig.title,
subtitle:
sanitizeText(raw.subtitle, 300) || defaultAgentWorkflowShowcaseConfig.subtitle,
actionText:
sanitizeText(raw.actionText, 48) || defaultAgentWorkflowShowcaseConfig.actionText,
videoUrl: sanitizeText(raw.videoUrl, 2000),
posterUrl: sanitizeText(raw.posterUrl, 2000) || null,
overlayText:
sanitizeText(raw.overlayText, 200) || defaultAgentWorkflowShowcaseConfig.overlayText,
footerText:
sanitizeText(raw.footerText, 64) || defaultAgentWorkflowShowcaseConfig.footerText,
};
}