From aed77fb6fca2c19b40838b3283d300f0035e1a39 Mon Sep 17 00:00:00 2001 From: martsi Date: Fri, 19 Jul 2024 20:16:15 +0800 Subject: [PATCH] fix: capability to highlight corresponding nodes at the same time. feat(session): reset store when backing to home page --- src/components/BreakdownChart.vue | 11 +++++++++-- src/components/WorkflowChart.vue | 15 +++++++++++---- src/pages/Workflow/components/TopBox.vue | 3 +++ src/store/job.ts | 4 ++-- src/store/session.ts | 11 +++++++++++ 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/components/BreakdownChart.vue b/src/components/BreakdownChart.vue index 6bf42dc..26ccece 100644 --- a/src/components/BreakdownChart.vue +++ b/src/components/BreakdownChart.vue @@ -5,6 +5,7 @@ import { useJobStore } from "@/store/job.ts"; import { IG6GraphEvent } from "@antv/g6-core/lib/types"; import { useGraphStore } from "@/store/graph.ts"; import { storeToRefs } from "pinia"; +import { Task } from "@/type.ts"; const props = defineProps<{ graphId: string; @@ -50,7 +51,10 @@ onMounted(() => { const node = evt.item; node?.setState("hover", true); const EqNode = graph.value!.find("node", (n) => { - return n.getModel().label === node?.getModel().label; + return ( + (n.getModel().task as Task).name === + (node?.getModel().task as Task).name + ); }); if (EqNode) { graph.value!.setItemState(EqNode, "hover", true); @@ -60,7 +64,10 @@ onMounted(() => { const node = evt.item; node?.setState("hover", false); const EqNode = graph.value!.find("node", (n) => { - return n.getModel().label === node?.getModel().label; + return ( + (n.getModel().task as Task).name === + (node?.getModel().task as Task).name + ); }); if (EqNode) { graph.value!.setItemState(EqNode, "hover", false); diff --git a/src/components/WorkflowChart.vue b/src/components/WorkflowChart.vue index 3835e90..3b3584b 100644 --- a/src/components/WorkflowChart.vue +++ b/src/components/WorkflowChart.vue @@ -11,6 +11,7 @@ import { useTaskStore } from "@/store/task.ts"; import { IG6GraphEvent } from "@antv/g6-core/lib/types"; import { useGraphStore } from "@/store/graph.ts"; import { storeToRefs } from "pinia"; +import { Task } from "@/type.ts"; const props = defineProps<{ graphId: string; @@ -59,8 +60,11 @@ onMounted(() => { const node = evt.item; node?.setState("hover", true); tree.value!.setItemState( - tree.value!.find("node", (node) => { - return node.getModel().label === node?.getModel().label; + tree.value!.find("node", (n) => { + return ( + (n.getModel().task as Task).name === + (node?.getModel().task as Task).name + ); })!, "hover", true, @@ -70,8 +74,11 @@ onMounted(() => { const node = evt.item; node?.setState("hover", false); tree.value!.setItemState( - tree.value!.find("node", (node) => { - return node.getModel().label === node?.getModel().label; + tree.value!.find("node", (n) => { + return ( + (n.getModel().task as Task).name === + (node?.getModel().task as Task).name + ); })!, "hover", false, diff --git a/src/pages/Workflow/components/TopBox.vue b/src/pages/Workflow/components/TopBox.vue index 60e39df..29ddd2f 100644 --- a/src/pages/Workflow/components/TopBox.vue +++ b/src/pages/Workflow/components/TopBox.vue @@ -3,10 +3,13 @@ // console.log("click"); // } import { useRouter } from "vue-router"; +import { useSessionStore } from "@/store/session.ts"; const router = useRouter(); +const sessionStore = useSessionStore(); const go = () => { + sessionStore.$reset(); router.push({ path: "/", replace: true }); }; diff --git a/src/store/job.ts b/src/store/job.ts index ed52b69..0f07a0c 100644 --- a/src/store/job.ts +++ b/src/store/job.ts @@ -8,8 +8,8 @@ export const useJobStore = defineStore("job", () => { let _job: Task; async function updateData(question: string) { - const res = (await fetchJob(question)).data; - // const res = (await fetchJob(`{ "task": "${question}" }`)).data; + // const res = (await fetchJob(question)).data; + const res = (await fetchJob(`{ "task": "${question}" }`)).data; console.debug("res", res); _job = convertData(res.data); diff --git a/src/store/session.ts b/src/store/session.ts index 0597fd3..9075ee5 100644 --- a/src/store/session.ts +++ b/src/store/session.ts @@ -31,10 +31,21 @@ export const useSessionStore = defineStore("session", () => { loading.value = false; } + function $reset() { + Object.assign(session, { + sessionId: generateId(), + sessionName: "", + question: "", + }); + graphShow.value = false; + loading.value = false; + } + return { session, graphShow, loading, chatted, + $reset, }; });