-
Notifications
You must be signed in to change notification settings - Fork 5
/
AppDrawer.vue
103 lines (100 loc) · 2.63 KB
/
AppDrawer.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
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
<template>
<v-navigation-drawer
v-model="showDrawer"
app
class="app-drawer"
:mini-variant.sync="mini"
mini-variant-width="64"
:width="drawerWidth"
>
<v-toolbar color="primary darken-1" dark>
<img :src="computeLogo" height="36" alt="Vue Material Admin Template" />
<v-toolbar-title>
<span class="hidden-sm-and-down">Vue Material</span>
</v-toolbar-title>
</v-toolbar>
<app-switcher />
<vue-perfect-scrollbar class="app-drawer__scrollbar">
<div class="app-drawer__inner">
<nav-list :items="computeMenu" :mini="mini" />
</div>
</vue-perfect-scrollbar>
<template #append>
<div class="grey lighten-3">
<template v-if="mini">
<v-btn block width="64" height="48" icon tile class="mx-auto" @click="handleDrawerCollapse">
<v-icon>mdi-arrow-collapse-right</v-icon>
</v-btn>
</template>
<template v-else>
<v-btn right block height="48" icon tile @click="handleDrawerCollapse">
<v-icon>mdi-arrow-collapse-left</v-icon>
</v-btn>
</template>
</div>
</template>
</v-navigation-drawer>
</template>
<script>
import { protectedRoute as routes } from '@/router/config'
import VuePerfectScrollbar from 'vue-perfect-scrollbar'
import AppSwitcher from './AppSwitcher'
import NavList from '@/components/nav/NavList'
export default {
name: 'AppDrawer',
components: { VuePerfectScrollbar, AppSwitcher, NavList },
props: {},
data() {
return {
mini: false,
showDrawer: true,
drawerWidth: 256,
scrollSettings: {
maxScrollbarLength: 160,
},
}
},
computed: {
computeLogo() {
return '/static/m.png'
},
computeMenu() {
return this.filterRouteItem(routes[0].children)
},
computeHeight() {
return {
height: this.height || '',
}
},
},
created() {},
methods: {
filterRouteItem(routes) {
return routes
.filter((item) => item.meta.hidden !== true)
.map((item) => {
return {
title: this.$t(item.meta.title),
icon: item.meta.icon,
path: item.path,
isNew: item.meta.isNew || false,
children: item.children ? this.filterRouteItem(item.children) : [],
}
})
},
handleDrawerCollapse() {
this.mini = !this.mini
},
toggleDrawer() {
this.showDrawer = !this.showDrawer
},
},
}
</script>
<style lang="sass" scoped>
.app-drawer
&__srollbar
max-height: calc(100vh - 64px - 36px - 44px)
&__inner
height: calc(100vh - 64px - 36px - 44px)
</style>