Initial commit
This commit is contained in:
+131
@@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<a-config-provider :locale="locale">
|
||||
<div id="app">
|
||||
<router-view v-if="isRouterAlive" />
|
||||
<div class="watermark" v-if="show" v-watermark="{text: watermark, textColor: watermarkConfig.color}"></div>
|
||||
</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'
|
||||
// 水印功能
|
||||
import '@/utils/warterMark'
|
||||
// 引入自定义icon
|
||||
import '@/assets/icon/iconfont.less'
|
||||
import Vue from 'vue'
|
||||
|
||||
moment.locale('zh-cn')
|
||||
|
||||
const EN = 'en-us'
|
||||
const ZH = 'zh-cn'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
locale: zhCN,
|
||||
isRouterAlive: true,
|
||||
show: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
watermark () {
|
||||
if (this.$store.getters.userInfo) {
|
||||
return this.$store.getters.userInfo.username + this.$store.getters.userInfo.realname
|
||||
}
|
||||
return null
|
||||
},
|
||||
watermarkConfig () {
|
||||
return window._CONFIG.watermarkConfig
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
watermark () {
|
||||
setTimeout(() => {
|
||||
this.show = false
|
||||
this.$nextTick(() => {
|
||||
this.show = true
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
// fix 79402 解决火狐浏览器拖拽文件会打开新标签页的问题
|
||||
document.body.ondrop = (e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
}
|
||||
},
|
||||
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')
|
||||
}
|
||||
})
|
||||
|
||||
// 新标签页打开
|
||||
Vue.prototype.$openPageNewSheet = (params) => {
|
||||
const { href } = this.$router.resolve(params)
|
||||
window.open(href, '_blank')
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
#app {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.watermark {
|
||||
pointer-events: none;
|
||||
position: fixed;
|
||||
z-index: 999999999;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user