mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 19:10:12 +08:00
5 files changed
+79
-6
No files matched your search
@@ -1,9 +1,66 @@
|
|||||||
<script setup></script>
|
<script setup>
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
|
import sessionManager from '../utils/session'
|
||||||
|
|
||||||
|
const current = ref(-1)
|
||||||
|
watch(sessionManager.hints, (hints) => {
|
||||||
|
current.value = hints.length - 1
|
||||||
|
})
|
||||||
|
|
||||||
|
const left = () => {
|
||||||
|
if (current.value > 0) {
|
||||||
|
current.value -= 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const right = () => {
|
||||||
|
if (current.value < sessionManager.hints.value.length - 1) {
|
||||||
|
current.value += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<font-awesome-icon :icon="['far', 'lightbulb']" class="text-yellow-200 p-1" />
|
<div class="flex flex-wrap">
|
||||||
<h1 class="inline text-text font-xl">Hint</h1>
|
<font-awesome-icon
|
||||||
<div id="hint">
|
:icon="['far', 'lightbulb']"
|
||||||
<p class="text-text">--Hint--</p>
|
class="text-yellow-200 p-2"
|
||||||
|
/>
|
||||||
|
<h1 class="inline text-text font-xl w-7/12 p-2 m-1">Hint</h1>
|
||||||
|
<div v-if="current !== -1">
|
||||||
|
<button
|
||||||
|
class="p-2 m-1 w-1/8"
|
||||||
|
id="Lbutton"
|
||||||
|
@click="left"
|
||||||
|
:disabled="current <= 0"
|
||||||
|
>
|
||||||
|
<font-awesome-icon
|
||||||
|
:icon="['fas', 'arrow-right']"
|
||||||
|
class="text-text"
|
||||||
|
rotation="180"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
<p class="inline text-text font-xl w-1/14 p-2 m-1">{{ current + 1 }}</p>
|
||||||
|
<p class="inline text-text font-xl w-1/14 p-2 m-1">/</p>
|
||||||
|
<p class="inline text-text font-xl w-1/14 p-2 m-1">
|
||||||
|
{{ sessionManager.hints.value.length }}
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
class="p-2 m-1 w-1/8"
|
||||||
|
id="Rbutton"
|
||||||
|
@click="right"
|
||||||
|
:disabled="current === sessionManager.hints.value.length - 1"
|
||||||
|
>
|
||||||
|
<font-awesome-icon :icon="['fas', 'arrow-right']" class="text-text" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="hint" class="bg-background flex flex-wrap">
|
||||||
|
<div class="bg-background h-full rounded-lg p-8 m-1">
|
||||||
|
<p class="inline text-text font-xl font-xl">
|
||||||
|
{{ sessionManager.hints.value[current] }}
|
||||||
|
</p>
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
+3
-1
@@ -12,6 +12,7 @@ import {
|
|||||||
faTerminal,
|
faTerminal,
|
||||||
faArrowRotateLeft,
|
faArrowRotateLeft,
|
||||||
faArrowRightFromBracket,
|
faArrowRightFromBracket,
|
||||||
|
faArrowRight,
|
||||||
} from '@fortawesome/free-solid-svg-icons'
|
} from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -33,5 +34,6 @@ library.add(
|
|||||||
faArrowRotateLeft,
|
faArrowRotateLeft,
|
||||||
faCircleRight,
|
faCircleRight,
|
||||||
faTerminal,
|
faTerminal,
|
||||||
faArrowRightFromBracket
|
faArrowRightFromBracket,
|
||||||
|
faArrowRight
|
||||||
)
|
)
|
||||||
@@ -6,6 +6,7 @@ class SessionManager {
|
|||||||
constructor(questId) {
|
constructor(questId) {
|
||||||
this.questId = questId
|
this.questId = questId
|
||||||
this.session = ref(null)
|
this.session = ref(null)
|
||||||
|
this.hints = ref([])
|
||||||
this.graph = ref(
|
this.graph = ref(
|
||||||
new FileGraph({
|
new FileGraph({
|
||||||
path: '/',
|
path: '/',
|
||||||
@@ -24,6 +25,7 @@ class SessionManager {
|
|||||||
console.log('Update session:', session)
|
console.log('Update session:', session)
|
||||||
this.session.value = session
|
this.session.value = session
|
||||||
this.graph.value = new FileGraph(session.graph)
|
this.graph.value = new FileGraph(session.graph)
|
||||||
|
this.hints.value = session.hints
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGraphUpdate(event) {
|
handleGraphUpdate(event) {
|
||||||
@@ -35,6 +37,11 @@ class SessionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleHintUpdate(event) {
|
||||||
|
console.log(event)
|
||||||
|
this.hints.value = [...this.hints.value, ...event]
|
||||||
|
}
|
||||||
|
|
||||||
setTasks(tasks) {
|
setTasks(tasks) {
|
||||||
this.session.value.tasks = tasks
|
this.session.value.tasks = tasks
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ onMounted(async () => {
|
|||||||
socket.on('graph', (event) => {
|
socket.on('graph', (event) => {
|
||||||
sessionManager.handleGraphUpdate(event)
|
sessionManager.handleGraphUpdate(event)
|
||||||
})
|
})
|
||||||
|
socket.on('hints', (event) => {
|
||||||
|
sessionManager.handleHintUpdate(event)
|
||||||
|
})
|
||||||
socket.on('tasks', (tasks) => {
|
socket.on('tasks', (tasks) => {
|
||||||
sessionManager.setTasks(tasks)
|
sessionManager.setTasks(tasks)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -91,6 +91,10 @@ async function connect(sessionId, cookie) {
|
|||||||
debug('receive graph:', data)
|
debug('receive graph:', data)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
socket.on('hints', (data) => {
|
||||||
|
debug('receive hints:', data)
|
||||||
|
})
|
||||||
|
|
||||||
socket.on('tasks', (data) => {
|
socket.on('tasks', (data) => {
|
||||||
debug('receive tasks:', data)
|
debug('receive tasks:', data)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user