vuepress-theme-uniapp-official 1.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/components/AlgoliaSearchBox.vue +130 -0
- package/components/DcloudSearchPage/components/Result.vue +160 -0
- package/components/DcloudSearchPage/components/Results.vue +66 -0
- package/components/DcloudSearchPage/components/pagination.vue +155 -0
- package/components/DcloudSearchPage/index.styl +183 -0
- package/components/DcloudSearchPage/index.vue +500 -0
- package/components/DcloudSearchPage/styles/ask.styl +272 -0
- package/components/DcloudSearchPage/styles/ext.styl +68 -0
- package/components/DcloudSearchPage/utils/Base64.js +134 -0
- package/components/DcloudSearchPage/utils/mock.js +434 -0
- package/components/DcloudSearchPage/utils/postDcloudServer.js +141 -0
- package/components/DcloudSearchPage/utils/searchClient.js +101 -0
- package/components/DcloudSearchPage/utils/searchUtils.js +52 -0
- package/components/Footer.vue +142 -0
- package/components/MainNavbarLink.vue +57 -0
- package/components/NavLink.vue +95 -0
- package/components/NavLinks.vue +173 -0
- package/components/Navbar.vue +322 -0
- package/components/NavbarLogo.vue +24 -0
- package/components/OutboundLink.vue +45 -0
- package/components/SearchBox/dist/match-query.dev.js +61 -0
- package/components/SearchBox/index.vue +337 -0
- package/components/SearchBox/match-query.js +51 -0
- package/components/SearchBox/search.svg +1 -0
- package/components/SidebarGroup.vue +141 -0
- package/components/SidebarLink.vue +152 -0
- package/components/SidebarLinks.vue +106 -0
- package/components/SiderBarBottom.vue +134 -0
- package/components/Sticker.vue +64 -0
- package/components/Toc-top.vue +95 -0
- package/components/Toc.vue +165 -0
- package/config/copy.js +7 -0
- package/config/footer.js +195 -0
- package/config/i18n/index.js +2 -0
- package/config/navbar.js +163 -0
- package/config/redirectRouter.js +120 -0
- package/config/searchPage.js +48 -0
- package/config/siderbar/index.js +8 -0
- package/config/siderbar/uni-app.js +210 -0
- package/config/siderbar/uniCloud.js +55 -0
- package/config/toc.js +5 -0
- package/enhanceApp.js +142 -0
- package/global-components/CodeSimulator.vue +211 -0
- package/global-components/icons.js +647 -0
- package/global-components/iconsLayouts.vue +117 -0
- package/global-components/uniIcon.vue +85 -0
- package/global-components/uniicons.css +656 -0
- package/global-components/uniicons.ttf +0 -0
- package/index.js +152 -0
- package/layouts/404.vue +22 -0
- package/layouts/Layout.vue +238 -0
- package/layouts/SimpleLayout.vue +18 -0
- package/mixin/navInject.js +21 -0
- package/mixin/navProvider.js +65 -0
- package/mixin/toc.js +36 -0
- package/package.json +50 -0
- package/styles/custom-block.styl +336 -0
- package/styles/footer.styl +248 -0
- package/styles/index.styl +197 -0
- package/styles/navbar.styl +293 -0
- package/styles/palette.styl +9 -0
- package/util/index.js +317 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
contactItems: [{
|
|
3
|
+
name: 'uniCloud Web控制台',
|
|
4
|
+
url: 'https://unicloud.dcloud.net.cn',
|
|
5
|
+
imageUrl: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/7962e8e0-4f2d-11eb-a16f-5b3e54966275.jpg'
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
name: '论坛',
|
|
9
|
+
url: 'https://ask.dcloud.net.cn/explore/',
|
|
10
|
+
imageUrl: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/73fc4f90-4f2d-11eb-a16f-5b3e54966275.png'
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'uniAD',
|
|
14
|
+
url: 'https://uniad.dcloud.net.cn',
|
|
15
|
+
imageUrl: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/765d9820-4f2d-11eb-bd01-97bc1429a9ff.png'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'uni统计',
|
|
19
|
+
url: 'https://tongji.dcloud.net.cn/',
|
|
20
|
+
imageUrl: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/77159d80-4f2d-11eb-a16f-5b3e54966275.png'
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
codeHosting: [{
|
|
24
|
+
name: '码云',
|
|
25
|
+
url: 'https://gitee.com/dcloud/uni-app'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'GitHub',
|
|
29
|
+
url: 'http://github.com/dcloudio/uni-app'
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
qq_group: [
|
|
33
|
+
{
|
|
34
|
+
"number": "531031261",
|
|
35
|
+
"state": 1,
|
|
36
|
+
"prefix": "群1"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"number": "901474938",
|
|
40
|
+
"state": 1,
|
|
41
|
+
"prefix": "群2"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"number": "773794803",
|
|
45
|
+
"state": 1,
|
|
46
|
+
"prefix": "群3"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"number": "942702595",
|
|
50
|
+
"state": 1,
|
|
51
|
+
"prefix": "群4"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"number": "731951419",
|
|
55
|
+
"state": 1,
|
|
56
|
+
"prefix": "群5"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"number": "697264024",
|
|
60
|
+
"state": 1,
|
|
61
|
+
"prefix": "群6"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"number": "942061423",
|
|
65
|
+
"state": 1,
|
|
66
|
+
"prefix": "群7"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"number": "695442854",
|
|
70
|
+
"state": 1,
|
|
71
|
+
"prefix": "群8"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"number": "775128777",
|
|
75
|
+
"state": 1,
|
|
76
|
+
"prefix": "群9"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"number": "959059626",
|
|
80
|
+
"state": 1,
|
|
81
|
+
"prefix": "群10"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"number": "296811328",
|
|
85
|
+
"state": 1,
|
|
86
|
+
"prefix": "群11"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"number": "884860657",
|
|
90
|
+
"state": 1,
|
|
91
|
+
"prefix": "群12"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"number": "699478442",
|
|
95
|
+
"state": 1,
|
|
96
|
+
"prefix": "群13"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"number": "465953250",
|
|
100
|
+
"state": 1,
|
|
101
|
+
"prefix": "群14"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"number": "719211033",
|
|
105
|
+
"state": 1,
|
|
106
|
+
"prefix": "群16"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"number": "951348804",
|
|
110
|
+
"state": 1,
|
|
111
|
+
"prefix": "群17"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"number": "698592271",
|
|
115
|
+
"state": 1,
|
|
116
|
+
"prefix": "群18"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"number": "165657124",
|
|
120
|
+
"state": 1,
|
|
121
|
+
"prefix": "群19"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"number": "165796402",
|
|
125
|
+
"state": 1,
|
|
126
|
+
"prefix": "群20"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"number": "717019120",
|
|
130
|
+
"state": 1,
|
|
131
|
+
"prefix": "群21"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"number": "687186952",
|
|
135
|
+
"state": 1,
|
|
136
|
+
"prefix": "群22"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"number": "599958679",
|
|
140
|
+
"state": 1,
|
|
141
|
+
"prefix": "群23"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"number": "672494800",
|
|
145
|
+
"state": 1,
|
|
146
|
+
"prefix": "群24"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"number": "165297000",
|
|
150
|
+
"state": 1,
|
|
151
|
+
"prefix": "群25"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"number": "147867597",
|
|
155
|
+
"state": 1,
|
|
156
|
+
"prefix": "群26"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"number": "811363410",
|
|
160
|
+
"state": 1,
|
|
161
|
+
"prefix": "群27"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"number": "166188776",
|
|
165
|
+
"state": 1,
|
|
166
|
+
"prefix": "群28"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"number": "202965481",
|
|
170
|
+
"state": 1,
|
|
171
|
+
"prefix": "群29"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"number": "371046920",
|
|
175
|
+
"state": 1,
|
|
176
|
+
"prefix": "群30"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"number": "567471669",
|
|
180
|
+
"state": 1,
|
|
181
|
+
"prefix": "群31"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"number": "166188631",
|
|
185
|
+
"state": 1,
|
|
186
|
+
"prefix": "群32"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"number": "498071674",
|
|
190
|
+
"state": 1,
|
|
191
|
+
"prefix": "群33"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"number": "530305531",
|
|
195
|
+
"state": 1,
|
|
196
|
+
"prefix": "群34"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"number": "713420817",
|
|
200
|
+
"state": 1,
|
|
201
|
+
"prefix": "群35"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"number": "516984120",
|
|
205
|
+
"state": 0,
|
|
206
|
+
"prefix": "群15"
|
|
207
|
+
}
|
|
208
|
+
],
|
|
209
|
+
joinQQGroupHref: 'https://qm.qq.com/cgi-bin/qm/qr?k=nsW1gqNT9LqZLfcyntjd1paIKUzWewHN&jump_from=webapi'
|
|
210
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
contactItems: [
|
|
3
|
+
{
|
|
4
|
+
name: 'uniCloud Web控制台',
|
|
5
|
+
url: 'https://unicloud.dcloud.net.cn',
|
|
6
|
+
imageUrl: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/7962e8e0-4f2d-11eb-a16f-5b3e54966275.jpg'
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: '论坛',
|
|
10
|
+
url: 'https://ask.dcloud.net.cn/explore/',
|
|
11
|
+
imageUrl: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/73fc4f90-4f2d-11eb-a16f-5b3e54966275.png'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'uniAD',
|
|
15
|
+
url: 'https://uniad.dcloud.net.cn',
|
|
16
|
+
imageUrl: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/765d9820-4f2d-11eb-bd01-97bc1429a9ff.png'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'uni统计',
|
|
20
|
+
url: 'https://tongji.dcloud.net.cn/',
|
|
21
|
+
imageUrl: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/77159d80-4f2d-11eb-a16f-5b3e54966275.png'
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
qq_group: [
|
|
25
|
+
{
|
|
26
|
+
"number": "1012245137",
|
|
27
|
+
"state": 1,
|
|
28
|
+
"prefix": "群1"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"number": "749911289",
|
|
32
|
+
"state": 1,
|
|
33
|
+
attendance: 1000,
|
|
34
|
+
"prefix": "群2"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"number": "599819864",
|
|
38
|
+
"state": 1,
|
|
39
|
+
attendance: 1000,
|
|
40
|
+
"prefix": "群3"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"number": "641753405",
|
|
44
|
+
"state": 1,
|
|
45
|
+
attendance: 1000,
|
|
46
|
+
"prefix": "群4"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"number": "806429316",
|
|
50
|
+
"state": 0,
|
|
51
|
+
"prefix": "群5"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
joinQQGroupHref: 'https://qm.qq.com/cgi-bin/qm/qr?k=ez84UYIZgPKpTvrXD8GINUr62u8CF96x&jump_from=webapi'
|
|
55
|
+
}
|
package/config/toc.js
ADDED
package/enhanceApp.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import getRedirectRouter from '@theme-config/redirectRouter';
|
|
2
|
+
import VueRouter from 'vue-router';
|
|
3
|
+
import { isServer } from './util';
|
|
4
|
+
import OutboundLink from '@theme/components/OutboundLink.vue';
|
|
5
|
+
|
|
6
|
+
const originalPush = VueRouter.prototype.push;
|
|
7
|
+
VueRouter.prototype.push = function push(location, resolve, reject) {
|
|
8
|
+
if (resolve || reject) return originalPush.call(this, location, resolve, reject);
|
|
9
|
+
return originalPush.call(this, location).catch(err => err);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function handleRedirectForCleanUrls(router, to) {
|
|
13
|
+
if (isRouteExists(router, to.path)) {
|
|
14
|
+
return to.path;
|
|
15
|
+
} else {
|
|
16
|
+
if (!/(\/|\.html)$/.test(to.path)) {
|
|
17
|
+
const endingSlashUrl = to.path + '/';
|
|
18
|
+
const endingHtmlUrl = to.path + '.html';
|
|
19
|
+
if (isRouteExists(router, endingHtmlUrl)) {
|
|
20
|
+
return endingHtmlUrl;
|
|
21
|
+
} else if (isRouteExists(router, endingSlashUrl)) {
|
|
22
|
+
return endingSlashUrl;
|
|
23
|
+
} else {
|
|
24
|
+
return to.path.replace(/\.md$/, '');
|
|
25
|
+
}
|
|
26
|
+
} else if (/\/$/.test(to.path)) {
|
|
27
|
+
const endingHtmlUrl = to.path.replace(/\/$/, '') + '.html';
|
|
28
|
+
if (isRouteExists(router, endingHtmlUrl)) {
|
|
29
|
+
return endingHtmlUrl;
|
|
30
|
+
} else {
|
|
31
|
+
return to.path;
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
return to.path;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isRouteExists(router, path) {
|
|
40
|
+
const pathLower = path.toLowerCase();
|
|
41
|
+
return router.options.routes.some(route => route.path.toLowerCase() === pathLower);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function resolveRouterBase(router, redirectPath) {
|
|
45
|
+
if (router.options.base !== '/') redirectPath = (router.options.base + redirectPath).replace(/\/\//g, '/');
|
|
46
|
+
return redirectPath;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function handlePath(router, to) {
|
|
50
|
+
// 重定向路由表
|
|
51
|
+
const redirectRouter = getRedirectRouter(to);
|
|
52
|
+
if (redirectRouter && !isServer) return location.replace(redirectRouter.path + (redirectRouter.hash || ''));
|
|
53
|
+
|
|
54
|
+
const id = to.query.id;
|
|
55
|
+
delete to.query.id;
|
|
56
|
+
let hash = decodeURIComponent(id || to.hash).toLowerCase();
|
|
57
|
+
if (hash && hash.indexOf('#') !== 0) hash = '#' + hash;
|
|
58
|
+
const redirectPath = handleRedirectForCleanUrls(router, to);
|
|
59
|
+
if (id) {
|
|
60
|
+
return {
|
|
61
|
+
path: resolveRouterBase(router, redirectPath),
|
|
62
|
+
replace: true,
|
|
63
|
+
hash,
|
|
64
|
+
query: to.query,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (redirectPath !== to.path) {
|
|
68
|
+
return {
|
|
69
|
+
path: resolveRouterBase(router, redirectPath),
|
|
70
|
+
replace: true,
|
|
71
|
+
hash,
|
|
72
|
+
query: to.query,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (/\bREADME\b/.test(to.path)) {
|
|
76
|
+
return {
|
|
77
|
+
path: to.path.replace(/\bREADME\b/, ''),
|
|
78
|
+
replace: true,
|
|
79
|
+
hash,
|
|
80
|
+
query: to.query,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default ({ Vue, options, router, siteData }) => {
|
|
86
|
+
let mounted = Vue.$vuepress.store._isMounted;
|
|
87
|
+
// debugger
|
|
88
|
+
const ScrollBehavior = 'instant';
|
|
89
|
+
|
|
90
|
+
router.beforeHooks.unshift((to, from, next) => {
|
|
91
|
+
const _next = handlePath(router, to);
|
|
92
|
+
if (_next && /\.html$/.test(_next.path) && !isServer) return location.replace(_next.path + (_next.hash || ''));
|
|
93
|
+
else next(_next);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
router.options.scrollBehavior = function scrollBehavior(to, from, savedPosition) {
|
|
97
|
+
if (savedPosition) {
|
|
98
|
+
return window.scrollTo({
|
|
99
|
+
top: savedPosition.y,
|
|
100
|
+
behavior: ScrollBehavior,
|
|
101
|
+
});
|
|
102
|
+
} else if (to.hash) {
|
|
103
|
+
if (Vue.$vuepress.$get('disableScrollBehavior')) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
const selector = decodeURIComponent(to.hash.toLowerCase());
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
setTimeout(
|
|
109
|
+
() => {
|
|
110
|
+
if (!mounted) mounted = true;
|
|
111
|
+
const targetElement = document.querySelector(selector);
|
|
112
|
+
if (targetElement) {
|
|
113
|
+
return window.scrollTo({
|
|
114
|
+
top: getElementPosition(targetElement).y,
|
|
115
|
+
behavior: ScrollBehavior,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return resolve(false);
|
|
119
|
+
},
|
|
120
|
+
mounted ? 0 : 700
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
return window.scrollTo({
|
|
125
|
+
top: 0,
|
|
126
|
+
behavior: ScrollBehavior,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
Vue.component('OutboundLink', OutboundLink);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
function getElementPosition(el) {
|
|
135
|
+
const docEl = document.documentElement;
|
|
136
|
+
const docRect = docEl.getBoundingClientRect();
|
|
137
|
+
const elRect = el.getBoundingClientRect();
|
|
138
|
+
return {
|
|
139
|
+
x: elRect.left - docRect.left,
|
|
140
|
+
y: elRect.top - docRect.top,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import clientRootMixin from 'vuepress-plugin-juejin-style-copy/clientRootMixin';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
mixins:[clientRootMixin],
|
|
6
|
+
props:{
|
|
7
|
+
src:{
|
|
8
|
+
type:String,
|
|
9
|
+
default:''
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
data(){
|
|
13
|
+
return {
|
|
14
|
+
activeIndex: 0
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
mounted(){
|
|
18
|
+
this.$copyUpdates && this.$copyUpdates()
|
|
19
|
+
this.onWindowResize()
|
|
20
|
+
window.addEventListener('resize', this.onWindowResize)
|
|
21
|
+
},
|
|
22
|
+
beforeDestroy(){
|
|
23
|
+
window.removeEventListener('resize', this.onWindowResize)
|
|
24
|
+
},
|
|
25
|
+
methods:{
|
|
26
|
+
onWindowResize(){
|
|
27
|
+
const contentWidth = getComputedStyle(document.querySelector('.theme-default-content')).width
|
|
28
|
+
if (window.matchMedia('(max-width: 410px)').matches) {
|
|
29
|
+
this.$refs.codeIframe.style.maxWidth = contentWidth
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
onClick(index){
|
|
33
|
+
this.activeIndex = index
|
|
34
|
+
},
|
|
35
|
+
createdDom(h,node){
|
|
36
|
+
let headerDom = []
|
|
37
|
+
node.forEach((v,index)=>{
|
|
38
|
+
headerDom.push(h('p',{class:`pages-tabs-header-text ${this.activeIndex === index?'pages-tabs--active':''}`,on:{click:(e)=>{
|
|
39
|
+
this.onClick(index)
|
|
40
|
+
}}},v.title),)
|
|
41
|
+
})
|
|
42
|
+
return this.renderDom(h,h('div',{class:'page-tabs'},[
|
|
43
|
+
h('div',{class:'pages-tabs-header'},headerDom),
|
|
44
|
+
h('div',{class:'page-snippet-code',key:this.activeIndex},[node[this.activeIndex].node]),
|
|
45
|
+
]))
|
|
46
|
+
},
|
|
47
|
+
renderDom(h,node){
|
|
48
|
+
return h('div',{class:'page-runtime'},
|
|
49
|
+
[
|
|
50
|
+
h('div',{class:'page-snippet'},[node]),
|
|
51
|
+
h('div',{class:'code-content',style:{display:this.src?'block':'none'}},[
|
|
52
|
+
h('iframe',{class:'code-iframe',attrs:{
|
|
53
|
+
src:this.src,
|
|
54
|
+
frameborder:'0',
|
|
55
|
+
allow:'geolocation https://hellouniappx.dcloud.net.cn'
|
|
56
|
+
},ref:'codeIframe'})
|
|
57
|
+
]),
|
|
58
|
+
|
|
59
|
+
]
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
render(h){
|
|
64
|
+
const columns = this.$slots.default || []
|
|
65
|
+
let boxObj = []
|
|
66
|
+
let realDom = []
|
|
67
|
+
columns.forEach((v,i)=>{
|
|
68
|
+
if(v.tag && v.children){
|
|
69
|
+
realDom.push(v)
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
realDom.forEach((vnode,index)=>{
|
|
73
|
+
let code = vnode.children[0]
|
|
74
|
+
if(vnode.tag === 'div' && code.tag === 'pre'){
|
|
75
|
+
let i = index - 1
|
|
76
|
+
if(i >= 0){
|
|
77
|
+
let textDom = realDom[i]
|
|
78
|
+
if(textDom.tag === 'blockquote'){
|
|
79
|
+
let text = textDom.children[0]
|
|
80
|
+
let p = text.children[0]
|
|
81
|
+
boxObj.push({
|
|
82
|
+
title:p.text,
|
|
83
|
+
node:vnode
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
if(boxObj.length > 0){
|
|
91
|
+
return h('div',null,[this.createdDom(h,boxObj)])
|
|
92
|
+
}else{
|
|
93
|
+
if(this.src){
|
|
94
|
+
return this.renderDom(h,this.$slots.default)
|
|
95
|
+
}else{
|
|
96
|
+
return h('div',null,this.$slots.default)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<style lang="stylus" scoped>
|
|
104
|
+
$pages-tabs-header-height = 44px
|
|
105
|
+
.page-runtime {
|
|
106
|
+
display: flex;
|
|
107
|
+
max-height: 667px;
|
|
108
|
+
border: 1px #eee solid;
|
|
109
|
+
margin-top: 16px;
|
|
110
|
+
}
|
|
111
|
+
.page-snippet {
|
|
112
|
+
width: 100%;
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
.page-snippet-code {
|
|
117
|
+
height: calc(100% - $pages-tabs-header-height);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.page-tabs {
|
|
121
|
+
height: 100%;
|
|
122
|
+
box-sizing: border-box;
|
|
123
|
+
}
|
|
124
|
+
.pages-tabs-header {
|
|
125
|
+
display: flex;
|
|
126
|
+
height: $pages-tabs-header-height;
|
|
127
|
+
background-color: #222;
|
|
128
|
+
}
|
|
129
|
+
.pages-tabs-header-text {
|
|
130
|
+
display: flex;
|
|
131
|
+
flex-direction: column;
|
|
132
|
+
justify-content: center;
|
|
133
|
+
margin: 5px;
|
|
134
|
+
margin-bottom: 0px;
|
|
135
|
+
border-top-left-radius: 5px;
|
|
136
|
+
border-top-right-radius: 5px;
|
|
137
|
+
padding: 0 45px;
|
|
138
|
+
text-align: center;
|
|
139
|
+
font-size: 16px;
|
|
140
|
+
color: #eee;
|
|
141
|
+
background:transparent;
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
-moz-user-select:none; /*火狐*/
|
|
144
|
+
-webkit-user-select:none; /*webkit浏览器*/
|
|
145
|
+
-ms-user-select:none; /*IE10*/
|
|
146
|
+
-khtml-user-select:none; /*早期浏览器*/
|
|
147
|
+
user-select:none;
|
|
148
|
+
}
|
|
149
|
+
.pages-tabs--active {
|
|
150
|
+
// background:#282c34;
|
|
151
|
+
background-color: #292d3e;
|
|
152
|
+
color: #fff;
|
|
153
|
+
font-weight: bold;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.page-snippet div[class*="language-"]{
|
|
157
|
+
width: 100%;
|
|
158
|
+
height: 100%;
|
|
159
|
+
border-radius: 0;
|
|
160
|
+
overflow: auto;
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
.page-snippet pre[class*="language-"]{
|
|
164
|
+
margin: 0;
|
|
165
|
+
padding: 20px 20px;
|
|
166
|
+
width: 100%;
|
|
167
|
+
height: 100%;
|
|
168
|
+
// overflow: auto;
|
|
169
|
+
box-sizing: border-box;
|
|
170
|
+
}
|
|
171
|
+
.code-iframe {
|
|
172
|
+
flex-shrink: 0;
|
|
173
|
+
width: 375px;
|
|
174
|
+
height: 667px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@media (max-width: $MQMobileNarrow)
|
|
178
|
+
{$contentClass}
|
|
179
|
+
div[class*="language-"]
|
|
180
|
+
margin 0 !important
|
|
181
|
+
|
|
182
|
+
/* .page-runtime pre::-webkit-scrollbar {
|
|
183
|
+
display: none
|
|
184
|
+
} */
|
|
185
|
+
::-webkit-scrollbar {
|
|
186
|
+
width: 8px !important;
|
|
187
|
+
height: 8px !important;
|
|
188
|
+
background: transparent;
|
|
189
|
+
filter: invert();
|
|
190
|
+
}
|
|
191
|
+
::-webkit-scrollbar:hover {
|
|
192
|
+
background: rgba(128, 128, 128, 0.2);
|
|
193
|
+
}
|
|
194
|
+
::-webkit-scrollbar-thumb {
|
|
195
|
+
border: 1px solid rgba(255, 255, 255, 0.4) !important;
|
|
196
|
+
background-color: rgba(0, 0, 0, 0.4) !important;
|
|
197
|
+
z-index: 2147483647;
|
|
198
|
+
-webkit-border-radius: 12px;
|
|
199
|
+
background-clip: content-box;
|
|
200
|
+
}
|
|
201
|
+
::-webkit-scrollbar-corner {
|
|
202
|
+
background: rgba(255, 255, 255, 0.3);
|
|
203
|
+
border: 1px solid transparent;
|
|
204
|
+
}
|
|
205
|
+
::-webkit-scrollbar-thumb:hover {
|
|
206
|
+
background-color: rgba(0, 0, 0, 0.8) !important;
|
|
207
|
+
}
|
|
208
|
+
::-webkit-scrollbar-thumb:active {
|
|
209
|
+
background-color: rgba(0, 0, 0, 0.6) !important;
|
|
210
|
+
}
|
|
211
|
+
</style>
|