创作模式oss文件上传临时数据清理
This commit is contained in:
@@ -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<Record<string, Array<{ name: string; url: string }>>>({});
|
||||
const creationFieldUploading = reactive<Record<string, boolean>>({});
|
||||
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(`已进入创作模式`);
|
||||
|
||||
Reference in New Issue
Block a user