mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
feat: use dynamic route to select quest (no error handling yet)
This commit is contained in:
1 parent
cce6127d51
commit
f973982ec4
3 files changed
+13
-19
No files matched your search
@@ -1,10 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from 'vue'
|
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { logout } from '../utils/auth'
|
import { logout } from '../utils/auth'
|
||||||
import { bugReportUrl } from '../config'
|
import { bugReportUrl } from '../config'
|
||||||
import api from '../utils/api'
|
import sessionStore, { reset } from '../store/session'
|
||||||
import { reset } from '../store/session'
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
@@ -17,18 +15,6 @@ const handleLogout = async () => {
|
|||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const questData = ref(null)
|
|
||||||
const questErr = ref(null)
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
try {
|
|
||||||
const res = await api.get('/quests/helloworld')
|
|
||||||
questData.value = res.data
|
|
||||||
} catch (err) {
|
|
||||||
questErr.value = err
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -50,9 +36,9 @@ onMounted(async () => {
|
|||||||
<button>
|
<button>
|
||||||
<p
|
<p
|
||||||
class="text-text-primary inline-block font-bold whitespace-nowrap"
|
class="text-text-primary inline-block font-bold whitespace-nowrap"
|
||||||
v-if="questData"
|
v-if="sessionStore.quest"
|
||||||
>
|
>
|
||||||
{{ questData.title }}
|
{{ sessionStore.quest.title }}
|
||||||
</p>
|
</p>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+2
-1
@@ -23,9 +23,10 @@ const routes = [
|
|||||||
meta: { requiresGuest: true },
|
meta: { requiresGuest: true },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/game',
|
path: '/game/:questId',
|
||||||
name: 'game',
|
name: 'game',
|
||||||
component: GamePage,
|
component: GamePage,
|
||||||
|
props: true,
|
||||||
meta: { requiresAuth: true },
|
meta: { requiresAuth: true },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,8 +14,15 @@ const completed = computed(() => {
|
|||||||
return sessionStore.session.status === 'finished'
|
return sessionStore.session.status === 'finished'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
questId: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await init('helloworld')
|
await init(props.questId)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user