|
@@ -1,92 +1,38 @@
|
1
|
1
|
<template>
|
2
|
|
- <a-layout has-sider>
|
3
|
|
- <a-layout-sider class="layout-sider" :width="siderWidth">
|
4
|
|
- <div></div>
|
5
|
|
- <div>
|
6
|
|
- <a-menu
|
7
|
|
- @click="handleMenu"
|
8
|
|
- @openChange="handleOpenChange"
|
9
|
|
- :style="menuStyle"
|
10
|
|
- theme="dark"
|
11
|
|
- triggerSubMenuAction="click"
|
12
|
|
- >
|
13
|
|
- <SubMenu :menus="menus" :sub-menu="SubMenu"></SubMenu>
|
14
|
|
- </a-menu>
|
15
|
|
- </div>
|
16
|
|
- </a-layout-sider>
|
17
|
|
- <a-layout class="layout-main">
|
18
|
|
- <a-layout-content>
|
19
|
|
- <router-view></router-view>
|
20
|
|
- </a-layout-content>
|
|
2
|
+ <a-layout>
|
|
3
|
+ <a-layout-header>
|
|
4
|
+ <Header />
|
|
5
|
+ </a-layout-header>
|
|
6
|
+ <a-layout>
|
|
7
|
+ <a-layout-sider class="layout-sider" :width="siderWidth">
|
|
8
|
+ <SiderBar :menu-style="menuStyle" />
|
|
9
|
+ </a-layout-sider>
|
|
10
|
+ <a-layout class="layout-main">
|
|
11
|
+ <a-layout-content>
|
|
12
|
+ <router-view></router-view>
|
|
13
|
+ </a-layout-content>
|
|
14
|
+ </a-layout>
|
21
|
15
|
</a-layout>
|
22
|
16
|
</a-layout>
|
23
|
17
|
</template>
|
24
|
18
|
|
25
|
19
|
<script setup>
|
26
|
|
-import { useModel } from '@zjxpcyc/vue-tiny-store'
|
27
|
|
-import SubMenu from '@/components/SubMenu.vue';
|
|
20
|
+import Header from './components/Header.vue'
|
|
21
|
+import SiderBar from './components/SiderBar.vue';
|
28
|
22
|
|
29
|
23
|
const siderWidth = '300px';
|
30
|
|
-const menuStyle = { width: `calc(${siderWidth} - 2px)` };
|
31
|
|
-
|
32
|
|
-const { user } = useModel('user')
|
33
|
|
-const { menus, getMenus, appendMenu } = useModel('menu')
|
34
|
|
-const { getNote } = useModel('note')
|
35
|
|
-
|
36
|
|
-const currentDir = { current: [] }
|
37
|
|
-const currentMenu = { current: {} }
|
38
|
|
-
|
39
|
|
-if (!menus || !menus.length) {
|
40
|
|
- getMenus(user).then(res => {
|
41
|
|
- appendMenu(menus, res)
|
42
|
|
- currentDir.current = res
|
43
|
|
- })
|
44
|
|
-}
|
45
|
|
-
|
46
|
|
-const handleMenu = (e) => {
|
47
|
|
- const menuId = e.key
|
48
|
|
- currentMenu.current = currentDir.current.filter(menu => `${menu.path}/${menu.name}` === menuId)[0]
|
49
|
|
-
|
50
|
|
- const [name, ...pathArr] = menuId.split('/').reverse()
|
51
|
|
- const path = pathArr.reverse().join('/')
|
52
|
|
-
|
53
|
|
-
|
54
|
|
- const fullPath = path === name ? name : menuId
|
55
|
|
-
|
56
|
|
- getNote(user, fullPath)
|
57
|
|
-}
|
58
|
|
-
|
59
|
|
-const handleOpenChange = (keys) => {
|
60
|
|
- const [ menuId ] = keys
|
61
|
|
- const [name, ...pathArr] = menuId.split('/').reverse()
|
62
|
|
- const path = pathArr.reverse().join('/').replace('/@@mockroot@@/', '')
|
63
|
|
-
|
64
|
|
- getMenus(user, path).then(res => {
|
65
|
|
- if (!currentMenu.current.children) {
|
66
|
|
- currentMenu.current.children = []
|
67
|
|
- }
|
68
|
|
-
|
69
|
|
- appendMenu(currentMenu.current.children, res)
|
70
|
|
- currentDir.current = res
|
71
|
|
- })
|
72
|
|
-}
|
|
24
|
+const menuStyle = { width: siderWidth, height: '100%' };
|
73
|
25
|
|
74
|
26
|
</script>
|
75
|
27
|
|
76
|
28
|
<style lang="less" scoped>
|
77
|
29
|
.layout-sider {
|
78
|
30
|
overflow: auto;
|
79
|
|
- height: 100vh;
|
80
|
|
- position: fixed;
|
81
|
|
- left: 0;
|
82
|
|
- top: 0;
|
83
|
|
- bottom: 0;
|
84
|
31
|
}
|
85
|
32
|
|
86
|
33
|
.layout-main {
|
87
|
|
- margin-left: v-bind(siderWidth);
|
88
|
34
|
box-sizing: border-box;
|
89
|
35
|
padding: 24px;
|
90
|
|
- height: 100vh;
|
|
36
|
+ height: calc(100vh - 80px);
|
91
|
37
|
}
|
92
|
38
|
</style>
|