Skip to content

Commit 37c133b

Browse files
author
reco_luan
authored
Merge pull request #52 from vuepress-reco/master
Master
2 parents 8018599 + 46b2a48 commit 37c133b

File tree

7 files changed

+80
-197
lines changed

7 files changed

+80
-197
lines changed

components/Common.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@touchstart="onTouchStart"
66
@touchend="onTouchEnd">
77
<transition name="fade">
8-
<Loading v-if="firstLoad"></Loading>
8+
<LoadingPage v-if="firstLoad"></LoadingPage>
99
<Password v-else-if="!isHasKey"></Password>
1010
<div v-else>
1111
<Navbar
@@ -42,12 +42,11 @@ import Navbar from '@theme/components/Navbar.vue'
4242
import Sidebar from '@theme/components/Sidebar.vue'
4343
import { resolveSidebarItems } from '../util'
4444
import Password from '@theme/components/Password'
45-
import Loading from '@theme/components/Loading'
4645
import Valine from '@theme/components/Valine/'
4746
import { setTimeout } from 'timers'
4847
4948
export default {
50-
components: { Sidebar, Navbar, Password, Valine, Loading },
49+
components: { Sidebar, Navbar, Password, Valine },
5150
5251
props: ['sidebar', 'isComment'],
5352

components/HomeBlog.vue

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,7 @@
4848
</ul>
4949
<hr>
5050
<h4><i class="iconfont reco-tag"></i> 标签</h4>
51-
<div class="tags">
52-
<span
53-
v-for="(item, index) in tags"
54-
:key="index"
55-
:style="{ 'backgroundColor': item.color }"
56-
@click="getPagesByTags(item.name)">{{item.name}}</span>
57-
</div>
51+
<TagList @getCurrentTag="getPagesByTags"></TagList>
5852
</div>
5953
</div>
6054

@@ -87,12 +81,11 @@
8781

8882
<script>
8983
import AccessNumber from '@theme/components/Valine/AccessNumber'
84+
import TagList from '@theme/components/TagList.vue'
9085
import NoteAbstract from '@theme/components/NoteAbstract.vue'
91-
import mixin from '@theme/mixins/index.js'
9286
9387
export default {
94-
mixins: [mixin],
95-
components: { AccessNumber, NoteAbstract },
88+
components: { AccessNumber, NoteAbstract, TagList },
9689
data () {
9790
return {
9891
recoShow: false,
@@ -156,17 +149,6 @@ export default {
156149
return document.querySelector('.hero').clientHeight
157150
}
158151
},
159-
created () {
160-
if (this.$tags.list.length > 0) {
161-
const tags = this.$tags.list
162-
tags.map(item => {
163-
const color = this._tagColor()
164-
item.color = color
165-
return tags
166-
})
167-
this.tags = tags
168-
}
169-
},
170152
mounted () {
171153
this.recoShow = true
172154
},
@@ -318,28 +300,6 @@ export default {
318300
}
319301
}
320302
}
321-
.tags {
322-
margin-bottom 30px
323-
span {
324-
vertical-align: middle;
325-
margin: 4px 4px 10px;
326-
padding: 4px 8px;
327-
display: inline-flex;
328-
cursor: pointer;
329-
border-radius: 2px;
330-
background: #fff;
331-
color: #fff;
332-
font-size: 13px;
333-
box-shadow 0 1px 4px 0 rgba(0,0,0,0.2)
334-
transition: all .5s
335-
&:hover {
336-
transform scale(1.04)
337-
}
338-
&.active {
339-
transform scale(1.2)
340-
}
341-
}
342-
}
343303
}
344304
}
345305

components/Loading.vue

Lines changed: 0 additions & 108 deletions
This file was deleted.

