feat: load session and display start button if not exists

This commit is contained in:
wancat committed 2024-06-27 11:55:34 +08:00
1 parent c64043316e
commit 3398d18055
7 files changed
+51 -56

No files matched your search

+2 -17
View File
@@ -1,31 +1,16 @@
<script setup lang="ts">
import { useToast } from 'vue-toastification'
import { onMounted, ref } from 'vue'
import { computed } from 'vue'
import useSession from '../../store/session'
const props = defineProps({
questId: {
type: String,
required: true,
},
})
const toast = useToast()
const showCover = ref(true)
const sessionStore = useSession()
onMounted(async () => {
sessionStore.setQuest(props.questId)
if (await sessionStore.getActiveSession()) {
showCover.value = false
}
sessionStore.setup()
})
const showCover = computed(() => sessionStore.session === null)
const startSession = async () => {
try {
await sessionStore.createSession()
showCover.value = false
} catch (err: any) {
console.error(err)
toast.error(err.message)