mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
load quest info before start
This commit is contained in:
1 parent
0b136a830a
commit
ea2ba2c7a0
2 files changed
+10
-9
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useToast } from 'vue-toastification'
|
import { useToast } from 'vue-toastification'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { init } from '../../store/session'
|
import { init, setQuest } from '../../store/session'
|
||||||
import { LoadQuestError, LoadSessionError } from '../../utils/errors'
|
import { LoadQuestError, LoadSessionError } from '../../utils/errors'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -13,6 +13,7 @@ const props = defineProps({
|
|||||||
|
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const showCover = ref(true)
|
const showCover = ref(true)
|
||||||
|
setQuest(props.questId)
|
||||||
const startSession = async () => {
|
const startSession = async () => {
|
||||||
showCover.value = false
|
showCover.value = false
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ const store = reactive<Store>({
|
|||||||
const socket = new Socket()
|
const socket = new Socket()
|
||||||
const term = new SocketTerminal(40, 80)
|
const term = new SocketTerminal(40, 80)
|
||||||
|
|
||||||
function setQuest(questId: string) {
|
export function setQuest(questId: string) {
|
||||||
return api.get(`/quests/${questId}`).then((res) => {
|
return api.get(`/quests/${questId}`).then((res) => {
|
||||||
store.questId = res.data._id
|
store.questId = res.data._id
|
||||||
store.quest = res.data
|
store.quest = res.data
|
||||||
@@ -121,13 +121,13 @@ export function reset() {
|
|||||||
|
|
||||||
export async function init(questId: string) {
|
export async function init(questId: string) {
|
||||||
if (!questId) throw new Error('No quest ID provided')
|
if (!questId) throw new Error('No quest ID provided')
|
||||||
reset()
|
// reset()
|
||||||
try {
|
// try {
|
||||||
await setQuest(questId)
|
// await setQuest(questId)
|
||||||
} catch (err) {
|
// } catch (err) {
|
||||||
console.error(err)
|
// console.error(err)
|
||||||
throw new LoadQuestError('Failed to load quest', questId)
|
// throw new LoadQuestError('Failed to load quest', questId)
|
||||||
}
|
// }
|
||||||
try {
|
try {
|
||||||
await getActiveSession(questId)
|
await getActiveSession(questId)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in new issue
Block a user