long
2021-02-02 36b71142347dc524e18fa24c5ffdffff0d02287a
提交 | 用户 | age
2a61f6 1 <template>
L 2   <div :class="classObj" class="app-wrapper">
3     <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
4     <sidebar class="sidebar-container" />
5     <div class="main-container">
6       <div :class="{'fixed-header':fixedHeader}">
7         <navbar />
8       </div>
9       <app-main />
10       <right-panel v-if="showSettings">
11         <settings />
12       </right-panel>
13     </div>
14   </div>
15 </template>
16
17 <script>
18 import RightPanel from '@/components/RightPanel'
19 import { AppMain, Navbar, Settings, Sidebar } from './components'
20 import ResizeMixin from './mixin/ResizeHandler'
21 import { mapState } from 'vuex'
22
23 export default {
24   name: 'Layout',
25   components: {
26     AppMain,
27     Navbar,
28     RightPanel,
29     Settings,
30     Sidebar
31   },
32   mixins: [ResizeMixin],
33   computed: {
34     ...mapState({
35       sidebar: state => state.app.sidebar,
36       device: state => state.app.device,
37       showSettings: state => state.settings.showSettings,
38       fixedHeader: state => state.settings.fixedHeader
39     }),
40     classObj() {
41       return {
42         hideSidebar: !this.sidebar.opened,
43         openSidebar: this.sidebar.opened,
44         withoutAnimation: this.sidebar.withoutAnimation,
45         mobile: this.device === 'mobile'
46       }
47     }
48   },
49   methods: {
50     handleClickOutside() {
51       this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
52     }
53   }
54 }
55 </script>
56
57 <style lang="scss" scoped>
58   @import "~@/styles/mixin.scss";
59   @import "~@/styles/variables.scss";
60
61   .app-wrapper {
62     @include clearfix;
63     position: relative;
64     height: 100%;
65     width: 100%;
66
67     &.mobile.openSidebar {
68       position: fixed;
69       top: 0;
70     }
71   }
72
73   .drawer-bg {
74     background: #000;
75     opacity: 0.3;
76     width: 100%;
77     top: 0;
78     height: 100%;
79     position: absolute;
80     z-index: 999;
81   }
82
83   .fixed-header {
84     position: fixed;
85     top: 0;
86     right: 0;
87     z-index: 9;
88     width: calc(100% - #{$sideBarWidth});
89     transition: width 0.28s;
90   }
91
92   .hideSidebar .fixed-header {
93     width: calc(100% - 54px)
94   }
95
96   .mobile .fixed-header {
97     width: 100%;
98   }
99 </style>