Skip to content

Commit beea671

Browse files
author
reco_luan
committed
feat(vuepress-theme-reco): support time localization
ISSUES CLOSED: #255
1 parent 1215e56 commit beea671

File tree

6 files changed

+8
-24
lines changed

6 files changed

+8
-24
lines changed

example/.vuepress/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = {
5353
},
5454
socialLinks: [
5555
{ icon: 'reco-github', link: 'https://github.com/recoluan' },
56-
{ icon: 'reco-npm', link: 'https://www.npmjs.com/~reco_luan' }
56+
{ icon: 'fa-camera', link: 'https://www.npmjs.com/~reco_luan' }
5757
]
5858
},
5959
logo: '/head.png',

example/en/views/category1/2019/092101.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: second page in category1
2+
title: second page in category12
33
date: 2019-09-21
44
tags:
55
- tag2

example/views/category1/2019/092101.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: sidebar test
3-
date: 2019-09-21
3+
date: '2019-09-21'
44
sidebarDepth: 5
55
tags:
66
- tag2

packages/vuepress-theme-reco/components/Page.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default {
117117
return false
118118
},
119119
lastUpdated () {
120-
return this.$page.lastUpdated
120+
return new Date(this.$page.lastUpdated).toLocaleString()
121121
},
122122
lastUpdatedText () {
123123
if (typeof this.$themeLocaleConfig.lastUpdated === 'string') {

packages/vuepress-theme-reco/components/PageInfo.vue

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
</template>
3636

3737
<script>
38-
// 引入时间格式化js文件
39-
import { formatDate } from '@theme/helpers/utils'
4038
import { RecoIcon } from '@vuepress-reco/core/lib/components'
4139
4240
export default {
@@ -68,23 +66,9 @@ export default {
6866
},
6967
filters: {
7068
formatDateValue (value) {
71-
if (!value) return ''
72-
// 返回的value的值都是这个样子2019-09-20T18:22:30.000Z
73-
// 对value进行处理
74-
value = value.replace('T', ' ').slice(0, value.lastIndexOf('.'))
75-
// 转化后的value 2019-09-20 18:22:30
76-
// 获取到时分秒
77-
const h = Number(value.substr(11, 2))
78-
const m = Number(value.substr(14, 2))
79-
const s = Number(value.substr(17, 2))
80-
// 判断时分秒是不是 00:00:00 (如果是用户手动输入的00:00:00也会不显示)
81-
if (h > 0 || m > 0 || s > 0) {
82-
// 时分秒有一个> 0 就说明用户输入一个非 00:00:00 的时分秒
83-
return formatDate(value)
84-
} else {
85-
// 用户没有输入或者输入了 00:00:00
86-
return formatDate(value, 'yyyy-MM-dd')
87-
}
69+
let localDate = new Date(value).toLocaleString()
70+
if (value.split(' ').length === 1) localDate = localDate.split(' ')[0]
71+
return localDate
8872
}
8973
},
9074
methods: {

packages/vuepress-theme-reco/components/PersonalInfo.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default {
108108
&:hover {
109109
transform scale(1.08)
110110
}
111-
.iconfont {
111+
i {
112112
cursor pointer
113113
font-size 22px
114114
}

0 commit comments

Comments
 (0)