Skip to content

Commit b42c51e

Browse files
committed
refactor: update sidebar ui
1 parent 84537be commit b42c51e

File tree

2 files changed

+55
-45
lines changed

2 files changed

+55
-45
lines changed

src/assets/styles/custom.less

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
line-height: 36px;
116116
}
117117

118+
.ant-menu-item:active, .ant-menu-submenu-title:active {
119+
background: inherit;
120+
}
121+
118122
.ant-pagination-prev .ant-pagination-item-link, .ant-pagination-next .ant-pagination-item-link, .ant-pagination-item {
119123
border: none;
120124
&:hover {
@@ -220,10 +224,8 @@
220224
.ant-menu-inline .ant-menu-item, .ant-menu-inline .ant-menu-submenu-title {
221225
width: 90%;
222226
margin-left: 5%;
223-
border-radius: 2px;
224-
&:hover {
225-
background: #efebe385;
226-
}
227+
border-radius: 8px;
228+
color: #666;
227229
}
228230

229231
.menu-tab {

src/components/Main.vue

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,18 @@
88
<div class="logo">
99
<img class="img" src="@/assets/logo.png">
1010
</div>
11-
<a-menu mode="inline" :defaultSelectedKeys="['articles']" @click="clickMenu">
12-
<a-menu-item key="articles">
11+
<a-menu mode="inline" :defaultSelectedKeys="['/articles']" @click="clickMenu">
12+
<a-menu-item :key="menu.router" v-for="menu in sideMenus">
1313
<div class="menu-item">
1414
<div class="flex items-center">
15-
<!-- <i class="zwicon-document menu-icon"></i> -->
16-
<i class="ri-article-line mr-2 text-base"></i>
17-
<span class="nav-text">{{ $t('article') }}</span>
15+
<i
16+
class="mr-2 text-base"
17+
:class="{ [menu.icon]: true }"
18+
:style="{ color: currentRouter === menu.router ? '#f9d757' : 'inherit' }"
19+
></i>
20+
<span class="nav-text">{{ menu.text }}</span>
1821
</div>
19-
<span class="number">{{ site.posts.length }}</span>
20-
</div>
21-
</a-menu-item>
22-
<a-menu-item key="menu">
23-
<div class="menu-item">
24-
<div class="flex items-center">
25-
<!-- <i class="zwicon-grid menu-icon"></i> -->
26-
<i class="ri-menu-2-line mr-2 text-base"></i>
27-
<span class="nav-text">{{ $t('menu') }}</span>
28-
</div>
29-
<span class="number">{{ site.menus.length }}</span>
30-
</div>
31-
</a-menu-item>
32-
<a-menu-item key="tags">
33-
<div class="menu-item">
34-
<div class="flex items-center">
35-
<!-- <i class="zwicon-price-tag menu-icon"></i> -->
36-
<i class="ri-price-tag-3-line mr-2 text-base"></i>
37-
<span class="nav-text">{{ $t('tag') }}</span>
38-
</div>
39-
<span class="number">{{ site.tags.length }}</span>
40-
</div>
41-
</a-menu-item>
42-
<a-menu-item key="theme">
43-
<!-- <i class="zwicon-palette menu-icon"></i> -->
44-
<div class="flex items-center">
45-
<i class="ri-t-shirt-line mr-2 text-base"></i>
46-
<span class="nav-text">{{ $t('theme') }}</span>
47-
</div>
48-
</a-menu-item>
49-
<a-menu-item key="setting">
50-
<!-- <i class="zwicon-server-stack menu-icon"></i> -->
51-
<div class="flex items-center">
52-
<i class="ri-server-line mr-2 text-base"></i>
53-
<span class="nav-text">{{ $t('remote') }}</span>
22+
<span class="number">{{ menu.count }}</span>
5423
</div>
5524
</a-menu-item>
5625
</a-menu>
@@ -153,6 +122,43 @@ export default class App extends Vue {
153122
154123
log: any = {}
155124
125+
get currentRouter() {
126+
return this.$route.path
127+
}
128+
129+
get sideMenus() {
130+
return [
131+
{
132+
icon: 'ri-article-line',
133+
text: this.$t('article'),
134+
count: this.site.posts.length,
135+
router: '/articles',
136+
},
137+
{
138+
icon: 'ri-menu-2-line',
139+
text: this.$t('menu'),
140+
count: this.site.menus.length,
141+
router: '/menu',
142+
},
143+
{
144+
icon: 'ri-price-tag-3-line',
145+
text: this.$t('tag'),
146+
count: this.site.tags.length,
147+
router: '/tags',
148+
},
149+
{
150+
icon: 'ri-t-shirt-line',
151+
text: this.$t('theme'),
152+
router: '/theme',
153+
},
154+
{
155+
icon: 'ri-server-line',
156+
text: this.$t('remote'),
157+
router: '/setting',
158+
},
159+
]
160+
}
161+
156162
created() {
157163
this.$bus.$on('site-reload', () => {
158164
this.reloadSite()
@@ -319,7 +325,9 @@ export default class App extends Vue {
319325
}
320326
321327
/deep/ .ant-menu:not(.ant-menu-horizontal) .ant-menu-item-selected {
322-
background-color: #ece9e3;
328+
background-color: #fff;
329+
// @apply shadow;
330+
color: #000;
323331
}
324332
325333
/deep/ .ant-menu-inline, .ant-menu-vertical, .ant-menu-vertical-left {

0 commit comments

Comments
 (0)