Commit 5f904413 authored by chenghong_tao's avatar chenghong_tao

fix 工作流显示

parent 98994bd5
......@@ -7,7 +7,7 @@
<div class="custom-bubble-content" v-adjust-width>
<!-- 工作流 -->
<workflowItem
v-if="taskStore.showWorkflow"
v-if="taskStore.showWorkflow && workflowContent.length > 0"
:workflowContent="workflowContent"
ref="workflowItemRef"
/>
......
......@@ -45,8 +45,10 @@ watch(
() => props.workflowContent,
(val) => {
if (val && Array.isArray(val)) {
let inIteration = false;
for (let i = 0; i < val.length; i++) {
const item = val[i];
const dataId = item?.data?.id;
if (item.event === "error") {
ElMessage.error(item.message)
workflowStatus.value = 'error';
......@@ -55,13 +57,47 @@ watch(
if (item.event === "workflow_finished") {
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 (
item.event !== "workflow_started" &&
item.event !== "workflow_finished" &&
item.event !== "message_end" &&
item.event !== "message"
) {
const dataId = item?.data?.id;
const index = thinkingItems.value.findIndex(
(ti) => ti.codeId === dataId
);
......@@ -70,24 +106,18 @@ watch(
const isExcludeNode = excludedNodeTypes.includes(item?.data?.node_type);
if (!isExcludeNode) {
if (index === -1) {
// 如果存在迭代节点,且迭代节点正在执行,则不再添加后续节点
const iterationItem = thinkingItems.value.filter(m => m.type === 'iteration')
if (iterationItem.length > 0 && iterationItem[0].status === 'loading') {
console.log('迭代中');
} else {
thinkingItems.value.push({
codeId: dataId,
status: "loading",
isCanExpand: false,
isDefaultExpand: false,
title: item.data.title,
thinkTitle: "",
thinkContent: "",
type: item?.data?.node_type
});
}
thinkingItems.value.push({
codeId: dataId,
status: "loading",
isCanExpand: false,
isDefaultExpand: false,
title: item.data.title,
thinkTitle: "",
thinkContent: "",
type: item?.data?.node_type
});
} else {
if (item.event === "node_finished" || item.event === "iteration_completed") {
if (item.event === "node_finished") {
thinkingItems.value[index].status = "success";
}
}
......
......@@ -42,8 +42,6 @@ export const useTaskStore = defineStore('task', {
this.message_id = ''
this.workflow_run_id = ''
this.isLoading = false
this.deepThink = false
this.showWorkflow = false
}
},
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