From-wh 2 лет назад
Родитель
Сommit
dfbe4047f9
2 измененных файлов с 15 добавлено и 10 удалено
  1. 15 9
      template/uni-app/App.vue
  2. 0 1
      template/uni-app/pages/users/user_info/index.vue

+ 15 - 9
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) {

+ 0 - 1
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)
 				})
 			},