Browse Source

设置element国际化

jwyu 1 year ago
parent
commit
654befacd0
3 changed files with 12 additions and 2 deletions
  1. 7 0
      src/main.js
  2. 4 1
      src/views/Home.vue
  3. 1 1
      src/views/sandbox_manage/index_new_version.vue

+ 7 - 0
src/main.js

@@ -15,6 +15,10 @@ import { dataBaseInterface } from '@/api/api.js';
 import { mixins } from "@/mixins";
 import VueI18n from 'vue-i18n';
 import messages from './lang/index';
+import langEN from 'element-ui/lib/locale/lang/en'
+import langZH from 'element-ui/lib/locale/lang/zh-CN'
+import locale from 'element-ui/lib/locale'
+
 Vue.mixin(mixins);
 Vue.use(VueI18n);
 const i18n = new VueI18n({
@@ -27,6 +31,9 @@ Vue.use(ElementUI);
 Vue.use(VueRouter);
 Vue.use(Vuex);
 
+// 设置element语言
+locale.use(localStorage.getItem('i18n')=='zh' ? langZH : langEN)
+
 import{endCalc,optionTimeCalc,init}from'@/utils/TimeOnPage.js';
 
 

+ 4 - 1
src/views/Home.vue

@@ -332,7 +332,9 @@ import EventBus from "@/api/bus.js";
 
 import {recordActiveLoginFun,loginEndCalc} from "@/utils/TimeOnPage.js"
 import NotificationMsg from "../components/notificationMsg.vue";
-
+import langEN from 'element-ui/lib/locale/lang/en'
+import langZH from 'element-ui/lib/locale/lang/zh-CN'
+import locale from 'element-ui/lib/locale'
 export default {
   components: {
     PwdDlg,
@@ -917,6 +919,7 @@ export default {
     // 中英文的切换
     langChangeHandler(){
        this.$i18n.locale =  this.$i18n.locale == 'zh' ? 'en' : 'zh'
+       locale.use(this.$i18n.locale == 'zh' ? langZH : langEN)
        localStorage.setItem('i18n',this.$i18n.locale)
     },
   },

+ 1 - 1
src/views/sandbox_manage/index_new_version.vue

@@ -878,7 +878,7 @@ import { myGraph } from './common/gragh';
         }
       },500),
       deleteHandle(item,type){
-        this.$confirm("确定删除该沙盘图吗?", "提示", {
+        this.$confirm("确定删除该沙盘图吗?", this.$t('Confirm.prompt'), {
           type: "warning",
         })
         .then(() => {