2022-03-24 04:15:14 +00:00
|
|
|
<template>
|
2022-04-06 07:48:24 +00:00
|
|
|
<div class="g-container-layout" :class="classObj" >
|
|
|
|
|
<div v-if="device==='mobile'&&!isCollapse" class="drawer-bg" @click="handleClickOutside" />
|
|
|
|
|
<sidebar class="sidebar-container"/>
|
2022-03-24 04:15:14 +00:00
|
|
|
<div class="main-container">
|
|
|
|
|
<u-header />
|
|
|
|
|
<app-main/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
|
import {computed, defineComponent, ref} from 'vue';
|
|
|
|
|
import Sidebar from './components/Sidebar/index.vue'
|
|
|
|
|
import UHeader from './components/UHeader/index.vue'
|
|
|
|
|
import AppMain from './components/AppMain.vue'
|
2022-04-06 07:48:24 +00:00
|
|
|
import {useResizeHandler} from './hooks/useResizeHandler'
|
2022-03-31 02:13:27 +00:00
|
|
|
|
2022-03-24 04:15:14 +00:00
|
|
|
import {useStore} from "vuex";
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
name: 'layout',
|
|
|
|
|
components: {
|
|
|
|
|
Sidebar,
|
|
|
|
|
UHeader,
|
2022-03-31 02:13:27 +00:00
|
|
|
AppMain,
|
2022-03-24 04:15:14 +00:00
|
|
|
},
|
|
|
|
|
setup(){
|
|
|
|
|
const store = useStore()
|
|
|
|
|
// 是否折叠
|
|
|
|
|
const isCollapse = computed(()=>{
|
2022-04-06 07:48:24 +00:00
|
|
|
return !store.state.app.isCollapse
|
2022-03-24 04:15:14 +00:00
|
|
|
})
|
2022-04-06 07:48:24 +00:00
|
|
|
let {device} = useResizeHandler()
|
|
|
|
|
|
|
|
|
|
const classObj = computed(()=>{
|
|
|
|
|
return {
|
|
|
|
|
hideSidebar:!store.state.app.isCollapse,
|
|
|
|
|
openSidebar: store.state.app.isCollapse,
|
|
|
|
|
withoutAnimation: store.state.app.withoutAnimation,
|
|
|
|
|
mobile: device.value === 'mobile'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const handleClickOutside = ()=> {
|
|
|
|
|
store.dispatch('app/closeSideBar', { withoutAnimation: false })
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-24 04:15:14 +00:00
|
|
|
return{
|
2022-04-06 07:48:24 +00:00
|
|
|
isCollapse,
|
|
|
|
|
device,
|
|
|
|
|
classObj,
|
|
|
|
|
handleClickOutside
|
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;
|
2022-03-24 04:15:14 +00:00
|
|
|
flex-direction: column
|
|
|
|
|
}
|
2022-04-06 07:48:24 +00:00
|
|
|
&.mobile.openSidebar {
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-19 01:47:14 +00:00
|
|
|
.sidebar-container{
|
|
|
|
|
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;
|
|
|
|
|
z-index: 999;
|
2022-03-24 04:15:14 +00:00
|
|
|
}
|
|
|
|
|
</style>
|