Merge pull request #53 from vuepress-reco/feature/lxb

Feature/lxb
This commit is contained in:
reco_luan 2019-10-09 10:42:06 +08:00 committed by GitHub
commit 18d46f1cdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 18 deletions

View File

@ -1,6 +1,6 @@
<template>
<div class="home-blog" :class="recoShow?'reco-show': 'reco-hide'">
<div class="hero" :style="{background: `url(${$frontmatter.bgImage ? $withBase($frontmatter.bgImage) : require('../images/home-bg.jpg')}) center/cover no-repeat`, ...bgImageStyle}">
<div class="hero" :style="{background: `url(${$frontmatter.bgImage ? $withBase($frontmatter.bgImage) : require('../images/home-bg.jpg')}) center/cover no-repeat`, ...bgImageStyle}">
<h1>{{ data.heroText || $title || '午后南杂' }}</h1>
<p class="description">{{ data.tagline || $description || 'Welcome to your vuePress-theme-reco site' }}</p>
@ -22,21 +22,21 @@
@getCurrentPage="getCurrentPage" />
</div>
<div class="info-wrapper">
<img class="personal-img" :src="$frontmatter.faceImage ? $withBase($frontmatter.faceImage) : require('../images/home-head.png')" alt="hero">
<h3 class="name" v-if="$themeConfig.author || $site.title">{{ $themeConfig.author || $site.title }}</h3>
<div class="num">
<div>
<h3>{{getPagesLength}}</h3>
<h6>文章</h6>
</div>
<div>
<h3>{{$tags.list.length}}</h3>
<h6>标签</h6>
</div>
</div>
<hr>
<h4><i class="iconfont reco-category"></i> 分类</h4>
<ul class="category-wrapper">
<img class="personal-img" :src="$frontmatter.faceImage ? $withBase($frontmatter.faceImage) : require('../images/home-head.png')" alt="hero">
<h3 class="name" v-if="$themeConfig.author || $site.title">{{ $themeConfig.author || $site.title }}</h3>
<div class="num">
<div>
<h3>{{getPagesLength}}</h3>
<h6>文章</h6>
</div>
<div>
<h3>{{$tags.list.length}}</h3>
<h6>标签</h6>
</div>
</div>
<hr>
<h4><i class="iconfont reco-category"></i> 分类</h4>
<ul class="category-wrapper">
<li class="category-item" v-for="(item, index) in this.$categories.list" :key="index">
<router-link :to="item.path">
<span class="category-name">{{ item.name }}</span>

View File

@ -5,7 +5,7 @@
v-if="pageInfo.frontmatter.author || $themeConfig.author || $site.title">
<span>{{ pageInfo.frontmatter.author || $themeConfig.author || $site.title }}</span>
</i>
<i class="iconfont reco-date" v-if="pageInfo.frontmatter.date"><span>{{ new Date(pageInfo.frontmatter.date).toLocaleDateString() }}</span></i>
<i class="iconfont reco-date" v-if="pageInfo.frontmatter.date"><span>{{ pageInfo.frontmatter.date | formatDate }}</span></i>
<AccessNumber v-if="isHome !== true" :idVal="pageInfo.path" :numStyle="numStyle"></AccessNumber>
<i class="iconfont reco-tag tags" v-if="pageInfo.frontmatter.tags">
<span
@ -22,6 +22,8 @@
<script>
import AccessNumber from './Valine/AccessNumber'
//js
import { fromatDateTime } from '@theme/util/formatDate.js'
export default {
components: { AccessNumber },
@ -51,7 +53,27 @@ export default {
}
}
},
filters: {
formatDate: function (value) {
if (!value) return ''
// value2019-09-20T18:22:30.000Z
// value
value = value.replace('T', ' ').slice(0,value.lastIndexOf('.'))
// value 2019-09-20 18:22:30
// 00:00:00 (00:00:00)
const h = Number(value.substr(11, 2))
const m = Number(value.substr(14, 2))
const s = Number(value.substr(17, 2))
// > 0 00:00:00
if (h > 0 || m > 0 || s > 0) {
return fromatDateTime(value)
}else {
// 00:00:00
return new Date(value).toLocaleDateString()
}
}
},
methods: {
goTags (tag) {
const base = this.$site.base

21
util/formatDate.js Normal file
View File

@ -0,0 +1,21 @@
/**
* 时间格式化的方法
* 创建时间2019-10-08
* 作者刘晓北
* 邮箱 15732451723@163.com
*/
// 将时间格式化成 YYYY/MM/DD HH:mm:SS
export const fromatDateTime = (time) => {
const date = new Date(time)
const Y = date.getFullYear()
const M = date.getMonth() + 1
const D = date.getDate()
let H = date.getHours()
H = H > 9 ? H : '0' + H
let m = date.getMinutes()
m = m > 9 ? m : '0' + m
let S = date.getSeconds()
S = S > 9 ? S : '0' + S
return Y + '/' + M + '/' + D + ' ' + H + ':' + m + ':' + S
}