feat: send response to frontend

This commit is contained in:
wancat committed 2024-02-29 10:54:53 +08:00
1 parent fb69cb4e10
commit 88ee8f2cc3
8 files changed
+46 -35

No files matched your search

+5 -13
View File
@@ -8,12 +8,12 @@ import type {
IStage,
ITask,
} from '@linux-odyssey/models'
import { pushToSession } from '../api/socket.js'
export interface ExecuteResult {
responses: IResponse[]
hints: string[]
callback: () => void
tasks?: ITask[]
status: string
stage?: string
end?: boolean
}
@@ -82,12 +82,8 @@ export default class SessionHandler {
return {
responses: stage.responses,
hints: stage.hints,
callback: () => {
pushToSession(this.session.id, 'tasks', this.session.tasks)
if (stage.hints && stage.hints.length > 0)
pushToSession(this.session.id, 'hints', stage.hints)
pushToSession(this.session.id, 'status', this.session.status)
},
tasks: this.session.tasks,
status: this.session.status,
}
}
@@ -98,11 +94,7 @@ export default class SessionHandler {
return {
responses,
hints,
callback: () => {
if (hints && hints.length > 0)
pushToSession(this.session.id, 'hints', hints)
pushToSession(this.session.id, 'status', this.session.status)
},
status: this.session.status,
}
}
}