98 lines
2.4 KiB
Java
98 lines
2.4 KiB
Java
<template>
|
|
<a-config-provider :locale="locale">
|
|
<div id="app">
|
|
<router-view v-if="isRouterAlive" />
|
|
</div>
|
|
</a-config-provider>
|
|
</template>
|
|
<script>
|
|
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
|
|
import enUS from 'ant-design-vue/lib/locale-provider/en_US'
|
|
import enquireScreen from '@/utils/device'
|
|
import moment from 'moment'
|
|
import 'moment/locale/zh-cn'
|
|
moment.locale('zh-cn')
|
|
|
|
const EN = 'en-us'
|
|
const ZH = 'zh-cn'
|
|
|
|
export default {
|
|
data () {
|
|
return {
|
|
locale: zhCN,
|
|
isRouterAlive:true
|
|
}
|
|
},
|
|
created () {
|
|
let that = this
|
|
enquireScreen(deviceType => {
|
|
// tablet
|
|
if (deviceType === 0) {
|
|
that.$store.commit('TOGGLE_DEVICE', 'mobile')
|
|
that.$store.dispatch('setSidebar', false)
|
|
}
|
|
// mobile
|
|
else if (deviceType === 1) {
|
|
that.$store.commit('TOGGLE_DEVICE', 'mobile')
|
|
that.$store.dispatch('setSidebar', false)
|
|
}
|
|
else {
|
|
that.$store.commit('TOGGLE_DEVICE', 'desktop')
|
|
that.$store.dispatch('setSidebar', true)
|
|
}
|
|
})
|
|
|
|
// 默认中文
|
|
localStorage.lang == undefined ? localStorage.setItem("language", "zh-cn") : "";
|
|
// 自己配置多语言适配
|
|
this.$root.Bus.$on("switchLanguage", value => {
|
|
let router_path = this.$route.path;
|
|
switch (value) {
|
|
case "zh-cn":
|
|
localStorage.setItem("language", "zh-cn");
|
|
break;
|
|
case "en-us":
|
|
localStorage.setItem("language", "en-us");
|
|
break;
|
|
}
|
|
// 刷新页面
|
|
this.isRouterAlive = false; //先关闭,
|
|
this.$nextTick(function() {
|
|
this.isRouterAlive = true; //再打开
|
|
});
|
|
// 系统组件适配
|
|
let lang = localStorage.language;
|
|
if (lang == "zh-cn") {
|
|
this.locale = zhCN;
|
|
moment.locale("zh-cn");
|
|
} else if (lang == "en-us") {
|
|
this.locale = enUS;
|
|
moment.locale("en-us");
|
|
}
|
|
});
|
|
},
|
|
mounted() {
|
|
|
|
},
|
|
watch:{
|
|
$route:function(val) {
|
|
this.$nextTick(() => {
|
|
if (document.getElementsByClassName('ant-card-body').length > 0){
|
|
this.$watermark.set('fanqiangqiang 范强强')
|
|
}
|
|
})
|
|
}
|
|
},
|
|
computed:{
|
|
},
|
|
|
|
methods:{
|
|
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
#app {
|
|
height: 100%;
|
|
}
|
|
</style> |