mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
feat: send response to frontend
This commit is contained in:
1 parent
fb69cb4e10
commit
88ee8f2cc3
8 files changed
+46
-35
No files matched your search
+16
-11
@@ -20,6 +20,7 @@ function newSession() {
|
||||
pwd: '',
|
||||
hints: [],
|
||||
tasks: [],
|
||||
responses: [],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +42,7 @@ function setQuest(questId) {
|
||||
|
||||
async function setSession(session) {
|
||||
try {
|
||||
console.log('Setting session...', session)
|
||||
store.session = session
|
||||
store.session.graph = new FileGraph(session.graph)
|
||||
term.reset()
|
||||
@@ -85,18 +87,18 @@ function updateGraph(event) {
|
||||
}
|
||||
}
|
||||
|
||||
function updateHints(hints) {
|
||||
store.session.hints.push(hints)
|
||||
function newResponse(response) {
|
||||
console.log('newResponse', response, 'session', store.session)
|
||||
store.session.responses.push(response.responses)
|
||||
store.session.hints.push(response.hints)
|
||||
store.session.tasks = response.tasks
|
||||
store.session.status = response.status
|
||||
}
|
||||
|
||||
function updateStatus(status) {
|
||||
store.session.status = status
|
||||
}
|
||||
|
||||
function setTasks(tasks) {
|
||||
store.session.tasks = tasks
|
||||
}
|
||||
|
||||
export function useTerminal() {
|
||||
return term
|
||||
}
|
||||
@@ -135,11 +137,14 @@ function setup() {
|
||||
socket.on('graph', (event) => {
|
||||
updateGraph(event)
|
||||
})
|
||||
socket.on('hints', (event) => {
|
||||
updateHints(event)
|
||||
})
|
||||
socket.on('tasks', (tasks) => {
|
||||
setTasks(tasks)
|
||||
// socket.on('hints', (event) => {
|
||||
// updateHints(event)
|
||||
// })
|
||||
// socket.on('tasks', (tasks) => {
|
||||
// setTasks(tasks)
|
||||
// })
|
||||
socket.on('response', (response) => {
|
||||
newResponse(response)
|
||||
})
|
||||
socket.on('status', (event) => {
|
||||
updateStatus(event)
|
||||
|
||||
@@ -72,13 +72,13 @@ onMounted(async () => {
|
||||
</div>
|
||||
<!-- Terminal and Hint -->
|
||||
<div class="bg-bg h-full w-1/3 rounded-lg">
|
||||
<section id="terminal" class="h-3/5 overflow-hidden">
|
||||
<TerminalPart />
|
||||
</section>
|
||||
<hr class="border-border border" />
|
||||
<section id="hint" class="h-2/5">
|
||||
<HintPart />
|
||||
</section>
|
||||
<hr class="border-border border" />
|
||||
<section id="terminal" class="h-3/5 overflow-hidden">
|
||||
<TerminalPart />
|
||||
</section>
|
||||
</div>
|
||||
<!-- Visualization -->
|
||||
<div class="h-full w-1/3">
|
||||
|
||||
Reference in new issue
Block a user