手持机
This commit is contained in:
@@ -8,12 +8,23 @@
|
||||
config: {}
|
||||
},
|
||||
onLaunch: function() {
|
||||
this.initApp()
|
||||
this.initApp(),
|
||||
// 初始化 tabBar 文本
|
||||
this.updateTabBarText()
|
||||
|
||||
// 监听语言变化事件
|
||||
uni.$on('languageChanged', () => {
|
||||
this.updateTabBarText()
|
||||
})
|
||||
},
|
||||
onShow: function() {
|
||||
// 检查应用状态,确保从后台恢复时状态一致
|
||||
this.checkAppState()
|
||||
},
|
||||
onDestroy() {
|
||||
// 移除事件监听器
|
||||
uni.$off('languageChanged')
|
||||
},
|
||||
methods: {
|
||||
// 初始化应用
|
||||
initApp() {
|
||||
@@ -62,6 +73,32 @@
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
updateTabBarText() {
|
||||
// 使用 nextTick 确保 DOM 更新完成
|
||||
this.$nextTick(() => {
|
||||
try {
|
||||
// 设置工作台 tabBar 项
|
||||
uni.setTabBarItem({
|
||||
index: 0,
|
||||
text: this.$t('tabBar.workbench')
|
||||
})
|
||||
|
||||
// 设置任务 tabBar 项
|
||||
uni.setTabBarItem({
|
||||
index: 1,
|
||||
text: this.$t('tabBar.task')
|
||||
})
|
||||
|
||||
// 设置我的 tabBar 项
|
||||
uni.setTabBarItem({
|
||||
index: 2,
|
||||
text: this.$t('tabBar.mine')
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('更新 tabBar 文本失败:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user