From dfbe4047f970646ed4114e26f11367c4a2f8b542 Mon Sep 17 00:00:00 2001 From: From-wh Date: Mon, 6 Mar 2023 15:43:37 +0800 Subject: [PATCH] =?UTF-8?q?improve:=20=E8=AF=AD=E8=A8=80=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/uni-app/App.vue | 24 ++++++++++++------- .../uni-app/pages/users/user_info/index.vue | 1 - 2 files changed, 15 insertions(+), 10 deletions(-) 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) }) },