2021-08-11 15:44:50 +08:00
|
|
|
<template>
|
|
|
|
<pro-layout
|
|
|
|
:title="title"
|
|
|
|
:menus="menus"
|
|
|
|
:collapsed="collapsed"
|
|
|
|
:mediaQuery="query"
|
|
|
|
:isMobile="isMobile"
|
|
|
|
:handleMediaQuery="handleMediaQuery"
|
|
|
|
:handleCollapse="handleCollapse"
|
|
|
|
:logo="logoRender"
|
|
|
|
:i18nRender="i18nRender"
|
|
|
|
v-bind="settings"
|
|
|
|
>
|
2021-08-20 11:14:51 +08:00
|
|
|
<!-- <setting-drawer :settings="settings" @change="handleSettingChange" /> -->
|
2021-08-11 15:44:50 +08:00
|
|
|
<template v-slot:rightContentRender>
|
|
|
|
<right-content :top-menu="settings.layout === 'topmenu'" :is-mobile="isMobile" :theme="settings.theme" />
|
|
|
|
</template>
|
2021-08-20 11:14:51 +08:00
|
|
|
<!-- <multi-tab></multi-tab> -->
|
2021-08-11 15:44:50 +08:00
|
|
|
<template v-slot:footerRender>
|
|
|
|
<global-footer />
|
|
|
|
</template>
|
|
|
|
<router-view />
|
|
|
|
</pro-layout>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-08-20 11:14:51 +08:00
|
|
|
import { updateTheme } from '@ant-design-vue/pro-layout'
|
2021-08-11 15:44:50 +08:00
|
|
|
import { i18nRender } from '@/locales'
|
|
|
|
import { mapState } from 'vuex'
|
|
|
|
import { SIDEBAR_TYPE, TOGGLE_MOBILE_TYPE } from '@/store/mutation-types'
|
2021-08-20 11:14:51 +08:00
|
|
|
import { asyncRouterMap } from '@/config/router.config.js'
|
2021-08-11 15:44:50 +08:00
|
|
|
|
|
|
|
import defaultSettings from '@/config/defaultSettings'
|
|
|
|
import RightContent from '@/components/GlobalHeader/RightContent'
|
|
|
|
import GlobalFooter from '@/components/GlobalFooter'
|
2021-08-20 11:14:51 +08:00
|
|
|
import MultiTab from '@/components/MultiTab'
|
2021-08-11 15:44:50 +08:00
|
|
|
import LogoSvg from '../assets/logo.svg?inline'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'BasicLayout',
|
|
|
|
components: {
|
2021-08-20 11:14:51 +08:00
|
|
|
// SettingDrawer,
|
2021-08-11 15:44:50 +08:00
|
|
|
RightContent,
|
2021-08-20 11:14:51 +08:00
|
|
|
GlobalFooter,
|
|
|
|
MultiTab
|
2021-08-11 15:44:50 +08:00
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
// base
|
|
|
|
menus: [],
|
|
|
|
// 侧栏收起状态
|
|
|
|
collapsed: false,
|
|
|
|
title: defaultSettings.title,
|
|
|
|
settings: {
|
|
|
|
// 布局类型
|
|
|
|
layout: defaultSettings.layout, // 'sidemenu', 'topmenu'
|
|
|
|
// 定宽: true / 流式: false
|
|
|
|
contentWidth: defaultSettings.layout === 'sidemenu' ? false : defaultSettings.contentWidth === 'Fixed',
|
|
|
|
// 主题 'dark' | 'light'
|
|
|
|
theme: defaultSettings.navTheme,
|
|
|
|
// 主色调
|
|
|
|
primaryColor: defaultSettings.primaryColor,
|
|
|
|
fixedHeader: defaultSettings.fixedHeader,
|
|
|
|
fixSiderbar: defaultSettings.fixSiderbar,
|
|
|
|
colorWeak: defaultSettings.colorWeak,
|
2021-08-20 11:14:51 +08:00
|
|
|
|
2021-08-11 15:44:50 +08:00
|
|
|
hideHintAlert: false,
|
|
|
|
hideCopyButton: false
|
|
|
|
},
|
|
|
|
// 媒体查询
|
|
|
|
query: {},
|
2021-08-20 11:14:51 +08:00
|
|
|
|
2021-08-11 15:44:50 +08:00
|
|
|
// 是否手机模式
|
|
|
|
isMobile: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
|
|
|
// 动态主路由
|
|
|
|
mainMenu: state => state.permission.addRouters
|
|
|
|
})
|
|
|
|
},
|
|
|
|
created () {
|
2021-08-20 11:14:51 +08:00
|
|
|
// const routes = this.mainMenu.find(item => item.path === '/')
|
|
|
|
// this.menus = (routes && routes.children) || []
|
|
|
|
this.menus = asyncRouterMap.find((item) => item.path === '/').children
|
|
|
|
// 处理侧栏收起状态
|
|
|
|
this.$watch('collapsed', () => {
|
|
|
|
this.$store.commit(SIDEBAR_TYPE, this.collapsed)
|
|
|
|
})
|
|
|
|
this.$watch('isMobile', () => {
|
|
|
|
this.$store.commit(TOGGLE_MOBILE_TYPE, this.isMobile)
|
|
|
|
})
|
2021-08-11 15:44:50 +08:00
|
|
|
},
|
|
|
|
mounted () {
|
|
|
|
const userAgent = navigator.userAgent
|
|
|
|
if (userAgent.indexOf('Edge') > -1) {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.collapsed = !this.collapsed
|
|
|
|
setTimeout(() => {
|
|
|
|
this.collapsed = !this.collapsed
|
|
|
|
}, 16)
|
|
|
|
})
|
|
|
|
}
|
2021-08-20 11:14:51 +08:00
|
|
|
|
|
|
|
// first update color
|
|
|
|
// TIPS: THEME COLOR HANDLER!! PLEASE CHECK THAT!!
|
|
|
|
if (process.env.NODE_ENV !== 'production' || process.env.VUE_APP_PREVIEW === 'true') {
|
|
|
|
updateTheme(this.settings.primaryColor)
|
|
|
|
}
|
2021-08-11 15:44:50 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
i18nRender,
|
|
|
|
handleMediaQuery (val) {
|
|
|
|
this.query = val
|
|
|
|
if (this.isMobile && !val['screen-xs']) {
|
|
|
|
this.isMobile = false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (!this.isMobile && val['screen-xs']) {
|
|
|
|
this.isMobile = true
|
|
|
|
this.collapsed = false
|
|
|
|
this.settings.contentWidth = false
|
|
|
|
// this.settings.fixSiderbar = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handleCollapse (val) {
|
|
|
|
this.collapsed = val
|
|
|
|
},
|
2021-08-20 11:14:51 +08:00
|
|
|
handleSettingChange ({ type, value }) {
|
|
|
|
console.log('type', type, value)
|
|
|
|
type && (this.settings[type] = value)
|
|
|
|
switch (type) {
|
|
|
|
case 'contentWidth':
|
|
|
|
this.settings[type] = value === 'Fixed'
|
|
|
|
break
|
|
|
|
case 'layout':
|
|
|
|
if (value === 'sidemenu') {
|
|
|
|
this.settings.contentWidth = false
|
|
|
|
} else {
|
|
|
|
this.settings.fixSiderbar = false
|
|
|
|
this.settings.contentWidth = true
|
|
|
|
}
|
|
|
|
break
|
|
|
|
}
|
|
|
|
},
|
2021-08-11 15:44:50 +08:00
|
|
|
logoRender () {
|
|
|
|
return <LogoSvg />
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less">
|
|
|
|
@import "./BasicLayout.less";
|
|
|
|
</style>
|