forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppMenu.js
More file actions
109 lines (95 loc) · 2.28 KB
/
AppMenu.js
File metadata and controls
109 lines (95 loc) · 2.28 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import {
QExpansionItem,
QItem,
QItemSection,
QIcon,
QBadge,
QList
} from 'quasar'
import Menu from 'assets/menu.js'
import './AppMenu.sass'
export default {
name: 'AppMenu',
watch: {
$route (route) {
this.showMenu(this.$refs[route.path])
}
},
methods: {
showMenu (comp) {
if (comp !== void 0 && comp !== this) {
this.showMenu(comp.$parent)
comp.show !== void 0 && comp.show()
}
},
getDrawerMenu (h, menu, path, level) {
if (menu.children !== void 0) {
return h(
QExpansionItem,
{
staticClass: 'non-selectable',
ref: path,
key: `${menu.name}-${path}`,
props: {
label: menu.name,
dense: level > 0,
icon: menu.icon,
defaultOpened: menu.opened,
expandSeparator: true,
switchToggleSide: level > 0,
denseToggle: level > 0
}
},
menu.children.map(item => this.getDrawerMenu(
h,
item,
path + (item.path !== void 0 ? '/' + item.path : ''),
level + 1
))
)
}
const props = {
to: path,
dense: level > 0,
insetLevel: level > 1 ? 1.2 : level
}
const attrs = {}
if (menu.external === true) {
Object.assign(props, {
to: void 0,
clickable: true,
tag: 'a'
})
attrs.href = menu.path
attrs.target = '_blank'
}
return h(QItem, {
ref: path,
key: path,
props,
attrs,
staticClass: 'app-menu-entry non-selectable'
}, [
menu.icon !== void 0
? h(QItemSection, {
props: { avatar: true }
}, [ h(QIcon, { props: { name: menu.icon } }) ])
: null,
h(QItemSection, [ menu.name ]),
menu.badge !== void 0
? h(QItemSection, {
props: { side: true }
}, [ h(QBadge, [ menu.badge ]) ])
: null
])
}
},
render (h) {
return h(QList, { staticClass: 'app-menu' }, Menu.map(
item => this.getDrawerMenu(h, item, '/' + item.path, 0)
))
},
mounted () {
this.showMenu(this.$refs[this.$route.path])
}
}