2019-04-15 10:35:40 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<i
|
|
|
|
class="iconfont reco-account"
|
2019-05-08 15:13:18 +08:00
|
|
|
v-if="pageInfo.frontmatter.author || $themeConfig.author || $site.title">
|
|
|
|
<span>{{ pageInfo.frontmatter.author || $themeConfig.author || $site.title }}</span>
|
2019-04-15 10:35:40 +08:00
|
|
|
</i>
|
2019-10-15 19:56:50 +08:00
|
|
|
<i
|
|
|
|
v-if="pageInfo.frontmatter.date"
|
|
|
|
class="iconfont reco-date">
|
2019-12-05 14:59:03 +08:00
|
|
|
<span>{{ pageInfo.frontmatter.date | formatDateValue }}</span>
|
2019-10-15 19:56:50 +08:00
|
|
|
</i>
|
2019-10-16 15:06:20 +08:00
|
|
|
<i
|
2019-11-13 14:21:17 +08:00
|
|
|
v-if="hideAccessNumber !== true"
|
2019-10-16 15:06:20 +08:00
|
|
|
class="iconfont reco-eye">
|
|
|
|
<AccessNumber
|
|
|
|
:idVal="pageInfo.path"
|
|
|
|
:numStyle="numStyle" />
|
|
|
|
</i>
|
2019-10-15 19:56:50 +08:00
|
|
|
<i
|
|
|
|
v-if="pageInfo.frontmatter.tags"
|
|
|
|
class="iconfont reco-tag tags">
|
2019-04-15 10:35:40 +08:00
|
|
|
<span
|
|
|
|
v-for="(subItem, subIndex) in pageInfo.frontmatter.tags"
|
|
|
|
:key="subIndex"
|
|
|
|
class="tag-item"
|
|
|
|
:class="{ 'active': currentTag == subItem }"
|
|
|
|
@click="goTags(subItem)">
|
|
|
|
{{subItem}}
|
|
|
|
</span>
|
|
|
|
</i>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-10-10 21:35:49 +08:00
|
|
|
// 引入时间格式化js文件
|
2019-12-05 14:59:03 +08:00
|
|
|
import { formatDate } from '@theme/helpers/utils'
|
2019-04-15 10:35:40 +08:00
|
|
|
|
|
|
|
export default {
|
2019-07-20 19:38:25 +08:00
|
|
|
// props: ['pageInfo', 'currentTag'],
|
|
|
|
props: {
|
|
|
|
pageInfo: {
|
|
|
|
type: Object,
|
2019-09-20 13:54:13 +08:00
|
|
|
default () {
|
|
|
|
return {}
|
|
|
|
}
|
2019-07-20 19:38:25 +08:00
|
|
|
},
|
|
|
|
currentTag: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
2019-10-16 15:06:20 +08:00
|
|
|
hideAccessNumber: {
|
2019-07-20 19:38:25 +08:00
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
}
|
|
|
|
},
|
2019-04-15 10:35:40 +08:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
numStyle: {
|
|
|
|
fontSize: '.9rem',
|
|
|
|
fontWeight: 'normal',
|
|
|
|
color: '#999'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-10-09 09:45:19 +08:00
|
|
|
filters: {
|
2019-12-05 14:59:03 +08:00
|
|
|
formatDateValue (value) {
|
2019-10-09 09:45:19 +08:00
|
|
|
if (!value) return ''
|
|
|
|
// 返回的value的值都是这个样子2019-09-20T18:22:30.000Z
|
|
|
|
// 对value进行处理
|
2019-10-10 21:18:58 +08:00
|
|
|
value = value.replace('T', ' ').slice(0, value.lastIndexOf('.'))
|
2019-10-09 09:45:19 +08:00
|
|
|
// 转化后的value 2019-09-20 18:22:30
|
2019-10-10 21:18:58 +08:00
|
|
|
// 获取到时分秒
|
2019-10-09 09:45:19 +08:00
|
|
|
const h = Number(value.substr(11, 2))
|
|
|
|
const m = Number(value.substr(14, 2))
|
|
|
|
const s = Number(value.substr(17, 2))
|
2019-10-10 21:18:58 +08:00
|
|
|
// 判断时分秒是不是 00:00:00 (如果是用户手动输入的00:00:00也会不显示)
|
2019-10-09 09:45:19 +08:00
|
|
|
if (h > 0 || m > 0 || s > 0) {
|
2019-10-10 21:35:49 +08:00
|
|
|
// 时分秒有一个> 0 就说明用户输入一个非 00:00:00 的时分秒
|
2019-12-04 23:45:40 +08:00
|
|
|
return formatDate(value)
|
2019-10-10 21:18:58 +08:00
|
|
|
} else {
|
2019-10-09 09:45:19 +08:00
|
|
|
// 用户没有输入或者输入了 00:00:00
|
2019-12-04 23:45:40 +08:00
|
|
|
return formatDate(value, 'yyyy-MM-dd')
|
2019-10-09 09:45:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-04-15 10:35:40 +08:00
|
|
|
methods: {
|
|
|
|
goTags (tag) {
|
2019-11-20 16:47:05 +08:00
|
|
|
this.$router.push({ path: `/tags/${tag}/` })
|
2019-04-15 10:35:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
.iconfont
|
|
|
|
display inline-block
|
|
|
|
line-height 1.5rem
|
|
|
|
&:not(:last-child)
|
|
|
|
margin-right 1rem
|
2019-09-20 13:54:13 +08:00
|
|
|
span
|
2019-10-10 21:18:58 +08:00
|
|
|
margin-left 0.5rem
|
2019-04-15 10:35:40 +08:00
|
|
|
.tags
|
|
|
|
.tag-item
|
2019-10-10 21:18:58 +08:00
|
|
|
cursor pointer
|
|
|
|
font-family Ubuntu, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif
|
2019-04-15 10:35:40 +08:00
|
|
|
&.active
|
|
|
|
color $accentColor
|
2019-09-20 13:54:13 +08:00
|
|
|
&:hover
|
2019-04-15 10:35:40 +08:00
|
|
|
color $accentColor
|
|
|
|
@media (max-width: $MQMobile)
|
|
|
|
.tags
|
|
|
|
display block
|
2019-10-10 21:18:58 +08:00
|
|
|
margin-left 0 !important
|
2019-04-15 10:35:40 +08:00
|
|
|
</style>
|