diff --git a/app/api/admin/psd-templates/[id]/parse/route.ts b/app/api/admin/psd-templates/[id]/parse/route.ts index 5befacedc..3f8bf5895 100644 --- a/app/api/admin/psd-templates/[id]/parse/route.ts +++ b/app/api/admin/psd-templates/[id]/parse/route.ts @@ -25,6 +25,7 @@ import { failTimedOutAgentPsdTemplates } from "@/lib/agents/psd-template-timeout import { uploadFile } from "@/lib/storage/service"; export const runtime = "nodejs"; +export const maxDuration = 1800; function jsonError(status: number, error: string) { const payload: AgentPsdTemplateMutationResponse = { @@ -291,6 +292,13 @@ export async function POST( }); } + await updateParseProgress({ + templateId: id, + updatedBy: session.user.id, + progress: 24, + stage: "正在解析 PSD 图层结构与预览", + error: undefined, + }); const parsedTemplate = await parsePsdTemplateFile(fileBuffer); if (parsedTemplate.layers.length === 0) { @@ -301,7 +309,7 @@ export async function POST( templateId: id, updatedBy: session.user.id, progress: 42, - stage: "正在生成模板预览", + stage: "正在上传模板预览", error: undefined, }); diff --git a/lib/agents/psd-template-timeout.ts b/lib/agents/psd-template-timeout.ts index f41afcf20..ef446b6b9 100644 --- a/lib/agents/psd-template-timeout.ts +++ b/lib/agents/psd-template-timeout.ts @@ -7,8 +7,19 @@ import { } from "@/lib/agents/psd-template-config"; import { readAgentPsdTemplates } from "@/lib/agents/psd-template-settings"; -export const AGENT_PSD_TEMPLATE_QUICK_PARSE_TIMEOUT_MS = 8 * 60 * 1000; -export const AGENT_PSD_TEMPLATE_ASSET_BACKFILL_TIMEOUT_MS = 20 * 60 * 1000; +function getEnvPositiveInt(name: string, fallback: number) { + const parsed = Number.parseInt(process.env[name] || "", 10); + return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback; +} + +export const AGENT_PSD_TEMPLATE_QUICK_PARSE_TIMEOUT_MS = getEnvPositiveInt( + "AGENT_PSD_TEMPLATE_QUICK_PARSE_TIMEOUT_MS", + 15 * 60 * 1000 +); +export const AGENT_PSD_TEMPLATE_ASSET_BACKFILL_TIMEOUT_MS = getEnvPositiveInt( + "AGENT_PSD_TEMPLATE_ASSET_BACKFILL_TIMEOUT_MS", + 20 * 60 * 1000 +); function getTemplateUpdatedAtTime(template: AgentPsdTemplate) { const updatedAt = new Date(template.updatedAt).getTime();