diff --git a/template/uni-app/App.vue b/template/uni-app/App.vue index c863fb258..85cba6b6d 100644 --- a/template/uni-app/App.vue +++ b/template/uni-app/App.vue @@ -23,7 +23,8 @@ } from '@/api/api.js'; import { - getLangJson + getLangJson, + getLangVersion } from '@/api/user.js' import { mapGetters @@ -152,14 +153,19 @@ break } }); - if (!Cache.has('localeSet')) { - getLangJson().then(res => { - Cache.set('locale', Object.keys(res.data)[0]) - uni.setStorageSync('localeJson', res.data); - Cache.set('localeSet', true, 600) // 语言类型缓存时间 - }) - } - + getLangVersion().then(res => { + let version = res.data.version + if (version != uni.getStorageSync('LANG_VERSION')) { + console.log('我变了') + getLangJson().then(res => { + let value = Object.keys(res.data)[0] + Cache.set('locale', Object.keys(res.data)[0]) + this.$i18n.setLocaleMessage(value, res.data[value]); + uni.setStorageSync('localeJson', res.data); + }) + } + uni.setStorageSync('LANG_VERSION', version) + }) // #ifdef APP-PLUS || H5 uni.getSystemInfo({ success: function(res) { diff --git a/template/uni-app/pages/users/user_info/index.vue b/template/uni-app/pages/users/user_info/index.vue index a115ff2e5..8116dc3c2 100644 --- a/template/uni-app/pages/users/user_info/index.vue +++ b/template/uni-app/pages/users/user_info/index.vue @@ -298,7 +298,6 @@ this.$nextTick(e => { this.$i18n.locale = this.array[this.setIndex].value; }) - Cache.set('localeSet', true, 600) }) },