Skip to content

Commit

Permalink
fix: capability to highlight corresponding nodes at the same time.
Browse files Browse the repository at this point in the history
feat(session): reset store when backing to home page
  • Loading branch information
martsimq committed Jul 19, 2024
1 parent fbf85eb commit aed77fb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
11 changes: 9 additions & 2 deletions src/components/BreakdownChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
15 changes: 11 additions & 4 deletions src/components/WorkflowChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/Workflow/components/TopBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
};
</script>
Expand Down
4 changes: 2 additions & 2 deletions src/store/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
11 changes: 11 additions & 0 deletions src/store/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
});

0 comments on commit aed77fb

Please sign in to comment.