mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 19:40:11 +08:00
add start button
- new stage will load previous stored data at first
This commit is contained in:
1 parent
3848ca6941
commit
0b136a830a
4 files changed
+87
-25
No files matched your search
@@ -0,0 +1,51 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useToast } from 'vue-toastification'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { init } from '../../store/session'
|
||||||
|
import { LoadQuestError, LoadSessionError } from '../../utils/errors'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
questId: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const toast = useToast()
|
||||||
|
const showCover = ref(true)
|
||||||
|
const startSession = async () => {
|
||||||
|
showCover.value = false
|
||||||
|
try {
|
||||||
|
await init(props.questId)
|
||||||
|
} catch (err: any) {
|
||||||
|
if (err instanceof LoadQuestError) {
|
||||||
|
toast.error(`無法讀取關卡: ${err.questId},請確認網頁連結。`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (err instanceof LoadSessionError) {
|
||||||
|
toast.error(`無法建立工作階段: ${err.questId},請重新登入再試一次。`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.error(err)
|
||||||
|
toast.error(err.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="showCover"
|
||||||
|
class="bg-bg-secondary h-full w-1/2 fixed bg-opacity-50 flex justify-center items-center"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
id="start"
|
||||||
|
class="bg-bg-secondary rounded-lg p-3"
|
||||||
|
@click="startSession"
|
||||||
|
>
|
||||||
|
<font-awesome-icon
|
||||||
|
:icon="['fas', 'play']"
|
||||||
|
class="text-text-primary h-full px-3"
|
||||||
|
/>
|
||||||
|
<p class="text-text-primary inline ml-1 md:flex">開始</p>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
+3
-1
@@ -19,6 +19,7 @@ import {
|
|||||||
faTrophy,
|
faTrophy,
|
||||||
faFileInvoice,
|
faFileInvoice,
|
||||||
faEnvelope,
|
faEnvelope,
|
||||||
|
faPlay,
|
||||||
} from '@fortawesome/free-solid-svg-icons'
|
} from '@fortawesome/free-solid-svg-icons'
|
||||||
import {
|
import {
|
||||||
faLightbulb,
|
faLightbulb,
|
||||||
@@ -54,5 +55,6 @@ library.add(
|
|||||||
faGoogle,
|
faGoogle,
|
||||||
faFileInvoice,
|
faFileInvoice,
|
||||||
faFacebook,
|
faFacebook,
|
||||||
faEnvelope
|
faEnvelope,
|
||||||
|
faPlay
|
||||||
)
|
)
|
||||||
@@ -46,7 +46,7 @@ class SocketTerminal {
|
|||||||
|
|
||||||
mount(reference: HTMLElement): void {
|
mount(reference: HTMLElement): void {
|
||||||
this.term.open(reference)
|
this.term.open(reference)
|
||||||
this.term.focus()
|
// this.term.focus()
|
||||||
this.resizeScreen()
|
this.resizeScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+32
-23
@@ -1,7 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { useToast } from 'vue-toastification'
|
// import { onMounted } from 'vue'
|
||||||
import sessionStore, { init } from '../store/session'
|
// import { useToast } from 'vue-toastification'
|
||||||
|
import sessionStore from '../store/session'
|
||||||
|
// import { init } from '../store/session'
|
||||||
import HeaderPart from '../components/header/HeaderPart.vue'
|
import HeaderPart from '../components/header/HeaderPart.vue'
|
||||||
import GameHeaderComponents from '../components/header/GameHeaderComponents.vue'
|
import GameHeaderComponents from '../components/header/GameHeaderComponents.vue'
|
||||||
// import CommandlistPart from '../components/CommandlistPart.vue'
|
// import CommandlistPart from '../components/CommandlistPart.vue'
|
||||||
@@ -11,37 +13,43 @@ import TerminalPart from '../components/game/TerminalPart.vue'
|
|||||||
import VisualizationPart from '../components/game/VisualizationPart.vue'
|
import VisualizationPart from '../components/game/VisualizationPart.vue'
|
||||||
import ControlPalette from '../components/game/ControlPalette.vue'
|
import ControlPalette from '../components/game/ControlPalette.vue'
|
||||||
import CompleteModal from '../components/game/CompleteModal.vue'
|
import CompleteModal from '../components/game/CompleteModal.vue'
|
||||||
import { LoadQuestError, LoadSessionError } from '../utils/errors'
|
// import { LoadQuestError, LoadSessionError } from '../utils/errors'
|
||||||
|
import StartButton from '../components/game/StartButton.vue'
|
||||||
|
|
||||||
const completed = computed(() => {
|
const completed = computed(() => {
|
||||||
return sessionStore.session.status === 'finished'
|
return sessionStore.session.status === 'finished'
|
||||||
})
|
})
|
||||||
|
|
||||||
const props = defineProps({
|
// const props = defineProps({
|
||||||
|
// questId: {
|
||||||
|
// type: String,
|
||||||
|
// required: true,
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
defineProps({
|
||||||
questId: {
|
questId: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
// const toast = useToast()
|
||||||
|
|
||||||
const toast = useToast()
|
// onMounted(async () => {
|
||||||
|
// try {
|
||||||
onMounted(async () => {
|
// await init(props.questId)
|
||||||
try {
|
// } catch (err: any) {
|
||||||
await init(props.questId)
|
// if (err instanceof LoadQuestError) {
|
||||||
} catch (err: any) {
|
// toast.error(`無法讀取關卡: ${err.questId},請確認網頁連結。`)
|
||||||
if (err instanceof LoadQuestError) {
|
// return
|
||||||
toast.error(`無法讀取關卡: ${err.questId},請確認網頁連結。`)
|
// }
|
||||||
return
|
// if (err instanceof LoadSessionError) {
|
||||||
}
|
// toast.error(`無法建立工作階段: ${err.questId},請重新登入再試一次。`)
|
||||||
if (err instanceof LoadSessionError) {
|
// return
|
||||||
toast.error(`無法建立工作階段: ${err.questId},請重新登入再試一次。`)
|
// }
|
||||||
return
|
// console.error(err)
|
||||||
}
|
// toast.error(err.message)
|
||||||
console.error(err)
|
// }
|
||||||
toast.error(err.message)
|
// })
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -72,6 +80,7 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
<!-- Terminal and Hint -->
|
<!-- Terminal and Hint -->
|
||||||
<div class="bg-bg h-full rounded-lg w-1/2">
|
<div class="bg-bg h-full rounded-lg w-1/2">
|
||||||
|
<StartButton :questId="$props.questId" />
|
||||||
<section id="hint" class="h-3/5">
|
<section id="hint" class="h-3/5">
|
||||||
<HintPart />
|
<HintPart />
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in new issue
Block a user