feat:国际化多语言适配
This commit is contained in:
@@ -8,11 +8,39 @@
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
|
||||
// 注意:语言初始化已移至 main.js,确保每次 reLaunch 都能正确加载新语言
|
||||
},
|
||||
onShow: async function() {
|
||||
// 手动登录模式:不再自动登录
|
||||
// 如需保留可开关逻辑,可在此读取配置决定是否执行 autoLogin
|
||||
console.log('========================================')
|
||||
console.log('=== App onShow 被调用 ===')
|
||||
console.log('时间戳:', new Date().toLocaleTimeString())
|
||||
|
||||
// 检查并更新语言(uni.reLaunch 会触发 onShow)
|
||||
try {
|
||||
const savedLang = uni.getStorageSync('language')
|
||||
console.log('App onShow - 缓存中的语言:', savedLang)
|
||||
|
||||
// 获取当前 i18n 实例并检查语言
|
||||
if (this.$i18n) {
|
||||
const currentLocale = this.$i18n.locale
|
||||
console.log('App onShow - 当前 i18n locale:', currentLocale)
|
||||
|
||||
if (savedLang && savedLang !== currentLocale) {
|
||||
console.log('=== App onShow 检测到语言变化 ===')
|
||||
console.log('旧语言:', currentLocale)
|
||||
console.log('新语言:', savedLang)
|
||||
|
||||
// 强制更新语言
|
||||
this.$i18n.locale = savedLang
|
||||
console.log('App onShow - 语言已更新为:', this.$i18n.locale)
|
||||
console.log('App onShow - 测试翻译:', this.$t('common.loading'))
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('App onShow - 语言检查失败:', e)
|
||||
}
|
||||
|
||||
console.log('========================================')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
|
||||
Reference in New Issue
Block a user