File tree 7 files changed +120
-37
lines changed
7 files changed +120
-37
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <component :is =" layout" :slot-key =" slotKey || 'default'" />
3
+ </template >
4
+
5
+ <script >
6
+ import Vue from ' vue'
7
+ import components from ' @internal/page-components'
8
+ import ContentLoading from ' ./ContentLoading'
9
+
10
+ export default {
11
+ components: { ContentLoading },
12
+
13
+ props: {
14
+ pageKey: String ,
15
+ slotKey: String
16
+ },
17
+
18
+ data () {
19
+ return {
20
+ layout: ' ContentLoading'
21
+ }
22
+ },
23
+
24
+ computed: {
25
+ $key () {
26
+ return this .pageKey || this .$page .key
27
+ }
28
+ },
29
+
30
+ created () {
31
+ this .loadContent (this .$key )
32
+ },
33
+
34
+ watch: {
35
+ $key (key) {
36
+ this .loadContent (key)
37
+ }
38
+ },
39
+
40
+ methods: {
41
+ loadContent (pageKey ) {
42
+ if (Vue .component (pageKey)) {
43
+ return
44
+ }
45
+ this .layout = ' ContentLoading'
46
+ if (components[pageKey]) {
47
+ if (! this .$ssrContext ) {
48
+ Promise .all ([
49
+ components[pageKey](),
50
+ new Promise (resolve => setTimeout (resolve, 0 ))
51
+ ]).then (([comp ]) => {
52
+ this .$vuepress .$emit (' AsyncMarkdownAssetLoaded' , this .pageKey )
53
+ Vue .component (pageKey, comp .default )
54
+ this .layout = pageKey
55
+ })
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ </script >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" content content-loading" >
3
+ <ContentLoader
4
+ :height =" 120"
5
+ :width =" 300"
6
+ :speed =" 0.5"
7
+ primaryColor =" #f3f3f3"
8
+ secondaryColor =" #ecebeb"
9
+ >
10
+ <rect x =" 0" y =" 5" rx =" 5" ry =" 5" width =" 117" height =" 10" />
11
+ <rect x =" 0" y =" 25" rx =" 5" ry =" 5" width =" 85" height =" 10" />
12
+ <rect x =" 0" y =" 60" rx =" 5" ry =" 5" width =" 250" height =" 10" />
13
+ <rect x =" 0" y =" 80" rx =" 5" ry =" 5" width =" 280" height =" 10" />
14
+ <rect x =" 0" y =" 100" rx =" 5" ry =" 5" width =" 201" height =" 10" />
15
+ </ContentLoader >
16
+ </div >
17
+ </template >
18
+
19
+ <script >
20
+ import { ContentLoader } from ' vue-content-loader'
21
+
22
+ export default {
23
+ components: {
24
+ ContentLoader
25
+ },
26
+
27
+ data () {
28
+ return {
29
+ containerStyle: {}
30
+ }
31
+ }
32
+ }
33
+ </script >
34
+
35
+ <style >
36
+ @media screen and (min-width : 719px ) {
37
+ .content.content-loading > svg {
38
+ max-width : 400px !important ;
39
+ }
40
+ }
41
+ @media screen and (max-width : 719px ) {
42
+ .content.content-loading > svg {
43
+ max-width : 320px !important ;
44
+ }
45
+ }
46
+
47
+ </style >
Original file line number Diff line number Diff line change 67
67
"webpack-chain" : " ^4.6.0" ,
68
68
"webpack-merge" : " ^4.1.2" ,
69
69
"webpack-serve" : " ^1.0.2" ,
70
- "webpackbar" : " ^2.6.1"
70
+ "webpackbar" : " ^2.6.1" ,
71
+ "vue-content-loader" : " ^0.2.1"
71
72
},
72
73
"engines" : {
73
74
"node" : " >=8"
Original file line number Diff line number Diff line change @@ -44,13 +44,13 @@ Suppose your layout component is as follows:
44
44
<template>
45
45
<div class="container">
46
46
<header>
47
- <Content slot="header"/>
47
+ <Content slot-key ="header"/>
48
48
</header>
49
49
<main>
50
50
<Content/>
51
51
</main>
52
52
<footer>
53
- <Content slot="footer"/>
53
+ <Content slot-key ="footer"/>
54
54
</footer>
55
55
</div>
56
56
</template>
Original file line number Diff line number Diff line change @@ -44,13 +44,13 @@ Markdown 插槽便是为了解决这一类问题。
44
44
<template>
45
45
<div class="container">
46
46
<header>
47
- <Content slot="header"/>
47
+ <Content slot-key ="header"/>
48
48
</header>
49
49
<main>
50
50
<Content/>
51
51
</main>
52
52
<footer>
53
- <Content slot="footer"/>
53
+ <Content slot-key ="footer"/>
54
54
</footer>
55
55
</div>
56
56
</template>
Original file line number Diff line number Diff line change 9045
9045
dependencies :
9046
9046
indexof "0.0.1"
9047
9047
9048
+ vue-content-loader@^0.2.1 :
9049
+ version "0.2.1"
9050
+ resolved "https://registry.yarnpkg.com/vue-content-loader/-/vue-content-loader-0.2.1.tgz#0eb332e2a72643d57fb209d72d6526573b191f5a"
9051
+ dependencies :
9052
+ babel-helper-vue-jsx-merge-props "^2.0.3"
9053
+
9048
9054
vue-eslint-parser@^2.0.3 :
9049
9055
version "2.0.3"
9050
9056
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-2.0.3.tgz#c268c96c6d94cfe3d938a5f7593959b0ca3360d1"
You can’t perform that action at this time.
0 commit comments