Skip to content

Commit 18b156d

Browse files
committed
修复新特性提示徽章显示问题
1 parent adeb000 commit 18b156d

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

src/components/header.vue

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<template>
2-
<div id="header" class="d-flex">
2+
<div id="header">
33
<v-btn icon class="menu-icon" height="50" width="50" @click="showNav = !showNav">
44
<v-icon>mdi-menu</v-icon>
55
</v-btn>
6-
<v-navigation-drawer v-model="showNav" absolute temporary>
6+
<v-navigation-drawer v-model="showNav" absolute temporary style="height:100vh">
77
<v-list>
88
<v-list-item link v-for="item in navList" :key="item.name" @click="navJumpTo(item)">
9-
<v-badge v-if="item.text==='新特性' && showBadge" dot color="primary">
9+
<v-badge v-if="item.text==='新特性' && hasNewFeatures" dot color="primary">
1010
<v-list-item-title>{{item.text}}</v-list-item-title>
1111
</v-badge>
1212
<v-list-item-title v-else>{{item.text}}</v-list-item-title>
@@ -23,7 +23,7 @@
2323
<nav class="d-flex flex-1 no-select pointer">
2424
<v-btn v-for="(item, index) in navList" :key="index" class="nav-item rounded-0" @click="navJumpTo(item)" depressed
2525
:plain="curRouteName !== item.name" tile>
26-
<v-badge v-if="item.text==='新特性' && showBadge" dot color="primary">
26+
<v-badge v-if="item.text==='新特性' && hasNewFeatures" dot color="primary">
2727
{{item.text}}
2828
</v-badge>
2929
<span v-else>{{item.text}}</span>
@@ -37,6 +37,7 @@
3737
</template>
3838

3939
<script>
40+
import { mapState, mapMutations } from 'vuex'
4041
import HeaderAccount from './headerAccount.vue'
4142
import localStorage from '@utils/local-storage'
4243
@@ -61,37 +62,36 @@ export default {
6162
},
6263
],
6364
showNav: false,
64-
showBadge: true,
6565
}
6666
},
67-
created() {
67+
mounted() {
6868
this.judgeShowBadge()
6969
},
70+
computed: {
71+
...mapState(['hasNewFeatures']),
72+
curRouteName() {
73+
return this.$route.name
74+
},
75+
},
7076
methods: {
77+
...mapMutations(['setHasNewFeatures']),
7178
navJumpTo(navItem) {
7279
if (navItem.text === 'GitHub') {
7380
window.open('https://github.com/Longgererer/JS-Encoder-Online')
7481
} else {
75-
this.$router
76-
.push({
77-
name: navItem.name,
78-
})
79-
.catch(() => {})
82+
this.$router.push({ name: navItem.name }).catch(() => {})
8083
}
8184
},
8285
judgeShowBadge() {
8386
// 获取JS Encoder最新版本号,如果和本地localStorage存储的一致,则表示用户已读,不显示徽章
8487
this.$http.repoLatestV().then((res) => {
8588
const latestV = res.tag_name
86-
this.showBadge = latestV !== localStorage.get('latestViewVersion')
89+
this.setHasNewFeatures(
90+
latestV !== localStorage.get('latestViewVersion')
91+
)
8792
})
8893
},
8994
},
90-
computed: {
91-
curRouteName() {
92-
return this.$route.name
93-
},
94-
},
9595
components: {
9696
'header-account': HeaderAccount,
9797
},
@@ -102,6 +102,11 @@ export default {
102102
#header {
103103
height: 70px;
104104
padding: 0 30px;
105+
position: relative;
106+
// top: 0;
107+
z-index: 1;
108+
display: flex;
109+
// backdrop-filter: blur(10px);
105110
.menu-icon {
106111
display: none;
107112
}
@@ -142,6 +147,9 @@ export default {
142147
justify-content: center;
143148
}
144149
}
150+
::v-deep.v-overlay {
151+
bottom: -100vh;
152+
}
145153
}
146154
147155
@include Mobile {

0 commit comments

Comments
 (0)