zb-admin/src/layout/index.vue

82 lines
2.1 KiB
Vue
Raw Normal View History

2022-03-24 04:15:14 +00:00
<template>
<div class="g-container-layout" :class="classObj">
<div v-if="device === 'mobile' && !isCollapse" class="drawer-bg" @click="handleClickOutside" />
2022-11-20 11:53:13 +00:00
<Sidebar class="sidebar-container" v-if="mode === 'vertical'" />
<div
class="main-container"
:class="{
hideSliderLayout: mode === 'horizontal',
}"
>
2022-10-08 03:07:47 +00:00
<div :style="{ height:`${showTag?90:50}px` }" v-if="SettingStore.themeConfig.fixedHeader"></div>
2022-11-20 11:53:13 +00:00
<UHeader/>
<Main/>
<Footer/>
2022-03-24 04:15:14 +00:00
</div>
</div>
</template>
<script lang="ts" setup>
import { computed, defineComponent, ref } from 'vue'
import {useSettingStore} from "@/store/modules/setting"
2022-08-24 09:53:08 +00:00
import Sidebar from './Sidebar/index.vue'
import UHeader from './Header/index.vue'
2022-11-03 04:57:30 +00:00
import Main from './Main/index.vue'
2022-11-20 11:53:13 +00:00
import Footer from './Footer/index.vue'
import { useResizeHandler } from './hooks/useResizeHandler'
2022-03-31 02:13:27 +00:00
2022-09-12 12:31:21 +00:00
const SettingStore = useSettingStore()
2022-03-24 04:15:14 +00:00
2022-09-12 12:31:21 +00:00
// 是否折叠
const isCollapse = computed(() => {
return !SettingStore.isCollapse
})
let { device } = useResizeHandler()
// 当屏幕切换的时候进行变换
const classObj = computed(() => {
return {
hideSidebar: !SettingStore.isCollapse,
openSidebar: SettingStore.isCollapse,
withoutAnimation: SettingStore.withoutAnimation,
mobile: device.value === 'mobile',
}
})
// 移动端点击
const handleClickOutside = () => {
SettingStore.closeSideBar({ withoutAnimation: false })
}
const showTag = computed(() => SettingStore.themeConfig.showTag)
2022-04-06 07:48:24 +00:00
2022-09-12 12:31:21 +00:00
const mode = computed(() => SettingStore.themeConfig.mode)
2022-03-24 04:15:14 +00:00
</script>
<style lang="scss" scoped>
.g-container-layout {
2022-03-24 04:15:14 +00:00
height: 100%;
width: 100%;
.main-container {
2022-03-24 04:15:14 +00:00
display: flex;
flex: 1;
2022-03-28 10:32:20 +00:00
box-sizing: border-box;
flex-direction: column;
2022-03-24 04:15:14 +00:00
}
2022-04-06 07:48:24 +00:00
&.mobile.openSidebar {
position: fixed;
top: 0;
}
}
.sidebar-container {
2022-04-19 01:47:14 +00:00
display: flex;
flex-direction: column;
}
2022-04-06 07:48:24 +00:00
.drawer-bg {
background: #000;
opacity: 0.3;
width: 100%;
top: 0;
height: 100%;
position: absolute;
2022-09-02 13:28:40 +00:00
z-index: 90;
2022-03-24 04:15:14 +00:00
}
</style>