Merge pull request #18 from recoluan/feature/0.x

1. 更新keys报错;2. 优化时间轴列表按时间降序
This commit is contained in:
reco_luan 2019-04-09 14:42:11 +08:00 committed by GitHub
commit 2d4f3449bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 10 deletions

View File

@ -132,10 +132,11 @@ export default {
const keyPage = this.$site.themeConfig.keyPage
if (!keyPage) {
this.isHasKey = true
return
}
const {keys} = keyPage
this.isHasKey = keys.indexOf(sessionStorage.getItem('key')) > -1
const keys = keyPagekeys
this.isHasKey = keys && keys.indexOf(sessionStorage.getItem('key')) > -1
},
methods: {

View File

@ -67,8 +67,8 @@ export default {
},
isHasKey () {
const keyPage = this.$site.themeConfig.keyPage
const {keys} = keyPage
return keys.indexOf(sessionStorage.getItem('key')) > -1
const keys = keyPage.keys
return keys && keys.indexOf(sessionStorage.getItem('key')) > -1
},
inputFocus () {
this.warningText = 'Input Your Key'

View File

@ -2,10 +2,10 @@
<div>
<ul class="timeline-wrapper">
<li class="desc">Yesterday Once More!</li>
<li v-for="(item, index) in formatPagesArr">
<li v-for="(item, index) in formatPagesArr" :key="index">
<h3 class="year">{{item.year}}</h3>
<ul class="year-wrapper">
<li v-for="(subItem, subIndex) in item.data">
<li v-for="(subItem, subIndex) in item.data" :key="subIndex">
<span class="date">{{dateFormat(new Date(subItem.frontmatter.date))}}</span>
<span class="title" @click="go(subItem.path)">{{subItem.title}}</span>
</li>
@ -65,11 +65,12 @@ export default {
}
}
for(let key in this.formatPages) {
this.formatPagesArr.unshift({
year: key,
data: this.formatPages[key].reverse()
data: this.formatPages[key].sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)
})
})
}
},
@ -85,6 +86,10 @@ export default {
//
go (url) {
this.$router.push({path: url})
},
//
_getTimeNum (date) {
return parseInt(new Date(date.frontmatter.date).getTime())
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "vuepress-theme-reco",
"version": "0.3.9",
"version": "0.3.10",
"description": "this is a vuepress theme",
"main": "index.js",
"scripts": {