fix: fix page password rules

This commit is contained in:
reco_luan 2019-10-21 13:03:30 +08:00
parent d5c22e8e66
commit 88ceaad5a9
3 changed files with 13 additions and 22 deletions

View File

@ -137,7 +137,7 @@ export default {
return
}
this.isHasPageKey = pageKeys && pageKeys.indexOf(sessionStorage.getItem('pageKey')) > -1
this.isHasPageKey = pageKeys && pageKeys.indexOf(sessionStorage.getItem(`pageKey${window.location.pathname}`)) > -1
},
toggleSidebar (to) {
this.isSidebarOpen = typeof to === 'boolean' ? to : !this.isSidebarOpen

View File

@ -144,15 +144,6 @@ export default {
mounted () {
this.recoShow = true
const keys = this.$frontmatter.keys
if (!keys) {
this.isHasKey = true
return
}
this.isHasKey = keys && keys.indexOf(sessionStorage.getItem('pageKey')) > -1
this.$parent.isHasPageKey = this.isHasKey
},
methods: {

View File

@ -52,14 +52,24 @@ export default {
computed: {
year () {
return new Date().getFullYear()
},
isHasKey () {
const keyPage = this.$themeConfig.keyPage
const keys = keyPage.keys
return keys && keys.indexOf(sessionStorage.getItem('key')) > -1
},
isHasPageKey () {
const pageKeys = this.$frontmatter.keys
return pageKeys && pageKeys.indexOf(sessionStorage.getItem(`pageKey${window.location.pathname}`)) > -1
}
},
methods: {
inter () {
const keyVal = this.key.trim()
const key = this.isPage ? 'pageKey' : 'key'
const key = this.isPage ? `pageKey${window.location.pathname}` : 'key'
sessionStorage.setItem(key, keyVal)
const isHasKey = this.isPage ? this.isHasPageKey() : this.isHasKey()
const isHasKey = this.isPage ? this.isHasPageKey : this.isHasKey
if (!isHasKey) {
this.warningText = 'Key Error'
return
@ -73,16 +83,6 @@ export default {
window.location.reload()
}, 800)
},
isHasKey () {
const keyPage = this.$themeConfig.keyPage
const keys = keyPage.keys
return keys && keys.indexOf(sessionStorage.getItem('key')) > -1
},
isHasPageKey () {
const pageKeys = this.$frontmatter.keys
return pageKeys && pageKeys.indexOf(sessionStorage.getItem('pageKey')) > -1
},
inputFocus () {
this.warningText = 'Input Your Key'
},