diff --git a/Build_God_Game/src/views/GameView.vue b/Build_God_Game/src/views/GameView.vue index 5afb82a..e4d84d2 100644 --- a/Build_God_Game/src/views/GameView.vue +++ b/Build_God_Game/src/views/GameView.vue @@ -75,10 +75,20 @@ const navigateTo = (item: { label: string }) => { } else if (item.label === '捡垃圾') { router.push('/scrap') } else if (item.label === '角色') { - showCharacterDetail.value = true + openCharacterDetail() } } +const openCharacterDetail = async () => { + await characterStore.fetchCharacters() + const current = characterStore.characters.find(c => c.id === characterStore.currentCharacter?.id) + if (current) { + characterStore.currentCharacter = current + localStorage.setItem('current_character', JSON.stringify(current)) + } + showCharacterDetail.value = true +} + const handleBreakthrough = async () => { const result = await characterStore.breakthrough() breakthroughMessage.value = result.message diff --git a/Build_God_Game/src/views/ScrapView.vue b/Build_God_Game/src/views/ScrapView.vue index 24dd5d1..48fa9ac 100644 --- a/Build_God_Game/src/views/ScrapView.vue +++ b/Build_God_Game/src/views/ScrapView.vue @@ -44,11 +44,16 @@ const startScanning = async () => { }, 1000) } -const performScan = async () => { + const performScan = async () => { try { const result = await scrapApi.scanScrap(characterId.value) scanResult.value = result await characterStore.fetchCharacters() + const updatedChar = characterStore.characters.find(c => c.id === characterId.value) + if (updatedChar) { + characterStore.currentCharacter = updatedChar + localStorage.setItem('current_character', JSON.stringify(updatedChar)) + } } catch (error: unknown) { errorMessage.value = error instanceof Error ? error.message : String(error) } finally {