zb-admin/src/layout/index.vue

95 lines
2.4 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-08-24 09:53:08 +00:00
<sidebar class="sidebar-container" v-if="mode === 'vertical'" />
<div
class="main-container"
:class="{
hideSliderLayout: mode === 'horizontal',
}"
>
2022-03-24 04:15:14 +00:00
<u-header />
2022-08-24 10:53:05 +00:00
<div class="m-container-content" :class="{ 'app-main-hide-tag': !showTag }">
2022-08-24 09:53:08 +00:00
<u-main />
2022-04-30 13:19:10 +00:00
</div>
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'
import UMain from './Main/index.vue'
import { useResizeHandler } from './hooks/useResizeHandler'
2022-03-31 02:13:27 +00:00
const SettingStore = useSettingStore()
2022-03-24 04:15:14 +00:00
// 是否折叠
const isCollapse = computed(() => {
2022-09-02 13:28:40 +00:00
return !SettingStore.isCollapse
2022-03-24 04:15:14 +00:00
})
let { device } = useResizeHandler()
// 当屏幕切换的时候进行变换
const classObj = computed(() => {
2022-04-06 07:48:24 +00:00
return {
hideSidebar: !SettingStore.isCollapse,
openSidebar: SettingStore.isCollapse,
withoutAnimation: SettingStore.withoutAnimation,
mobile: device.value === 'mobile',
2022-04-06 07:48:24 +00:00
}
})
// 移动端点击
const handleClickOutside = () => {
SettingStore.closeSideBar({ withoutAnimation: false })
2022-04-06 07:48:24 +00:00
}
const showTag = computed(() => SettingStore.themeConfig.showTag)
2022-04-06 07:48:24 +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-04-25 07:48:25 +00:00
//display: flex;
2022-03-24 04:15:14 +00:00
height: 100%;
width: 100%;
.main-container {
2022-03-31 02:13:27 +00:00
//overflow: auto;
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
}
.m-container-content {
2022-06-10 03:01:39 +00:00
//padding: 20px;
2022-04-30 13:19:10 +00:00
/*background: #f6f8f9;*/
2022-06-10 03:01:39 +00:00
padding-top: 93px;
2022-06-16 06:48:48 +00:00
box-sizing: border-box;
height: 100vh;
2022-05-01 15:06:11 +00:00
position: relative;
2022-04-30 13:19:10 +00:00
}
.app-main-hide-tag {
2022-04-30 13:19:10 +00:00
padding-top: 80px;
}
2022-03-24 04:15:14 +00:00
</style>