Commit 5f904413 authored by chenghong_tao's avatar chenghong_tao

fix 工作流显示

parent 98994bd5
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<div class="custom-bubble-content" v-adjust-width> <div class="custom-bubble-content" v-adjust-width>
<!-- 工作流 --> <!-- 工作流 -->
<workflowItem <workflowItem
v-if="taskStore.showWorkflow" v-if="taskStore.showWorkflow && workflowContent.length > 0"
:workflowContent="workflowContent" :workflowContent="workflowContent"
ref="workflowItemRef" ref="workflowItemRef"
/> />
......
...@@ -45,8 +45,10 @@ watch( ...@@ -45,8 +45,10 @@ watch(
() => props.workflowContent, () => props.workflowContent,
(val) => { (val) => {
if (val && Array.isArray(val)) { if (val && Array.isArray(val)) {
let inIteration = false;
for (let i = 0; i < val.length; i++) { for (let i = 0; i < val.length; i++) {
const item = val[i]; const item = val[i];
const dataId = item?.data?.id;
if (item.event === "error") { if (item.event === "error") {
ElMessage.error(item.message) ElMessage.error(item.message)
workflowStatus.value = 'error'; workflowStatus.value = 'error';
...@@ -55,13 +57,47 @@ watch( ...@@ -55,13 +57,47 @@ watch(
if (item.event === "workflow_finished") { if (item.event === "workflow_finished") {
workflowStatus.value = 'success'; workflowStatus.value = 'success';
} }
// 特殊处理 iteration_started 和 iteration_completed
if (item.event === "iteration_started") {
inIteration = true;
// 添加 iteration 节点到 thinkingItems 中
const title = item.data?.title || '迭代执行数据库查询';
const index = thinkingItems.value.findIndex(ti => ti.codeId === dataId);
if (index === -1) {
thinkingItems.value.push({
codeId: dataId,
status: "loading",
isCanExpand: false,
isDefaultExpand: false,
title: title,
thinkTitle: "",
thinkContent: "",
type: "iteration"
});
}
continue;
}
if (item.event === "iteration_completed") {
const index = thinkingItems.value.findIndex(ti => ti.codeId === dataId);
if (index !== -1) {
thinkingItems.value[index].status = "success";
}
inIteration = false;
continue;
}
// 如果当前处于 iteration 区间内,则跳过处理
if (inIteration) continue;
if ( if (
item.event !== "workflow_started" && item.event !== "workflow_started" &&
item.event !== "workflow_finished" && item.event !== "workflow_finished" &&
item.event !== "message_end" && item.event !== "message_end" &&
item.event !== "message" item.event !== "message"
) { ) {
const dataId = item?.data?.id;
const index = thinkingItems.value.findIndex( const index = thinkingItems.value.findIndex(
(ti) => ti.codeId === dataId (ti) => ti.codeId === dataId
); );
...@@ -70,24 +106,18 @@ watch( ...@@ -70,24 +106,18 @@ watch(
const isExcludeNode = excludedNodeTypes.includes(item?.data?.node_type); const isExcludeNode = excludedNodeTypes.includes(item?.data?.node_type);
if (!isExcludeNode) { if (!isExcludeNode) {
if (index === -1) { if (index === -1) {
// 如果存在迭代节点,且迭代节点正在执行,则不再添加后续节点 thinkingItems.value.push({
const iterationItem = thinkingItems.value.filter(m => m.type === 'iteration') codeId: dataId,
if (iterationItem.length > 0 && iterationItem[0].status === 'loading') { status: "loading",
console.log('迭代中'); isCanExpand: false,
} else { isDefaultExpand: false,
thinkingItems.value.push({ title: item.data.title,
codeId: dataId, thinkTitle: "",
status: "loading", thinkContent: "",
isCanExpand: false, type: item?.data?.node_type
isDefaultExpand: false, });
title: item.data.title,
thinkTitle: "",
thinkContent: "",
type: item?.data?.node_type
});
}
} else { } else {
if (item.event === "node_finished" || item.event === "iteration_completed") { if (item.event === "node_finished") {
thinkingItems.value[index].status = "success"; thinkingItems.value[index].status = "success";
} }
} }
......
...@@ -42,8 +42,6 @@ export const useTaskStore = defineStore('task', { ...@@ -42,8 +42,6 @@ export const useTaskStore = defineStore('task', {
this.message_id = '' this.message_id = ''
this.workflow_run_id = '' this.workflow_run_id = ''
this.isLoading = false this.isLoading = false
this.deepThink = false
this.showWorkflow = false
} }
}, },
persist: { persist: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment