You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.9 KiB
106 lines
2.9 KiB
<template>
|
|
<transition name="el-fade-in-linear">
|
|
<router-view />
|
|
</transition>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapActions } from 'vuex'
|
|
import Cookies from 'js-cookie'
|
|
import { messages } from '@/i18n'
|
|
import Vue from 'vue'
|
|
export default {
|
|
watch: {
|
|
'$i18n.locale': 'i18nHandle'
|
|
},
|
|
created () {
|
|
this.i18nHandle(this.$i18n.locale)
|
|
},
|
|
methods: {
|
|
|
|
i18nHandle (val, oldVal) {
|
|
Cookies.set('language', val)
|
|
document.querySelector('html').setAttribute('lang', val)
|
|
document.title = messages[val].brand.lg
|
|
// 非登录页面,切换语言刷新页面
|
|
if (this.$route.name !== 'login' && oldVal) {
|
|
window.location.reload()
|
|
}
|
|
},
|
|
refreshView () {
|
|
// In order to make the cached page re-rendered
|
|
this.$store.dispatch('delAllCachedViews', this.$route)
|
|
|
|
const { fullPath } = this.$route
|
|
|
|
this.$nextTick(() => {
|
|
this.$router.replace({
|
|
path: '/redirect' + fullPath
|
|
})
|
|
})
|
|
},
|
|
...mapActions(['setClientHeight', 'setSize', 'setResolution', 'setEnv'])
|
|
},
|
|
computed: {
|
|
},
|
|
mounted () {
|
|
|
|
console.log("开始::::" + localStorage.getItem('userType'))
|
|
if (!localStorage.getItem('userType')) {
|
|
localStorage.setItem('userType', 'oper')
|
|
}
|
|
|
|
//console.log("为空后设置默认值::::" + localStorage.getItem('userType'))
|
|
const that = this
|
|
let envShow = process.env.VUE_APP_NODE_ENV
|
|
let env = 'dev'
|
|
if (envShow === 'dev' || envShow === 'prod:sit') { // 开发环境
|
|
env = 'dev'
|
|
} else if (envShow === 'prod:uat') { // 体验
|
|
env = 'test'
|
|
} else if (envShow === 'prod') { // 生产
|
|
env = 'prod'
|
|
}
|
|
// eslint-disable-next-line
|
|
// debugger
|
|
that.setEnv(env)
|
|
console.log('屏幕宽度:' + document.documentElement.clientWidth)
|
|
// 根据屏幕分辨率调整size
|
|
if (document.documentElement.clientHeight < 800) {
|
|
// medium大小
|
|
that.setSize('small')
|
|
// 屏幕分辨率
|
|
that.setResolution('small')
|
|
Vue.prototype.$ELEMENT = { size: 'medium', zIndex: 3000 }
|
|
} else {
|
|
// 默认大小
|
|
that.setSize('medium')
|
|
// 屏幕分辨率
|
|
that.setResolution('medium')
|
|
Vue.prototype.$ELEMENT = { size: 'medium', zIndex: 3000 }
|
|
}
|
|
|
|
|
|
window.onresize = () => {
|
|
return (() => {
|
|
if (!that.timer) {
|
|
that.timer = true
|
|
// 这里的定时器是为了避免window.onresize时过于频繁的刷新vuex
|
|
setTimeout(function() {
|
|
that.setClientHeight(document.documentElement.clientHeight)
|
|
// debugger
|
|
if (document.documentElement.clientHeight < 800) {
|
|
// medium大小
|
|
that.setSize('medium')
|
|
} else {
|
|
// 默认大小
|
|
that.setSize('medium')
|
|
}
|
|
that.timer = false
|
|
}, 150)
|
|
}
|
|
})()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|