liqk 3 роки тому
батько
коміт
b1c4b0b771

+ 2 - 0
TEAMModelOS/ClientApp/src/boot-app.js

@@ -49,6 +49,8 @@ import fabric from 'fabric'
 import VideoPlayer from 'vue-video-player'
 import NewChooseContent from '@/components/selflearn/NewChooseContent'
 
+
+jsFn.setLocalLang()
 require('video.js/dist/video-js.css')
 require('vue-video-player/src/custom-theme.css')
 // 图片预览组件

+ 2 - 6
TEAMModelOS/ClientApp/src/locale/index.js

@@ -1,15 +1,11 @@
 import Vue from 'vue'
 import VueI18n from 'vue-i18n'
+import jsFn from '@/utils/js-fn.js'
 import tools from '@/utils/public.js'
 import ElementLocale from 'element-ui/lib/locale'
 ElementLocale.i18n((key, value) => i18n.t(key, value))
 Vue.use(VueI18n)
-// 自动根据浏览器系统语言设置语言(优先判断本地设置的语言,如果有则使用本地设置的语言,如果没有则使用浏览器系统语言)
-const curLang = localStorage.getItem('cloudSetting') ? JSON.parse(localStorage.getItem('cloudSetting')).curLang : null
-const navLang = curLang || navigator.language.toLowerCase()
-const localLang = (navLang === 'zh' || navLang === 'zh-tw' || navLang === 'zh-cn' || navLang === 'zh-hk') ? navLang : false
-let lang = localLang || 'en-us'
-localStorage.setItem('local', lang)
+let lang = jsFn.setLocalLang()
 Vue.config.lang = lang
 Vue.locale = () => { }
 const i18n = new VueI18n({

+ 12 - 1
TEAMModelOS/ClientApp/src/utils/js-fn.js

@@ -430,6 +430,16 @@ function getBlobInfo(scope) {
     }
 }
 
+function setLocalLang() {
+    // 自动根据浏览器系统语言设置语言(优先判断本地设置的语言,如果有则使用本地设置的语言,如果没有则使用浏览器系统语言)
+    const curLang = localStorage.getItem('cloudSetting') ? JSON.parse(localStorage.getItem('cloudSetting')).curLang : null
+    const navLang = curLang || navigator.language.toLowerCase()
+    const localLang = (navLang === 'zh' || navLang === 'zh-tw' || navLang === 'zh-cn' || navLang === 'zh-hk') ? navLang : false
+    let lang = localLang || 'en-us'
+    localStorage.setItem('local', lang)
+    return lang
+}
+
 export default {
     groupBy,
     isObjEqual,
@@ -453,5 +463,6 @@ export default {
     checkJinNiu,
     checkTrain,
     handleStudentAnswer,
-    getBlobInfo
+    getBlobInfo,
+    setLocalLang
 }