Browse Source

不用退出到角色选择界面就能刷新人物属性

master
秦汉 1 month ago
parent
commit
39d0958a2b
  1. 12
      Build_God_Game/src/views/GameView.vue
  2. 7
      Build_God_Game/src/views/ScrapView.vue

12
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

7
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 {

Loading…
Cancel
Save