1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<template>
  <transition name="el-fade-in-linear">
    <router-view/>
  </transition>
</template>
 
<script>
import Cookies from 'js-cookie'
import {messages} from '../packages/i18n'
 
export default {
  watch: {
    '$i18n.locale': 'i18nHandle'
  },
  created() {
    this.i18nHandle(this.$i18n.locale)
 
    let body = document.querySelector('body')
 
    body.className += ' '+ this.$store.state.theme
  },
  methods: {
    i18nHandle(val, oldVal) {
      Cookies.set('language', val)
      document.querySelector('html').setAttribute('lang', val)
 
      // 可以在这里修改国际化显示名称
      messages[val].brand.lg = '可靠性仿真评估及评定'
      messages[val].company.name = '单位名称'
      messages[val].company.code = '单位代码'
      messages[val].company.shortName = '单位简称'
      messages[val].company.type = '单位类型'
      messages[val].company.sort = '排序'
      messages[val].company.parentCompany = '上级单位'
 
      document.title = messages[val].brand.lg
      // 非登录页面,切换语言刷新页面
      if (this.$route.name !== 'login' && oldVal) {
        window.location.reload()
      }
    }
  }
}
</script>
<style>
/*.el-table .cell{*/
/*white-space: inherit;*/
/*}*/
</style>