This commit is contained in:
fengchenchen
2023-08-14 17:10:11 +08:00
commit 37f6ec895d
1145 changed files with 437754 additions and 0 deletions
+79
View File
@@ -0,0 +1,79 @@
<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 () {
const that = this
enquireScreen(deviceType => {
// tablet
if (deviceType === 0) {
that.$store.commit('TOGGLE_DEVICE', 'mobile')
that.$store.dispatch('setSidebar', false)
} else if (deviceType === 1) { // mobile
that.$store.commit('TOGGLE_DEVICE', 'mobile')
that.$store.dispatch('setSidebar', false)
} else {
that.$store.commit('TOGGLE_DEVICE', 'desktop')
that.$store.dispatch('setSidebar', true)
}
})
const langCn = localStorage.language
// 默认中文
if (!langCn) {
localStorage.setItem('language', 'zh-cn')
} else if (langCn === 'en-us') {
this.locale = enUS
moment.locale('en-us')
this.$i18n.locale = EN
} else if (langCn === 'zh-cn') {
this.locale = zhCN
moment.locale('zh-cn')
this.$i18n.locale = ZH
}
// 自己配置多语言适配
this.$root.Bus.$on('switchLanguage', value => {
// 刷新页面
this.isRouterAlive = false // 先关闭,
const lang = localStorage.language
this.$nextTick(() => {
this.isRouterAlive = true // 再打开
})
// 系统组件适配
if (lang === 'zh-cn') {
this.locale = zhCN
moment.locale('zh-cn')
} else if (lang === 'en-us') {
this.locale = enUS
moment.locale('en-us')
}
})
}
}
</script>
<style scoped lang="less">
#app {
height: 100%;
}
</style>