From bb2a1a145f1a63d0bb70743309f63f815617eebd Mon Sep 17 00:00:00 2001 From: wancat Date: Thu, 28 Mar 2024 20:55:40 +0800 Subject: [PATCH] refactor: move interfaces to types.ts --- app/src/components/QuestPart.vue | 7 +------ app/src/store/session.ts | 11 ++--------- app/src/types.ts | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 app/src/types.ts diff --git a/app/src/components/QuestPart.vue b/app/src/components/QuestPart.vue index f4cae70..0e567be 100644 --- a/app/src/components/QuestPart.vue +++ b/app/src/components/QuestPart.vue @@ -2,12 +2,7 @@ import { computed } from 'vue' import MarkdownText from './MarkdownText.vue' import sessionStore from '../store/session' - -interface Task { - id: number - name: string - completed: boolean -} +import { Task } from '../types' const tasks = computed(() => { return sessionStore.session.tasks.map((task: Task) => { diff --git a/app/src/store/session.ts b/app/src/store/session.ts index 66946e1..1223f88 100644 --- a/app/src/store/session.ts +++ b/app/src/store/session.ts @@ -7,6 +7,7 @@ import api from '../utils/api' import Socket from '../utils/socket' import SocketTerminal from '../utils/terminal' import { LoadQuestError, LoadSessionError } from '../utils/errors' +import { Session } from '../types' const toast = useToast() @@ -26,21 +27,13 @@ function newSession() { } } -interface Session { - status: string - graph: FileGraph - pwd: string - hints: string[] - tasks: string[] -} - interface Store { session: Session questId: string quest: IQuest | null } -const store: Store = reactive({ +const store = reactive({ session: newSession(), questId: '', quest: null, diff --git a/app/src/types.ts b/app/src/types.ts new file mode 100644 index 0000000..853ef95 --- /dev/null +++ b/app/src/types.ts @@ -0,0 +1,15 @@ +import { FileGraph } from '@linux-odyssey/file-graph' + +export interface Task { + id: number + name: string + completed: boolean +} + +export interface Session { + status: string + graph: FileGraph + pwd: string + hints: string[] + tasks: Task[] +}