增加i18n国际化配置

This commit is contained in:
ival 2019-08-08 11:29:03 +08:00
parent d014007d25
commit c66d72a049
9 changed files with 119 additions and 63 deletions

View File

@ -29,6 +29,7 @@
"stompjs": "^2.3.3",
"storejs": "^1.0.25",
"vue": "2.6.10",
"vue-i18n": "^8.12.0",
"vue-router": "3.0.6",
"vuedraggable": "^2.20.0",
"vuex": "3.1.0",

View File

@ -7,5 +7,6 @@
<script>
export default {
name: 'App'
}
};
</script>

7
src/i18n/index.js Normal file
View File

@ -0,0 +1,7 @@
import en from 'en';
import zh from 'zh';
export default {
en,
zh
};

5
src/i18n/langs/en.js Normal file
View File

@ -0,0 +1,5 @@
import enLocale from 'element-ui/lib/locale/lang/en';
export default {
...enLocale
};

5
src/i18n/langs/zh.js Normal file
View File

@ -0,0 +1,5 @@
import cnLocale from 'element-ui/lib/locale/lang/zh-CN';
export default {
...cnLocale
};

View File

@ -9,25 +9,37 @@ import 'element-ui/lib/theme-chalk/index.css';
import '@/styles/index.scss'; // global css
import Theme from '@/jmap/theme/factory';
import LangStorage from '@/utils/lang';
import App from './App';
import VueI18n from 'vue-i18n';
import store from './store';
import router from './router';
import Theme from '@/jmap/theme/factory';
import '@/icons'; // icon
import '@/permission'; // permission control
import '@/scripts/GlobalPlugin';
import '@/directives';
import messages from '@/i18n/index';
window.THREE = require('@/jlmap3d/main/three.min.js');
window.zlib = require('@/jlmap3d/main/inflate.min.js');
Vue.use(ElementUI);
Vue.use(VueI18n);
Vue.config.productionTip = false;
const i18n = new VueI18n({
locale: LangStorage.getLang('zh'),
messages
});
new Vue({
el: '#app',
router,
store,
i18n,
render: h => h(App)
});

View File

@ -4,7 +4,7 @@ export function getBaseUrl() {
if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.3.5:9010' // 袁琪
// BASE_API = 'http://192.168.3.5:9010'; // 袁琪
// BASE_API = 'http://192.168.3.6:9010'; // 旭强
// BASE_API = 'http://192.168.3.4:9010' // 琰培
} else {

17
src/utils/lang.js Normal file
View File

@ -0,0 +1,17 @@
import Cookies from 'js-cookie';
const I18N_LANG = 'user_lang';
export default {
setLang(lang) {
Cookies.setItem(I18N_LANG, lang);
},
getLang(defaultLang) {
const localLang = Cookies.getItem(I18N_LANG);
if (localLang === null) {
return defaultLang;
} else {
return localLang;
}
}
};

View File

@ -1,67 +1,75 @@
<template>
<el-dialog :title="title" :visible.sync="show" width="600px" :before-close="doClose" :zIndex="2000" :modal="false"
:close-on-click-modal="false" v-dialogDrag>
<div style="height: 80px; line-height: 80px; font-size: 16px; padding-left: 10px;">{{roomName}}邀请你加入综合演练</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleJoin">确认</el-button>
<el-button @click="dialogShow = false"> </el-button>
</span>
</el-dialog>
<el-dialog
v-dialogDrag
:title="title"
:visible.sync="show"
width="600px"
:before-close="doClose"
:z-index="2000"
:modal="false"
:close-on-click-modal="false"
>
<div style="height: 80px; line-height: 80px; font-size: 16px; padding-left: 10px;">{{ roomName }}邀请你加入综合演练</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleJoin">确认</el-button>
<el-button @click="dialogShow = false"> </el-button>
</span>
</el-dialog>
</template>
<script>
import { getjointTraining, putJointTrainingSimulationEntrance } from '@/api/chat';
import { getPublishMapInfo } from '@/api/jmap/map';
import { launchFullscreen } from '@/utils/screen';
import { getjointTraining, putJointTrainingSimulationEntrance } from '@/api/chat';
import { getPublishMapInfo } from '@/api/jmap/map';
import { launchFullscreen } from '@/utils/screen';
export default {
name: 'DeomonList',
data() {
return {
dialogShow: false,
group: '',
roomName: '',
state: '',
mapId: '',
}
},
computed: {
show() {
return this.dialogShow;
},
title() {
return '综合演练快速入口';
},
},
mounted() {
},
methods: {
doShow(data) {
this.roomName = data.creator.nickName;
this.group = data.group;
this.state = data.state
this.mapId = data.mapId;
this.dialogShow = true;
},
doClose() {
this.dialogShow = false;
},
async handleJoin() {
if (this.state == '02') {
launchFullscreen();
await putJointTrainingSimulationEntrance(this.group);
let rest = await getPublishMapInfo(this.mapId);
let query = { skinStyle: rest.data.skinStyle, mapId: this.mapId, group: this.group };
this.$router.push({ path: `/jointTraining`, query: query });
} else if (this.state == '01') {
let query = { group: this.group };
this.$router.push({ path: `/trainroom`, query: query });
}
this.dialogShow = false;
getjointTraining(this.group);
}
}
}
export default {
name: 'DeomonList',
data() {
return {
dialogShow: false,
group: '',
roomName: '',
state: '',
mapId: ''
};
},
computed: {
show() {
return this.dialogShow;
},
title() {
return '综合演练快速入口';
}
},
mounted() {
},
methods: {
doShow(data) {
this.roomName = data.creator.nickName;
this.group = data.group;
this.state = data.state;
this.mapId = data.mapId;
this.dialogShow = true;
},
doClose() {
this.dialogShow = false;
},
async handleJoin() {
if (this.state == '02') {
launchFullscreen();
await putJointTrainingSimulationEntrance(this.group);
const rest = await getPublishMapInfo(this.mapId);
const query = { skinStyle: rest.data.skinStyle, mapId: this.mapId, group: this.group };
this.$router.push({ path: `/jointTraining`, query: query });
} else if (this.state == '01') {
const query = { group: this.group };
this.$router.push({ path: `/trainroom`, query: query });
}
this.dialogShow = false;
getjointTraining(this.group);
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@ -74,4 +82,4 @@
background-color: #e4e3e3 !important;
}
}
</style>
</style>