Skip to content

Commit 3c0415c

Browse files
committed
Merge branch 'v4.0' of https://github.com/PanJiaChen/vue-element-admin into v4.0
2 parents 960b562 + 58a66d4 commit 3c0415c

File tree

10 files changed

+158
-28
lines changed

10 files changed

+158
-28
lines changed

src/layout/Layout.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ export default {
6666
position: relative;
6767
height: 100%;
6868
width: 100%;
69-
&.mobile.openSidebar{
69+
70+
&.mobile.openSidebar {
7071
position: fixed;
7172
top: 0;
7273
}
7374
}
75+
7476
.drawer-bg {
7577
background: #000;
7678
opacity: 0.3;
@@ -80,18 +82,21 @@ export default {
8082
position: absolute;
8183
z-index: 999;
8284
}
83-
.fixed-header{
85+
86+
.fixed-header {
8487
position: fixed;
8588
top: 0;
8689
right: 0;
8790
z-index: 9;
8891
width: calc(100% - #{$sideBarWidth});
89-
transition: width 0.28s;
92+
transition: width 0.28s;
9093
}
91-
.hideSidebar .fixed-header{
92-
width: calc(100% - 54px)
94+
95+
.hideSidebar .fixed-header {
96+
width: calc(100% - 54px)
9397
}
94-
.mobile .fixed-header{
98+
99+
.mobile .fixed-header {
95100
width: 100%;
96101
}
97102
</style>

src/layout/components/AppMain.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ export default {
2424

2525
<style rel="stylesheet/scss" lang="scss" scoped>
2626
.app-main {
27-
/*50= navbar 50 */
27+
/* 50= navbar 50 */
2828
min-height: calc(100vh - 50px);
2929
width: 100%;
3030
position: relative;
3131
overflow: hidden;
3232
}
3333
3434
.fixed-header+.app-main {
35-
margin-top: 50px;
35+
padding-top: 50px;
3636
}
3737
3838
.hasTagsView {
3939
.app-main {
40-
/*84 = navbar + tags-view = 50 + 34 */
40+
/* 84 = navbar + tags-view = 50 + 34 */
4141
min-height: calc(100vh - 84px);
4242
}
4343
4444
.fixed-header+.app-main {
45-
margin-top: 80px;
45+
padding-top: 80px;
4646
}
4747
}
4848
</style>

src/layout/components/Navbar.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export default {
105105
float: left;
106106
cursor: pointer;
107107
transition: background .3s;
108+
-webkit-tap-highlight-color:transparent;
108109
109110
&:hover {
110111
background: rgba(0, 0, 0, .025)

src/layout/components/Settings/index.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<el-switch v-model="fixedHeader" class="drawer-switch" />
2121
</div>
2222

23+
<div class="drawer-item">
24+
<span>侧边栏 Logo</span>
25+
<el-switch v-model="sidebarLogo" class="drawer-switch" />
26+
</div>
27+
2328
</div>
2429
</div>
2530
</template>
@@ -31,7 +36,7 @@ export default {
3136
components: { ThemePicker },
3237
data() {
3338
return {
34-
sidebarLogo: true
39+
3540
}
3641
},
3742
computed: {
@@ -56,6 +61,17 @@ export default {
5661
value: val
5762
})
5863
}
64+
},
65+
sidebarLogo: {
66+
get() {
67+
return this.$store.state.settings.sidebarLogo
68+
},
69+
set(val) {
70+
this.$store.dispatch('settings/changeSetting', {
71+
key: 'sidebarLogo',
72+
value: val
73+
})
74+
}
5975
}
6076
}
6177
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<template>
2+
<div class="sidebar-logo-container" :class="{'collapse':collapse}">
3+
<transition name="sidebarLogoFade">
4+
<router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
5+
<img v-if="logo" :src="logo" class="sidebar-logo">
6+
<h1 v-else class="sidebar-title">{{ title }} </h1>
7+
</router-link>
8+
<router-link v-else key="expand" class="sidebar-logo-link" to="/">
9+
<img v-if="logo" :src="logo" class="sidebar-logo">
10+
<h1 class="sidebar-title">{{ title }} </h1>
11+
</router-link>
12+
</transition>
13+
</div>
14+
</template>
15+
16+
<script>
17+
export default {
18+
name: 'SidebarLogo',
19+
props: {
20+
collapse: {
21+
type: Boolean,
22+
required: true
23+
}
24+
},
25+
data() {
26+
return {
27+
title: 'Vue Element Admin',
28+
logo: 'https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png'
29+
}
30+
}
31+
}
32+
</script>
33+
34+
<style rel="stylesheet/scss" lang="scss" scoped>
35+
.sidebarLogoFade-enter-active {
36+
transition: opacity 1.5s;
37+
}
38+
39+
.sidebarLogoFade-enter,
40+
.sidebarLogoFade-leave-to {
41+
opacity: 0;
42+
}
43+
44+
.sidebar-logo-container {
45+
position: relative;
46+
width: 100%;
47+
height: 50px;
48+
line-height: 50px;
49+
background: #2b2f3a;
50+
text-align: center;
51+
overflow: hidden;
52+
53+
& .sidebar-logo-link {
54+
height: 100%;
55+
width: 100%;
56+
57+
& .sidebar-logo {
58+
width: 32px;
59+
height: 32px;
60+
vertical-align: middle;
61+
margin-right: 12px;
62+
}
63+
64+
& .sidebar-title {
65+
display: inline-block;
66+
margin: 0;
67+
color: #fff;
68+
font-weight: 600;
69+
line-height: 50px;
70+
font-size: 14px;
71+
font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
72+
vertical-align: middle;
73+
}
74+
}
75+
76+
&.collapse {
77+
.sidebar-logo {
78+
margin-right: 0px;
79+
}
80+
}
81+
}
82+
</style>

src/layout/components/Sidebar/index.vue

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
<template>
2-
<el-scrollbar wrap-class="scrollbar-wrapper">
3-
<el-menu
4-
:default-active="$route.path"
5-
:collapse="isCollapse"
6-
:background-color="variables.menuBg"
7-
:text-color="variables.menuText"
8-
:active-text-color="variables.menuActiveText"
9-
:collapse-transition="false"
10-
mode="vertical"
11-
>
12-
<sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" />
13-
</el-menu>
14-
</el-scrollbar>
2+
<div :class="{'has-logo':showLogo}">
3+
<logo v-if="showLogo" :collapse="isCollapse" />
4+
<el-scrollbar wrap-class="scrollbar-wrapper">
5+
<el-menu
6+
:default-active="$route.path"
7+
:collapse="isCollapse"
8+
:background-color="variables.menuBg"
9+
:text-color="variables.menuText"
10+
:active-text-color="variables.menuActiveText"
11+
:collapse-transition="false"
12+
mode="vertical"
13+
>
14+
<sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" />
15+
</el-menu>
16+
</el-scrollbar>
17+
</div>
1518
</template>
1619

1720
<script>
1821
import { mapGetters } from 'vuex'
22+
import Logo from './Logo'
1923
import SidebarItem from './SidebarItem'
2024
import variables from '@/styles/variables.scss'
2125
2226
export default {
23-
components: { SidebarItem },
27+
components: { SidebarItem, Logo },
2428
computed: {
2529
...mapGetters([
2630
'permission_routes',
2731
'sidebar'
2832
]),
33+
showLogo() {
34+
return this.$store.state.settings.sidebarLogo
35+
},
2936
variables() {
3037
return variables
3138
},

src/settings.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ export default {
1919
*/
2020
fixedHeader: true,
2121

22+
/**
23+
* @type {boolean} true | false
24+
* @description Whether show the logo in sidebar
25+
*/
26+
sidebarLogo: true,
27+
2228
/**
2329
* @type {string | array} 'production' | ['production','development']
2430
* @description Need show err logs component.

src/store/modules/settings.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import defaultSettings from '@/settings'
2-
const { showSettings, tagsView, fixedHeader } = defaultSettings
2+
const { showSettings, tagsView, fixedHeader, sidebarLogo } = defaultSettings
33

44
const state = {
55
showSettings: showSettings,
66
tagsView: tagsView,
7-
fixedHeader: fixedHeader
7+
fixedHeader: fixedHeader,
8+
sidebarLogo: sidebarLogo
89
}
910

1011
const mutations = {

src/styles/sidebar.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@
3838
right: 0px;
3939
}
4040

41+
.el-scrollbar {
42+
height: 100%;
43+
}
44+
45+
&.has-logo {
46+
.el-scrollbar {
47+
height: calc(100% - 50px);
48+
}
49+
}
50+
4151
.is-horizontal {
4252
display: none;
4353
}
@@ -100,6 +110,7 @@
100110

101111
.el-tooltip {
102112
padding: 0 !important;
113+
103114
.svg-icon {
104115
margin-left: 20px;
105116
}
@@ -111,6 +122,7 @@
111122

112123
&>.el-submenu__title {
113124
padding: 0 !important;
125+
114126
.svg-icon {
115127
margin-left: 20px;
116128
}

src/styles/transition.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//globl transition css
1+
//global transition css
22

33
/*fade*/
44
.fade-enter-active,

0 commit comments

Comments
 (0)