Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

Commit 84a349b

Browse files
committed
feat(MaterialAside): implement aside collapse state switch
1 parent 393d5df commit 84a349b

7 files changed

Lines changed: 89 additions & 38 deletions

File tree

src/App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export default {
5252
font-family: 'Avenir', Helvetica, Arial, sans-serif;
5353
-webkit-font-smoothing: antialiased;
5454
-moz-osx-font-smoothing: grayscale;
55-
text-align: center;
5655
color: #2c3e50;
5756
}
5857
#nav {

src/layout/Material/Aside.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
<template>
22
<el-aside
33
class="layout__material__aside"
4-
width="254px"
4+
:width="$store.state.isAsideCollapse ? `254px` : `80px`"
55
>
66
material aside
77
</el-aside>
88
</template>
99

1010
<script>
1111
export default {
12-
data () {
13-
return {}
14-
}
1512
}
1613
</script>
1714

1815
<style lang='scss' scoped>
16+
@import '~STYLE/color/background.scss';
17+
18+
.layout__material__aside {
19+
min-height: 100vh;
20+
background-color: $background-dark;
21+
transition: width .3s;
22+
}
1923
</style>

src/layout/Material/Header.vue

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<template>
2+
<el-header class="layout__material__header">
3+
<i
4+
class="el-icon-menu header__icon"
5+
@click="toggleAside"
6+
></i>
7+
<el-button
8+
class="logout"
9+
type="text"
10+
@click="onLogout"
11+
>Logout</el-button>
12+
<el-button
13+
class="logout"
14+
type="text"
15+
@click="$router.push('/pages/admin/dashboard')"
16+
>dashboard</el-button>
17+
<el-button
18+
class="logout"
19+
type="text"
20+
@click="$router.push('/pages/admin/table')"
21+
>table</el-button>
22+
<el-button
23+
class="logout"
24+
type="text"
25+
@click="$router.push('/pages/common/user')"
26+
>user info</el-button>
27+
</el-header>
28+
</template>
29+
30+
<script>
31+
import { mapMutations } from 'vuex'
32+
33+
export default {
34+
methods: {
35+
onLogout () {
36+
this.$store.dispatch('login/userLogout')
37+
.then(() => this.$router.replace('/login'))
38+
},
39+
...mapMutations({
40+
toggleAside: 'SET_ASIDE_COLLAPSE'
41+
})
42+
}
43+
}
44+
</script>
45+
46+
<style lang='scss' scoped>
47+
@import '~STYLE/color/background.scss';
48+
49+
.layout__material__header {
50+
padding: 0 24px 0 0;
51+
position: relative; // for box-shadow
52+
background-color: $background-lightest;
53+
box-shadow: 0 1px 4px rgba(0,21,41,.08);
54+
55+
.header {
56+
&__icon {
57+
padding: 0 24px;
58+
line-height: 60px;
59+
cursor: pointer;
60+
font-size: 20px;
61+
transition: all .3s, padding 0s;
62+
}
63+
}
64+
}
65+
</style>

src/layout/Material/index.vue

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,7 @@
44
<material-aside/>
55

66
<el-container class="layout__material__placeholder">
7-
<el-header>
8-
<el-button
9-
class="logout"
10-
type="text"
11-
@click="onLogout"
12-
>Logout</el-button>
13-
<el-button
14-
class="logout"
15-
type="text"
16-
@click="$router.push('/pages/admin/dashboard')"
17-
>dashboard</el-button>
18-
<el-button
19-
class="logout"
20-
type="text"
21-
@click="$router.push('/pages/admin/table')"
22-
>table</el-button>
23-
<el-button
24-
class="logout"
25-
type="text"
26-
@click="$router.push('/pages/common/user')"
27-
>user info</el-button>
28-
</el-header>
7+
<material-header/>
298

309
<el-main class="layout__material__placeholder-main">
3110
<router-view/>
@@ -39,23 +18,18 @@
3918
</template>
4019

4120
<script>
21+
import MaterialHeader from './Header'
4222
import MaterialAside from './Aside'
4323
4424
export default {
45-
methods: {
46-
onLogout () {
47-
this.$store.dispatch('login/userLogout')
48-
.then(() => this.$router.replace('/login'))
49-
}
50-
},
51-
5225
computed: {
5326
currentYear () {
5427
return new Date().getFullYear()
5528
}
5629
},
5730
5831
components: {
32+
MaterialHeader,
5933
MaterialAside
6034
}
6135
}
@@ -75,6 +49,7 @@ export default {
7549
7650
&__footer {
7751
line-height: 60px;
52+
text-align: center;
7853
}
7954
}
8055
</style>

src/store/mutations/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
// import types from './types'
1+
import types from './types'
22

3-
export default {}
3+
export default {
4+
[types.SET_ASIDE_COLLAPSE] (state) {
5+
state.isAsideCollapse = !state.isAsideCollapse
6+
}
7+
}

src/store/mutations/types.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export default {}
1+
export default {
2+
SET_ASIDE_COLLAPSE: 'SET_ASIDE_COLLAPSE'
3+
}

src/store/state.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export default {}
1+
export default {
2+
isAsideCollapse: false
3+
}

0 commit comments

Comments
 (0)