components/TagList.vue

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<template>
2+
<div class="tags">
3+
<span
4+
v-for="(item, index) in tags"
5+
:key="index"
6+
:class="{'active': item.name == currentTag}"
7+
:style="{ 'backgroundColor': item.color }"
8+
@click="tagClick(item.name)">{{item.name}}</span>
9+
</div>
10+
</template>
11+
12+
<script>
13+
import mixin from '@theme/mixins/index.js'
14+
15+
export default {
16+
mixins: [mixin],
17+
props: {
18+
currentTag: {
19+
type: String,
20+
default: ''
21+
}
22+
},
23+
data () {
24+
return {
25+
tags: []
26+
}
27+
},
28+
created () {
29+
if (this.$tags.list.length > 0) {
30+
const tags = this.$tags.list
31+
tags.map(item => {
32+
const color = this._tagColor()
33+
item.color = color
34+
return tags
35+
})
36+
this.tags = [{ name: '全部', color: this._tagColor() }, ...tags]
37+
}
38+
},
39+
methods: {
40+
tagClick (tag) {
41+
this.$emit('getCurrentTag', tag)
42+
}
43+
}
44+
}
45+
</script>
46+
47+
<style lang="stylus" scoped>
48+
.tags
49+
margin 30px 0
50+
span
51+
vertical-align: middle;
52+
margin: 4px 4px 10px;
53+
padding: 4px 8px;
54+
display: inline-block;
55+
cursor: pointer;
56+
border-radius: 2px;
57+
background: #fff;
58+
color: #fff;
59+
font-size: 13px;
60+
box-shadow 0 1px 4px 0 rgba(0,0,0,0.2)
61+
transition: all .5s
62+
&:hover
63+
transform scale(1.04)
64+
&.active
65+
transform scale(1.2)
66+
</style>

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ module.exports = (options, ctx) => ({
1818
},
1919

2020
plugins: [
21-
'@vuepress-reco/vuepress-plugin-back-to-top',
22-
'@vuepress-reco/vuepress-plugin-pagation',
23-
'@vuepress-reco/vuepress-plugin-screenfull',
21+
'@vuepress-reco/back-to-top',
22+
'@vuepress-reco/loading-page',
23+
'@vuepress-reco/pagation',
24+
'@vuepress-reco/screenfull',
2425
'@vuepress/active-header-links',
2526
['@vuepress/plugin-blog', {
2627
permalink: '/:regular',

layouts/Tags.vue

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
<template>
22
<div class="tags-wrapper" :class="recoShow?'reco-show': 'reco-hide'">
33
<Common :sidebar="false" :isComment="false"></Common>
4-
<div class="tags">
5-
<span
6-
v-for="(item, index) in tags"
7-
:key="index"
8-
:class="{'active': item.name == currentTag}"
9-
:style="{ 'backgroundColor': item.color }"
10-
@click="tagClick(item.name)">{{item.name}}</span>
11-
</div>
4+
<TagList :currentTag="currentTag" @getCurrentTag="tagClick"></TagList>
125
<note-abstract
136
class="list"
147
:data="posts"
@@ -26,13 +19,11 @@
2619

2720
<script>
2821
import Common from '@theme/components/Common.vue'
22+
import TagList from '@theme/components/TagList.vue'
2923
import NoteAbstract from '@theme/components/NoteAbstract.vue'
30-
import mixin from '@theme/mixins/index.js'
3124
3225
export default {
33-
mixins: [mixin],
34-
components: { Common, NoteAbstract },
35-
26+
components: { Common, NoteAbstract, TagList },
3627
data () {
3728
return {
3829
posts: [],
@@ -43,7 +34,6 @@ export default {
4334
allTagName: '全部'
4435
}
4536
},
46-
4737
computed: {
4838
// 时间降序后的博客列表
4939
handlePosts () {
@@ -58,17 +48,9 @@ export default {
5848
return posts
5949
}
6050
},
61-
6251
created () {
6352
if (this.$tags.list.length > 0) {
6453
const currentTag = this.$route.query.tag ? this.$route.query.tag : this.currentTag
65-
const tags = this.$tags.list
66-
tags.map(item => {
67-
const color = this._tagColor()
68-
item.color = color
69-
return tags
70-
})
71-
this.tags = [{ name: '全部', color: this._tagColor() }, ...tags]
7254
7355
this.getPagesByTags(currentTag)
7456
}
@@ -135,24 +117,6 @@ export default {
135117
max-width: 740px;
136118
margin: 0 auto;
137119
padding: 4.6rem 2.5rem 0;
138-
.tags
139-
margin 30px 0
140-
span
141-
vertical-align: middle;
142-
margin: 4px 4px 10px;
143-
padding: 4px 8px;
144-
display: inline-block;
145-
cursor: pointer;
146-
border-radius: 2px;
147-
background: #fff;
148-
color: #fff;
149-
font-size: 13px;
150-
box-shadow 0 1px 4px 0 rgba(0,0,0,0.2)
151-
transition: all .5s
152-
&:hover
153-
transform scale(1.04)
154-
&.active
155-
transform scale(1.2)
156120
&.reco-hide {
157121
.tags, .list, .pagation {
158122
load-start()

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuepress-theme-reco",
3-
"version": "1.0.9-alpha.6",
3+
"version": "1.0.9-alpha.8",
44
"description": "this is a vuepress theme",
55
"main": "index.js",
66
"scripts": {
@@ -27,6 +27,7 @@
2727
"_resolved": "http://registry.npm.taobao.org/vuepress-theme-reco/download/vuepress-theme-reco-0.2.1.tgz",
2828
"dependencies": {
2929
"@vuepress-reco/vuepress-plugin-back-to-top": "^1.0.3",
30+
"@vuepress-reco/vuepress-plugin-loading-page": "^1.0.0",
3031
"@vuepress-reco/vuepress-plugin-pagation": "^1.0.3",
3132
"@vuepress-reco/vuepress-plugin-screenfull": "^1.0.0",
3233
"@vuepress/plugin-blog": "1.3.0",

0 commit comments

Comments
 (0)