Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 游戏结束会回到首页 #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: 返回主菜单后状态清零
close #14
  • Loading branch information
smallp committed Jul 20, 2022
commit 75bc896188a349466f3670ddf8338f8e92224f51
5 changes: 4 additions & 1 deletion packages/client/components/internals/AdvGame.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { AdvAst, AdvConfig, Tachie } from '@advjs/types'

import { useBeforeUnload } from '@advjs/client/composables'
import { computed, ref } from 'vue'
import { computed, onUnmounted, ref } from 'vue'
import { getCharacter } from '@advjs/core'
import { useAppStore } from '~/stores/app'

Expand Down Expand Up @@ -44,6 +44,9 @@ const tachies = computed(() => {

return tachiesMap
})
onUnmounted(() => {
$adv.store.reset()
})
</script>

<template>
Expand Down
4 changes: 2 additions & 2 deletions packages/client/setup/adv/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const useAdvStore = defineStore('adv', () => {
],
})

const curState = ref<CurStateType>(defaultState)
const curState = ref<CurStateType>(Object.assign({}, defaultState))

const curNode = computed((): AdvAst.Item | undefined => {
if (ast.value && ast.value.children.length > 0 && curState.value.order < ast.value.children.length)
Expand All @@ -92,7 +92,7 @@ export const useAdvStore = defineStore('adv', () => {
curState.value.dialog = curNode.value
})
const reset = () => {
curState.value = defaultState
curState.value = Object.assign({}, defaultState)
}

return {
Expand Down