48 lines
1.7 KiB
JavaScript
48 lines
1.7 KiB
JavaScript
export default {
|
|
data() {
|
|
return {
|
|
growthModalVisible: false,
|
|
growthModalTitle: '',
|
|
growthModalMessage: '',
|
|
growthModalIcon: '',
|
|
growthModalConfirmText: '太棒了!',
|
|
growthModalCallback: null
|
|
}
|
|
},
|
|
methods: {
|
|
showGrowthModal(growth) {
|
|
this.showGrowthModalWithCallback(growth, null)
|
|
},
|
|
showGrowthModalWithCallback(growth, callback) {
|
|
this.growthModalCallback = callback
|
|
if (growth.levelUp) {
|
|
const privilegesText = growth.newPrivileges && growth.newPrivileges.length
|
|
? '\n解锁特权:' + growth.newPrivileges.join('、')
|
|
: ''
|
|
this.growthModalTitle = '🎉 恭喜升级!'
|
|
this.growthModalMessage = `等级:Lv.${growth.oldLevel || growth.currentLevel - 1} → Lv.${growth.currentLevel}\n称号:${growth.levelTitle || '暂无'}\n获得经验:+${growth.expGained || 0} EXP${privilegesText}`
|
|
this.growthModalIcon = '🎉'
|
|
this.growthModalConfirmText = '太棒了!'
|
|
this.growthModalVisible = true
|
|
} else if (growth.newAchievements && growth.newAchievements.length > 0) {
|
|
const ach = growth.newAchievements[0]
|
|
this.growthModalTitle = '🏆 获得成就!'
|
|
this.growthModalMessage = `${ach.name || ''}\n${ach.description || ''}\n稀有度:${ach.rarityName || '初级'}\n获得经验:+${ach.expReward || 0} EXP`
|
|
this.growthModalIcon = ach.icon || '🏆'
|
|
this.growthModalConfirmText = '太棒了!'
|
|
this.growthModalVisible = true
|
|
} else {
|
|
if (typeof callback === 'function') {
|
|
callback()
|
|
}
|
|
}
|
|
},
|
|
onGrowthModalClose() {
|
|
this.growthModalVisible = false
|
|
if (typeof this.growthModalCallback === 'function') {
|
|
this.growthModalCallback()
|
|
this.growthModalCallback = null
|
|
}
|
|
}
|
|
}
|
|
} |