mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
fix: socket & terminal states across quests
This commit is contained in:
1 parent
3398d18055
commit
94ef3749f5
2 files changed
+4
No files matched your search
@@ -8,6 +8,7 @@ import { Session, StageResponse } from '../types'
|
|||||||
|
|
||||||
const socket = new Socket()
|
const socket = new Socket()
|
||||||
const term = new SocketTerminal(40, 80)
|
const term = new SocketTerminal(40, 80)
|
||||||
|
let hasSetup = false
|
||||||
|
|
||||||
interface Store {
|
interface Store {
|
||||||
session: Session | null
|
session: Session | null
|
||||||
@@ -65,6 +66,7 @@ const useSession = defineStore('session', {
|
|||||||
this.$reset()
|
this.$reset()
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
if (hasSetup) return
|
||||||
socket.on('terminal', (data: string) => {
|
socket.on('terminal', (data: string) => {
|
||||||
term.write(data)
|
term.write(data)
|
||||||
})
|
})
|
||||||
@@ -77,6 +79,7 @@ const useSession = defineStore('session', {
|
|||||||
socket.on('response', (response: StageResponse) => {
|
socket.on('response', (response: StageResponse) => {
|
||||||
this.newResponse(response)
|
this.newResponse(response)
|
||||||
})
|
})
|
||||||
|
hasSetup = true
|
||||||
},
|
},
|
||||||
setStatus(status: string) {
|
setStatus(status: string) {
|
||||||
if (!this.session) return
|
if (!this.session) return
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
sessionStore.reset()
|
||||||
sessionStore.setup()
|
sessionStore.setup()
|
||||||
await sessionStore.setQuest(props.questId)
|
await sessionStore.setQuest(props.questId)
|
||||||
await sessionStore.getActiveSession()
|
await sessionStore.getActiveSession()
|
||||||
|
|||||||
Reference in new issue
Block a user