fix: socket & terminal states across quests

This commit is contained in:
wancat committed 2024-06-27 12:04:35 +08:00
1 parent 3398d18055
commit 94ef3749f5
2 files changed
+4

No files matched your search

+3
View File
@@ -8,6 +8,7 @@ import { Session, StageResponse } from '../types'
const socket = new Socket()
const term = new SocketTerminal(40, 80)
let hasSetup = false
interface Store {
session: Session | null
@@ -65,6 +66,7 @@ const useSession = defineStore('session', {
this.$reset()
},
setup() {
if (hasSetup) return
socket.on('terminal', (data: string) => {
term.write(data)
})
@@ -77,6 +79,7 @@ const useSession = defineStore('session', {
socket.on('response', (response: StageResponse) => {
this.newResponse(response)
})
hasSetup = true
},
setStatus(status: string) {
if (!this.session) return
+1
View File
@@ -29,6 +29,7 @@ const props = defineProps({
})
onMounted(async () => {
sessionStore.reset()
sessionStore.setup()
await sessionStore.setQuest(props.questId)
await sessionStore.getActiveSession()