From 6ef063ac09d2a99a9810088f0cf18b454457d107 Mon Sep 17 00:00:00 2001 From: 2910410219 <2910410219@qq.com> Date: Fri, 5 Jun 2026 09:41:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E4=BD=9C=E6=A8=A1=E5=BC=8Foss?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E4=B8=B4=E6=97=B6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/settings/creation/index.vue | 40 +++++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/views/settings/creation/index.vue b/src/views/settings/creation/index.vue index ff0a513..f2d32cc 100644 --- a/src/views/settings/creation/index.vue +++ b/src/views/settings/creation/index.vue @@ -1424,6 +1424,7 @@ const fetchWorkflowList = async () => { // }; // 新建工作流 const createNewWorkflow = () => { + resetCreationTempState(); // 切换回画布编辑模式 isCreationMode.value = false; currentWorkflowForCreation.value = null; @@ -1612,9 +1613,7 @@ const useWorkflow = async (workflow: WorkflowItem) => { // 从工作流进入,不禁用表单 isFromWorkspace.value = false; currentSessionId.value = null; // 清空会话 ID - - // 初始化创作表单的值 - Object.keys(creationFormValues).forEach((key) => delete creationFormValues[key]); + resetCreationTempState(); // 根据 nodeInputParams 初始化表单默认值 if (res.data.nodeInputParams && Array.isArray(res.data.nodeInputParams)) { @@ -1671,6 +1670,7 @@ const useWorkflow = async (workflow: WorkflowItem) => { }); } }); + hydrateCreationFileFields(res.data.nodeInputParams); } ElMessage.success(`已进入创作模式`); @@ -1687,6 +1687,7 @@ const editWorkflow = async (workflow: WorkflowItem) => { // 调用详情接口获取最新的工作流数据 const res = await getWorkflowDetail(workflow.id); if (res.data?.flowContent) { + resetCreationTempState(); // 切换回画布编辑模式 isCreationMode.value = false; currentWorkflowForCreation.value = null; @@ -1710,6 +1711,7 @@ const editWorkflow = async (workflow: WorkflowItem) => { }; // 返回画布编辑模式 const backToCanvas = async () => { + resetCreationTempState(); isCreationMode.value = false; currentWorkflowForCreation.value = null; currentSessionId.value = null; // 清空会话 ID @@ -1813,6 +1815,29 @@ const getCreationVisibleFields = (node: any) => { }); return result; }; +const resetCreationTempState = () => { + selectedFiles.value = []; + selectedCreationSkill.value = null; + userInput.value = ''; + Object.keys(creationFormValues).forEach((key) => delete creationFormValues[key]); + Object.keys(creationFieldFiles).forEach((key) => delete creationFieldFiles[key]); + Object.keys(creationFieldUploading).forEach((key) => delete creationFieldUploading[key]); +}; +const hydrateCreationFileFields = (nodes: any[] = []) => { + nodes.forEach((node: any) => { + getCreationVisibleFields(node).forEach((field: any) => { + if (!isCreationFileField(field)) return; + const key = getCreationFieldKey(node, field); + const rawValue = creationFormValues[key]; + const urls = Array.isArray(rawValue) ? rawValue : rawValue ? [rawValue] : []; + if (urls.length === 0) return; + creationFieldFiles[key] = urls.map((url: string, index: number) => ({ + name: String(url || '').split('/').pop() || `file-${index + 1}`, + url, + })); + }); + }); +}; const creationFieldFiles = reactive>>({}); const creationFieldUploading = reactive>({}); const isCreationFieldUploading = (node: any, field: any) => { @@ -2186,6 +2211,7 @@ const handleTreeNodeClick = async (data: TreeNode) => { currentSessionId.value = data.sessionId || null; // 标记为从工作空间进入 isFromWorkspace.value = true; + resetCreationTempState(); // 处理 fileUrl const fileUrls: string[] = []; @@ -2209,9 +2235,6 @@ const handleTreeNodeClick = async (data: TreeNode) => { isCreationMode.value = true; currentWorkflowForCreation.value = res.data; - // 初始化创作表单的值 - Object.keys(creationFormValues).forEach((key) => delete creationFormValues[key]); - // 根据 nodeInputParams 初始化表单默认值 if (res.data.nodeInputParams && Array.isArray(res.data.nodeInputParams)) { res.data.nodeInputParams.forEach((node: any) => { @@ -2247,6 +2270,7 @@ const handleTreeNodeClick = async (data: TreeNode) => { }); } }); + hydrateCreationFileFields(res.data.nodeInputParams); } ElMessage.success(`已进入创作模式`); @@ -2293,9 +2317,6 @@ const handleTreeNodeClick = async (data: TreeNode) => { isCreationMode.value = true; currentWorkflowForCreation.value = res.data; - // 初始化创作表单的值 - Object.keys(creationFormValues).forEach((key) => delete creationFormValues[key]); - // 根据 nodeInputParams 初始化表单默认值 if (res.data.nodeInputParams && Array.isArray(res.data.nodeInputParams)) { res.data.nodeInputParams.forEach((node: any) => { @@ -2331,6 +2352,7 @@ const handleTreeNodeClick = async (data: TreeNode) => { }); } }); + hydrateCreationFileFields(res.data.nodeInputParams); } ElMessage.success(`已进入创作模式`);