forked from CorentinTh/it-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenuLayout.vue
51 lines (46 loc) · 1.1 KB
/
MenuLayout.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<script setup lang="ts">
import { useStyleStore } from '@/stores/style.store';
const styleStore = useStyleStore();
const { isMenuCollapsed, isSmallScreen } = toRefs(styleStore);
const siderPosition = computed(() => (isSmallScreen.value ? 'absolute' : 'static'));
</script>
<template>
<n-layout has-sider>
<n-layout-sider
bordered
collapse-mode="width"
:collapsed-width="0"
:width="240"
:collapsed="isMenuCollapsed"
:show-trigger="false"
:native-scrollbar="false"
:position="siderPosition"
>
<slot name="sider" />
</n-layout-sider>
<n-layout class="content">
<slot name="content" />
<div v-show="isSmallScreen && !isMenuCollapsed" class="overlay" @click="isMenuCollapsed = true" />
</n-layout>
</n-layout>
</template>
<style lang="less" scoped>
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #00000080;
cursor: pointer;
}
.content {
// background-color: #f1f5f9;
::v-deep(.n-layout-scroll-container) {
padding: 26px;
}
}
.n-layout {
height: 100vh;
}
</style>