Skip to content

Commit 76403b4

Browse files
author
reco_luan
authored
Merge pull request #71 from vuepress-reco/feature/reco
fix: fix page password rules
2 parents 86d2d00 + 88ceaad commit 76403b4

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

components/Common.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export default {
137137
return
138138
}
139139
140-
this.isHasPageKey = pageKeys && pageKeys.indexOf(sessionStorage.getItem('pageKey')) > -1
140+
this.isHasPageKey = pageKeys && pageKeys.indexOf(sessionStorage.getItem(`pageKey${window.location.pathname}`)) > -1
141141
},
142142
toggleSidebar (to) {
143143
this.isSidebarOpen = typeof to === 'boolean' ? to : !this.isSidebarOpen

components/Page.vue

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,6 @@ export default {
144144
145145
mounted () {
146146
this.recoShow = true
147-
148-
const keys = this.$frontmatter.keys
149-
if (!keys) {
150-
this.isHasKey = true
151-
return
152-
}
153-
154-
this.isHasKey = keys && keys.indexOf(sessionStorage.getItem('pageKey')) > -1
155-
this.$parent.isHasPageKey = this.isHasKey
156147
},
157148
158149
methods: {

components/Password.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,24 @@ export default {
5252
computed: {
5353
year () {
5454
return new Date().getFullYear()
55+
},
56+
isHasKey () {
57+
const keyPage = this.$themeConfig.keyPage
58+
const keys = keyPage.keys
59+
return keys && keys.indexOf(sessionStorage.getItem('key')) > -1
60+
},
61+
isHasPageKey () {
62+
const pageKeys = this.$frontmatter.keys
63+
64+
return pageKeys && pageKeys.indexOf(sessionStorage.getItem(`pageKey${window.location.pathname}`)) > -1
5565
}
5666
},
5767
methods: {
5868
inter () {
5969
const keyVal = this.key.trim()
60-
const key = this.isPage ? 'pageKey' : 'key'
70+
const key = this.isPage ? `pageKey${window.location.pathname}` : 'key'
6171
sessionStorage.setItem(key, keyVal)
62-
const isHasKey = this.isPage ? this.isHasPageKey() : this.isHasKey()
72+
const isHasKey = this.isPage ? this.isHasPageKey : this.isHasKey
6373
if (!isHasKey) {
6474
this.warningText = 'Key Error'
6575
return
@@ -73,16 +83,6 @@ export default {
7383
window.location.reload()
7484
}, 800)
7585
},
76-
isHasKey () {
77-
const keyPage = this.$themeConfig.keyPage
78-
const keys = keyPage.keys
79-
return keys && keys.indexOf(sessionStorage.getItem('key')) > -1
80-
},
81-
isHasPageKey () {
82-
const pageKeys = this.$frontmatter.keys
83-
84-
return pageKeys && pageKeys.indexOf(sessionStorage.getItem('pageKey')) > -1
85-
},
8686
inputFocus () {
8787
this.warningText = 'Input Your Key'
8888
},

0 commit comments

Comments
 (0)