vuepress-theme-uniapp-official 1.4.17 → 1.4.19
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 -22
- package/components/AlgoliaSearchBox.vue +130 -130
- package/components/DcloudSearchPage/components/Result.vue +160 -160
- package/components/DcloudSearchPage/components/Results.vue +66 -66
- package/components/DcloudSearchPage/components/pagination.vue +155 -155
- package/components/DcloudSearchPage/index.styl +182 -182
- package/components/DcloudSearchPage/index.vue +500 -500
- package/components/DcloudSearchPage/styles/ask.styl +271 -271
- package/components/DcloudSearchPage/styles/ext.styl +67 -67
- package/components/DcloudSearchPage/utils/Base64.js +133 -133
- package/components/DcloudSearchPage/utils/mock.js +433 -433
- package/components/DcloudSearchPage/utils/postDcloudServer.js +140 -140
- package/components/DcloudSearchPage/utils/searchClient.js +100 -100
- package/components/DcloudSearchPage/utils/searchUtils.js +51 -51
- package/components/Footer.vue +142 -142
- package/components/MainNavbarLink.vue +56 -56
- package/components/NavLink.vue +95 -95
- package/components/NavLinks.vue +173 -173
- package/components/Navbar.vue +322 -322
- package/components/NavbarLogo.vue +24 -24
- package/components/OutboundLink.vue +45 -45
- package/components/SearchBox/index.vue +337 -337
- package/components/SearchBox/match-query.js +51 -51
- package/components/SearchBox/search.svg +1 -1
- package/components/SidebarGroup.vue +141 -141
- package/components/SidebarLink.vue +151 -151
- package/components/SidebarLinks.vue +106 -106
- package/components/SiderBarBottom.vue +134 -134
- package/components/Sticker.vue +64 -64
- package/components/Toc-top.vue +95 -95
- package/components/Toc.vue +165 -165
- package/config/copy.js +6 -6
- package/config/footer.js +194 -194
- package/config/i18n/index.js +1 -1
- package/config/navbar.js +162 -162
- package/config/redirectRouter.js +119 -119
- package/config/searchPage.js +47 -47
- package/config/siderbar/index.js +8 -8
- package/config/siderbar/uni-app.js +210 -210
- package/config/siderbar/uniCloud.js +54 -54
- package/config/toc.js +4 -4
- package/enhanceApp.js +142 -142
- package/global-components/CodeSimulator.vue +209 -209
- package/global-components/CompatibilityTable.vue +66 -1
- package/global-components/Popover.vue +27 -42
- package/global-components/icons.js +646 -646
- package/global-components/iconsLayouts.vue +117 -117
- package/global-components/uniIcon.vue +85 -85
- package/global-components/uniicons.css +656 -656
- package/index.js +169 -169
- package/layouts/404.vue +22 -22
- package/layouts/Layout.vue +238 -238
- package/layouts/SimpleLayout.vue +18 -18
- package/mixin/navInject.js +20 -20
- package/mixin/navProvider.js +64 -64
- package/mixin/toc.js +35 -35
- package/package.json +51 -52
- package/styles/custom-block.styl +337 -337
- package/styles/footer.styl +248 -248
- package/styles/index.styl +197 -197
- package/styles/navbar.styl +292 -292
- package/styles/palette.styl +8 -8
- package/util/index.js +333 -317
- package/components/SearchBox/dist/match-query.dev.js +0 -61
- package/helper/index.js +0 -15
package/README.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
### uni-app official website theme for vuepress
|
|
2
|
-
|
|
3
|
-
# vuepress-theme-uniapp-official
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/vuepress-theme-uniapp-official) [](https://npmjs.com/package/vuepress-theme-uniapp-official)
|
|
6
|
-
|
|
7
|
-
## Sites
|
|
8
|
-
|
|
9
|
-
- clone this repo and run `yarn && yarn docs:dev`
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## Install
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
yarn add vuepress-theme-uniapp-official -D
|
|
16
|
-
# OR npm install vuepress-theme-uniapp-official -D
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## Usage
|
|
21
|
-
|
|
22
|
-
[https://gitcode.net/dcloud/unidocs-uni-app-x-zh](https://gitcode.net/dcloud/unidocs-uni-app-x-zh)
|
|
1
|
+
### uni-app official website theme for vuepress
|
|
2
|
+
|
|
3
|
+
# vuepress-theme-uniapp-official
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/vuepress-theme-uniapp-official) [](https://npmjs.com/package/vuepress-theme-uniapp-official)
|
|
6
|
+
|
|
7
|
+
## Sites
|
|
8
|
+
|
|
9
|
+
- clone this repo and run `yarn && yarn docs:dev`
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
yarn add vuepress-theme-uniapp-official -D
|
|
16
|
+
# OR npm install vuepress-theme-uniapp-official -D
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
[https://gitcode.net/dcloud/unidocs-uni-app-x-zh](https://gitcode.net/dcloud/unidocs-uni-app-x-zh)
|
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div id="docsearch">
|
|
3
|
-
<button
|
|
4
|
-
type="button"
|
|
5
|
-
class="DocSearch DocSearch-Button"
|
|
6
|
-
:aria-label="searchText"
|
|
7
|
-
@click="openSearch"
|
|
8
|
-
>
|
|
9
|
-
<span class="DocSearch-Button-Container">
|
|
10
|
-
<svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20">
|
|
11
|
-
<path
|
|
12
|
-
d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z"
|
|
13
|
-
stroke="currentColor"
|
|
14
|
-
fill="none"
|
|
15
|
-
fill-rule="evenodd"
|
|
16
|
-
stroke-linecap="round"
|
|
17
|
-
stroke-linejoin="round"
|
|
18
|
-
></path>
|
|
19
|
-
</svg>
|
|
20
|
-
<span class="DocSearch-Button-Placeholder">{{ searchText }}</span>
|
|
21
|
-
</span>
|
|
22
|
-
<span class="DocSearch-Button-Keys">
|
|
23
|
-
<span class="DocSearch-Button-Key">
|
|
24
|
-
<svg width="15" height="15" class="DocSearch-Control-Key-Icon">
|
|
25
|
-
<path
|
|
26
|
-
d="M4.505 4.496h2M5.505 5.496v5M8.216 4.496l.055 5.993M10 7.5c.333.333.5.667.5 1v2M12.326 4.5v5.996M8.384 4.496c1.674 0 2.116 0 2.116 1.5s-.442 1.5-2.116 1.5M3.205 9.303c-.09.448-.277 1.21-1.241 1.203C1 10.5.5 9.513.5 8V7c0-1.57.5-2.5 1.464-2.494.964.006 1.134.598 1.24 1.342M12.553 10.5h1.953"
|
|
27
|
-
stroke-width="1.2"
|
|
28
|
-
stroke="currentColor"
|
|
29
|
-
fill="none"
|
|
30
|
-
stroke-linecap="square"
|
|
31
|
-
></path>
|
|
32
|
-
</svg>
|
|
33
|
-
</span>
|
|
34
|
-
<span class="DocSearch-Button-Key">K</span>
|
|
35
|
-
</span>
|
|
36
|
-
</button>
|
|
37
|
-
</div>
|
|
38
|
-
</template>
|
|
39
|
-
|
|
40
|
-
<script>
|
|
41
|
-
import '@docsearch/css';
|
|
42
|
-
import { LOCALE_ZH_HANS } from '@theme-config/i18n';
|
|
43
|
-
|
|
44
|
-
export default {
|
|
45
|
-
name: 'AlgoliaSearchBox',
|
|
46
|
-
|
|
47
|
-
computed: {
|
|
48
|
-
searchText() {
|
|
49
|
-
return this.$lang === LOCALE_ZH_HANS ? '搜索文档' : 'Search';
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
methods: {
|
|
54
|
-
openSearch() {
|
|
55
|
-
this.$parent.$refs.dcloudSearchPage.onSearchOpen();
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
</script>
|
|
60
|
-
|
|
61
|
-
<style lang="stylus">
|
|
62
|
-
.DocSearch
|
|
63
|
-
--docsearch-primary-color $accentColor
|
|
64
|
-
--docsearch-highlight-color var(--docsearch-primary-color)
|
|
65
|
-
--docsearch-searchbox-shadow inset 0 0 0 2px var(--docsearch-primary-color)
|
|
66
|
-
|
|
67
|
-
#docsearch
|
|
68
|
-
display flex
|
|
69
|
-
flex-direction column
|
|
70
|
-
justify-content center
|
|
71
|
-
#docsearch span
|
|
72
|
-
@media (min-width: 1200px)
|
|
73
|
-
&
|
|
74
|
-
display flex
|
|
75
|
-
|
|
76
|
-
@media (max-width: 1200px)
|
|
77
|
-
:root
|
|
78
|
-
--docsearch-spacing 10px
|
|
79
|
-
--docsearch-footer-height 40px
|
|
80
|
-
.DocSearch-Button-Keys,.DocSearch-Button-Key,.DocSearch-Button-KeySeparator,.DocSearch-Button-Placeholder
|
|
81
|
-
display none !important
|
|
82
|
-
.DocSearch-Search-Icon
|
|
83
|
-
vertical-align middle
|
|
84
|
-
.DocSearch-Dropdown
|
|
85
|
-
height 100%
|
|
86
|
-
.DocSearch-Container
|
|
87
|
-
height 100vh
|
|
88
|
-
height -webkit-fill-available
|
|
89
|
-
position absolute
|
|
90
|
-
.DocSearch-Footer
|
|
91
|
-
border-radius 0
|
|
92
|
-
bottom 0
|
|
93
|
-
position absolute
|
|
94
|
-
.DocSearch-Hit-content-wrapper
|
|
95
|
-
display flex
|
|
96
|
-
position relative
|
|
97
|
-
width 80%
|
|
98
|
-
.DocSearch-Modal
|
|
99
|
-
border-radius 0
|
|
100
|
-
box-shadow none
|
|
101
|
-
height 100vh
|
|
102
|
-
height -webkit-fill-available
|
|
103
|
-
margin 0
|
|
104
|
-
max-width 100%
|
|
105
|
-
width 100%
|
|
106
|
-
.DocSearch-Cancel
|
|
107
|
-
-webkit-appearance none
|
|
108
|
-
-moz-appearance none
|
|
109
|
-
appearance none
|
|
110
|
-
background none
|
|
111
|
-
border 0
|
|
112
|
-
color var(--docsearch-highlight-color)
|
|
113
|
-
cursor pointer
|
|
114
|
-
display inline-block
|
|
115
|
-
flex none
|
|
116
|
-
font inherit
|
|
117
|
-
font-size 1em
|
|
118
|
-
font-weight 500
|
|
119
|
-
margin-left var(--docsearch-spacing)
|
|
120
|
-
outline none
|
|
121
|
-
overflow hidden
|
|
122
|
-
padding 0
|
|
123
|
-
-webkit-user-select none
|
|
124
|
-
-moz-user-select none
|
|
125
|
-
-ms-user-select none
|
|
126
|
-
user-select none
|
|
127
|
-
white-space nowrap
|
|
128
|
-
.DocSearch-Commands,.DocSearch-Hit-Tree
|
|
129
|
-
display none
|
|
130
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div id="docsearch">
|
|
3
|
+
<button
|
|
4
|
+
type="button"
|
|
5
|
+
class="DocSearch DocSearch-Button"
|
|
6
|
+
:aria-label="searchText"
|
|
7
|
+
@click="openSearch"
|
|
8
|
+
>
|
|
9
|
+
<span class="DocSearch-Button-Container">
|
|
10
|
+
<svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20">
|
|
11
|
+
<path
|
|
12
|
+
d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z"
|
|
13
|
+
stroke="currentColor"
|
|
14
|
+
fill="none"
|
|
15
|
+
fill-rule="evenodd"
|
|
16
|
+
stroke-linecap="round"
|
|
17
|
+
stroke-linejoin="round"
|
|
18
|
+
></path>
|
|
19
|
+
</svg>
|
|
20
|
+
<span class="DocSearch-Button-Placeholder">{{ searchText }}</span>
|
|
21
|
+
</span>
|
|
22
|
+
<span class="DocSearch-Button-Keys">
|
|
23
|
+
<span class="DocSearch-Button-Key">
|
|
24
|
+
<svg width="15" height="15" class="DocSearch-Control-Key-Icon">
|
|
25
|
+
<path
|
|
26
|
+
d="M4.505 4.496h2M5.505 5.496v5M8.216 4.496l.055 5.993M10 7.5c.333.333.5.667.5 1v2M12.326 4.5v5.996M8.384 4.496c1.674 0 2.116 0 2.116 1.5s-.442 1.5-2.116 1.5M3.205 9.303c-.09.448-.277 1.21-1.241 1.203C1 10.5.5 9.513.5 8V7c0-1.57.5-2.5 1.464-2.494.964.006 1.134.598 1.24 1.342M12.553 10.5h1.953"
|
|
27
|
+
stroke-width="1.2"
|
|
28
|
+
stroke="currentColor"
|
|
29
|
+
fill="none"
|
|
30
|
+
stroke-linecap="square"
|
|
31
|
+
></path>
|
|
32
|
+
</svg>
|
|
33
|
+
</span>
|
|
34
|
+
<span class="DocSearch-Button-Key">K</span>
|
|
35
|
+
</span>
|
|
36
|
+
</button>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script>
|
|
41
|
+
import '@docsearch/css';
|
|
42
|
+
import { LOCALE_ZH_HANS } from '@theme-config/i18n';
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
name: 'AlgoliaSearchBox',
|
|
46
|
+
|
|
47
|
+
computed: {
|
|
48
|
+
searchText() {
|
|
49
|
+
return this.$lang === LOCALE_ZH_HANS ? '搜索文档' : 'Search';
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
methods: {
|
|
54
|
+
openSearch() {
|
|
55
|
+
this.$parent.$refs.dcloudSearchPage.onSearchOpen();
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<style lang="stylus">
|
|
62
|
+
.DocSearch
|
|
63
|
+
--docsearch-primary-color $accentColor
|
|
64
|
+
--docsearch-highlight-color var(--docsearch-primary-color)
|
|
65
|
+
--docsearch-searchbox-shadow inset 0 0 0 2px var(--docsearch-primary-color)
|
|
66
|
+
|
|
67
|
+
#docsearch
|
|
68
|
+
display flex
|
|
69
|
+
flex-direction column
|
|
70
|
+
justify-content center
|
|
71
|
+
#docsearch span
|
|
72
|
+
@media (min-width: 1200px)
|
|
73
|
+
&
|
|
74
|
+
display flex
|
|
75
|
+
|
|
76
|
+
@media (max-width: 1200px)
|
|
77
|
+
:root
|
|
78
|
+
--docsearch-spacing 10px
|
|
79
|
+
--docsearch-footer-height 40px
|
|
80
|
+
.DocSearch-Button-Keys,.DocSearch-Button-Key,.DocSearch-Button-KeySeparator,.DocSearch-Button-Placeholder
|
|
81
|
+
display none !important
|
|
82
|
+
.DocSearch-Search-Icon
|
|
83
|
+
vertical-align middle
|
|
84
|
+
.DocSearch-Dropdown
|
|
85
|
+
height 100%
|
|
86
|
+
.DocSearch-Container
|
|
87
|
+
height 100vh
|
|
88
|
+
height -webkit-fill-available
|
|
89
|
+
position absolute
|
|
90
|
+
.DocSearch-Footer
|
|
91
|
+
border-radius 0
|
|
92
|
+
bottom 0
|
|
93
|
+
position absolute
|
|
94
|
+
.DocSearch-Hit-content-wrapper
|
|
95
|
+
display flex
|
|
96
|
+
position relative
|
|
97
|
+
width 80%
|
|
98
|
+
.DocSearch-Modal
|
|
99
|
+
border-radius 0
|
|
100
|
+
box-shadow none
|
|
101
|
+
height 100vh
|
|
102
|
+
height -webkit-fill-available
|
|
103
|
+
margin 0
|
|
104
|
+
max-width 100%
|
|
105
|
+
width 100%
|
|
106
|
+
.DocSearch-Cancel
|
|
107
|
+
-webkit-appearance none
|
|
108
|
+
-moz-appearance none
|
|
109
|
+
appearance none
|
|
110
|
+
background none
|
|
111
|
+
border 0
|
|
112
|
+
color var(--docsearch-highlight-color)
|
|
113
|
+
cursor pointer
|
|
114
|
+
display inline-block
|
|
115
|
+
flex none
|
|
116
|
+
font inherit
|
|
117
|
+
font-size 1em
|
|
118
|
+
font-weight 500
|
|
119
|
+
margin-left var(--docsearch-spacing)
|
|
120
|
+
outline none
|
|
121
|
+
overflow hidden
|
|
122
|
+
padding 0
|
|
123
|
+
-webkit-user-select none
|
|
124
|
+
-moz-user-select none
|
|
125
|
+
-ms-user-select none
|
|
126
|
+
user-select none
|
|
127
|
+
white-space nowrap
|
|
128
|
+
.DocSearch-Commands,.DocSearch-Hit-Tree
|
|
129
|
+
display none
|
|
130
|
+
</style>
|
|
@@ -1,160 +1,160 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<li :class="li_class">
|
|
3
|
-
<a :href="handleUrl(item.url)">
|
|
4
|
-
<div class="DocSearch-Hit-Container">
|
|
5
|
-
<div
|
|
6
|
-
class="DocSearch-Hit-content-wrapper"
|
|
7
|
-
v-if="item.hierarchy[item.type] && item.type === 'lvl1'"
|
|
8
|
-
>
|
|
9
|
-
<span class="DocSearch-Hit-title" v-html="hierarchyLvl1Html" />
|
|
10
|
-
<span v-if="item.content" class="DocSearch-Hit-path" v-html="contentHtml" />
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
|
-
<div v-else-if="isContent" class="DocSearch-Hit-content-wrapper">
|
|
14
|
-
<span class="DocSearch-Hit-title" v-html="contentHtml" />
|
|
15
|
-
<span class="DocSearch-Hit-path" v-html="hierarchyLvl1Html || hierarchyLvl2Html" />
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<div v-else class="DocSearch-Hit-content-wrapper">
|
|
19
|
-
<span
|
|
20
|
-
class="DocSearch-Hit-title"
|
|
21
|
-
v-html="snippetResultContent(`hierarchy.${item.type}`)"
|
|
22
|
-
/>
|
|
23
|
-
<span class="DocSearch-Hit-path" v-html="hierarchyLvl1Html" />
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
<span v-if="item.tag && item.tag !== 'uniCloud'" class="DocSearch-Hit-source_tag">
|
|
27
|
-
{{ item.tag }}
|
|
28
|
-
</span>
|
|
29
|
-
</div>
|
|
30
|
-
</a>
|
|
31
|
-
</li>
|
|
32
|
-
</template>
|
|
33
|
-
<script>
|
|
34
|
-
function getPropertyByPath(object, path) {
|
|
35
|
-
const parts = path.split('.');
|
|
36
|
-
|
|
37
|
-
return parts.reduce((prev, current) => {
|
|
38
|
-
if (prev && prev[current]) return prev[current];
|
|
39
|
-
return null;
|
|
40
|
-
}, object);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default {
|
|
44
|
-
data() {
|
|
45
|
-
return {};
|
|
46
|
-
},
|
|
47
|
-
props: {
|
|
48
|
-
item: {
|
|
49
|
-
type: Object,
|
|
50
|
-
default: () => ({}),
|
|
51
|
-
},
|
|
52
|
-
index: {
|
|
53
|
-
type: Number,
|
|
54
|
-
default: 0,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
computed: {
|
|
58
|
-
li_class() {
|
|
59
|
-
return ['DocSearch-Hit', this.item.__docsearch_parent && 'DocSearch-Hit--Child']
|
|
60
|
-
.filter(Boolean)
|
|
61
|
-
.join(' ');
|
|
62
|
-
},
|
|
63
|
-
isContent() {
|
|
64
|
-
return this.item.type === 'content';
|
|
65
|
-
},
|
|
66
|
-
contentHtml() {
|
|
67
|
-
return this.snippetResultContent('content');
|
|
68
|
-
},
|
|
69
|
-
hierarchyLvl1Html() {
|
|
70
|
-
return this.snippetResultContent('hierarchy.lvl1');
|
|
71
|
-
},
|
|
72
|
-
hierarchyLvl2Html() {
|
|
73
|
-
const lvl2 = this.snippetResultContent('hierarchy.lvl2');
|
|
74
|
-
return this.isContent ? this.contentHtml === lvl2 ? '' : lvl2 : '';
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
methods: {
|
|
78
|
-
snippetResultContent(attribute) {
|
|
79
|
-
return (
|
|
80
|
-
getPropertyByPath(this.item, `_snippetResult.${attribute}.value`) ||
|
|
81
|
-
getPropertyByPath(this.item, attribute)
|
|
82
|
-
);
|
|
83
|
-
},
|
|
84
|
-
handleUrl(url) {
|
|
85
|
-
const len = url.length
|
|
86
|
-
const lastIndex = url.lastIndexOf('/')
|
|
87
|
-
if (lastIndex === len - 1) {
|
|
88
|
-
return url
|
|
89
|
-
}
|
|
90
|
-
const front = url.substring(0, lastIndex + 1)
|
|
91
|
-
const end = url.substring(lastIndex + 1)
|
|
92
|
-
if (end.indexOf('.html') > -1) {
|
|
93
|
-
return url
|
|
94
|
-
}
|
|
95
|
-
if (end.indexOf('#') > -1) {
|
|
96
|
-
return front + end.replace(/([\s\S]+)#([\s\S]+)/, '$1.html#$2')
|
|
97
|
-
}
|
|
98
|
-
return `${url}.html`
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
</script>
|
|
103
|
-
<style lang="stylus">
|
|
104
|
-
.DocSearch-Hit-source_tag {
|
|
105
|
-
background-color: #f0f0f0;
|
|
106
|
-
font-size: 12px;
|
|
107
|
-
padding: 2px 4px;
|
|
108
|
-
color: #999;
|
|
109
|
-
border-radius: 3px;
|
|
110
|
-
margin-right: 5px;
|
|
111
|
-
font-weight: normal;
|
|
112
|
-
}
|
|
113
|
-
.DocSearch-Hit
|
|
114
|
-
border-radius 0px
|
|
115
|
-
display flex
|
|
116
|
-
padding-bottom 0px
|
|
117
|
-
position relative
|
|
118
|
-
|
|
119
|
-
&:not(:first-child)
|
|
120
|
-
border-top 1px solid #f5f6f7
|
|
121
|
-
|
|
122
|
-
a
|
|
123
|
-
background var(--docsearch-hit-background)
|
|
124
|
-
border-radius 0px
|
|
125
|
-
// box-shadow var(--docsearch-hit-shadow)
|
|
126
|
-
box-shadow none
|
|
127
|
-
display block
|
|
128
|
-
padding-left var(--docsearch-spacing)
|
|
129
|
-
width 100%
|
|
130
|
-
|
|
131
|
-
.DocSearch-Hit-Container
|
|
132
|
-
align-items center
|
|
133
|
-
color #444950
|
|
134
|
-
display flex
|
|
135
|
-
flex-direction row
|
|
136
|
-
height 56px
|
|
137
|
-
padding 0 12px 0 0
|
|
138
|
-
|
|
139
|
-
.DocSearch-Hit-content-wrapper
|
|
140
|
-
overflow hidden
|
|
141
|
-
display flex
|
|
142
|
-
flex 1 1 auto
|
|
143
|
-
flex-direction column
|
|
144
|
-
font-weight 500
|
|
145
|
-
justify-content center
|
|
146
|
-
line-height 1.2em
|
|
147
|
-
margin 0 8px
|
|
148
|
-
overflow-x hidden
|
|
149
|
-
position relative
|
|
150
|
-
text-overflow ellipsis
|
|
151
|
-
white-space nowrap
|
|
152
|
-
width 80%
|
|
153
|
-
|
|
154
|
-
.DocSearch-Hit-title
|
|
155
|
-
font-size 0.9em
|
|
156
|
-
|
|
157
|
-
.DocSearch-Hit-path
|
|
158
|
-
// color $accentColor
|
|
159
|
-
font-size 0.75em
|
|
160
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<li :class="li_class">
|
|
3
|
+
<a :href="handleUrl(item.url)">
|
|
4
|
+
<div class="DocSearch-Hit-Container">
|
|
5
|
+
<div
|
|
6
|
+
class="DocSearch-Hit-content-wrapper"
|
|
7
|
+
v-if="item.hierarchy[item.type] && item.type === 'lvl1'"
|
|
8
|
+
>
|
|
9
|
+
<span class="DocSearch-Hit-title" v-html="hierarchyLvl1Html" />
|
|
10
|
+
<span v-if="item.content" class="DocSearch-Hit-path" v-html="contentHtml" />
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<div v-else-if="isContent" class="DocSearch-Hit-content-wrapper">
|
|
14
|
+
<span class="DocSearch-Hit-title" v-html="contentHtml" />
|
|
15
|
+
<span class="DocSearch-Hit-path" v-html="hierarchyLvl1Html || hierarchyLvl2Html" />
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div v-else class="DocSearch-Hit-content-wrapper">
|
|
19
|
+
<span
|
|
20
|
+
class="DocSearch-Hit-title"
|
|
21
|
+
v-html="snippetResultContent(`hierarchy.${item.type}`)"
|
|
22
|
+
/>
|
|
23
|
+
<span class="DocSearch-Hit-path" v-html="hierarchyLvl1Html" />
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<span v-if="item.tag && item.tag !== 'uniCloud'" class="DocSearch-Hit-source_tag">
|
|
27
|
+
{{ item.tag }}
|
|
28
|
+
</span>
|
|
29
|
+
</div>
|
|
30
|
+
</a>
|
|
31
|
+
</li>
|
|
32
|
+
</template>
|
|
33
|
+
<script>
|
|
34
|
+
function getPropertyByPath(object, path) {
|
|
35
|
+
const parts = path.split('.');
|
|
36
|
+
|
|
37
|
+
return parts.reduce((prev, current) => {
|
|
38
|
+
if (prev && prev[current]) return prev[current];
|
|
39
|
+
return null;
|
|
40
|
+
}, object);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default {
|
|
44
|
+
data() {
|
|
45
|
+
return {};
|
|
46
|
+
},
|
|
47
|
+
props: {
|
|
48
|
+
item: {
|
|
49
|
+
type: Object,
|
|
50
|
+
default: () => ({}),
|
|
51
|
+
},
|
|
52
|
+
index: {
|
|
53
|
+
type: Number,
|
|
54
|
+
default: 0,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
computed: {
|
|
58
|
+
li_class() {
|
|
59
|
+
return ['DocSearch-Hit', this.item.__docsearch_parent && 'DocSearch-Hit--Child']
|
|
60
|
+
.filter(Boolean)
|
|
61
|
+
.join(' ');
|
|
62
|
+
},
|
|
63
|
+
isContent() {
|
|
64
|
+
return this.item.type === 'content';
|
|
65
|
+
},
|
|
66
|
+
contentHtml() {
|
|
67
|
+
return this.snippetResultContent('content');
|
|
68
|
+
},
|
|
69
|
+
hierarchyLvl1Html() {
|
|
70
|
+
return this.snippetResultContent('hierarchy.lvl1');
|
|
71
|
+
},
|
|
72
|
+
hierarchyLvl2Html() {
|
|
73
|
+
const lvl2 = this.snippetResultContent('hierarchy.lvl2');
|
|
74
|
+
return this.isContent ? this.contentHtml === lvl2 ? '' : lvl2 : '';
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
methods: {
|
|
78
|
+
snippetResultContent(attribute) {
|
|
79
|
+
return (
|
|
80
|
+
getPropertyByPath(this.item, `_snippetResult.${attribute}.value`) ||
|
|
81
|
+
getPropertyByPath(this.item, attribute)
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
handleUrl(url) {
|
|
85
|
+
const len = url.length
|
|
86
|
+
const lastIndex = url.lastIndexOf('/')
|
|
87
|
+
if (lastIndex === len - 1) {
|
|
88
|
+
return url
|
|
89
|
+
}
|
|
90
|
+
const front = url.substring(0, lastIndex + 1)
|
|
91
|
+
const end = url.substring(lastIndex + 1)
|
|
92
|
+
if (end.indexOf('.html') > -1) {
|
|
93
|
+
return url
|
|
94
|
+
}
|
|
95
|
+
if (end.indexOf('#') > -1) {
|
|
96
|
+
return front + end.replace(/([\s\S]+)#([\s\S]+)/, '$1.html#$2')
|
|
97
|
+
}
|
|
98
|
+
return `${url}.html`
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
</script>
|
|
103
|
+
<style lang="stylus">
|
|
104
|
+
.DocSearch-Hit-source_tag {
|
|
105
|
+
background-color: #f0f0f0;
|
|
106
|
+
font-size: 12px;
|
|
107
|
+
padding: 2px 4px;
|
|
108
|
+
color: #999;
|
|
109
|
+
border-radius: 3px;
|
|
110
|
+
margin-right: 5px;
|
|
111
|
+
font-weight: normal;
|
|
112
|
+
}
|
|
113
|
+
.DocSearch-Hit
|
|
114
|
+
border-radius 0px
|
|
115
|
+
display flex
|
|
116
|
+
padding-bottom 0px
|
|
117
|
+
position relative
|
|
118
|
+
|
|
119
|
+
&:not(:first-child)
|
|
120
|
+
border-top 1px solid #f5f6f7
|
|
121
|
+
|
|
122
|
+
a
|
|
123
|
+
background var(--docsearch-hit-background)
|
|
124
|
+
border-radius 0px
|
|
125
|
+
// box-shadow var(--docsearch-hit-shadow)
|
|
126
|
+
box-shadow none
|
|
127
|
+
display block
|
|
128
|
+
padding-left var(--docsearch-spacing)
|
|
129
|
+
width 100%
|
|
130
|
+
|
|
131
|
+
.DocSearch-Hit-Container
|
|
132
|
+
align-items center
|
|
133
|
+
color #444950
|
|
134
|
+
display flex
|
|
135
|
+
flex-direction row
|
|
136
|
+
height 56px
|
|
137
|
+
padding 0 12px 0 0
|
|
138
|
+
|
|
139
|
+
.DocSearch-Hit-content-wrapper
|
|
140
|
+
overflow hidden
|
|
141
|
+
display flex
|
|
142
|
+
flex 1 1 auto
|
|
143
|
+
flex-direction column
|
|
144
|
+
font-weight 500
|
|
145
|
+
justify-content center
|
|
146
|
+
line-height 1.2em
|
|
147
|
+
margin 0 8px
|
|
148
|
+
overflow-x hidden
|
|
149
|
+
position relative
|
|
150
|
+
text-overflow ellipsis
|
|
151
|
+
white-space nowrap
|
|
152
|
+
width 80%
|
|
153
|
+
|
|
154
|
+
.DocSearch-Hit-title
|
|
155
|
+
font-size 0.9em
|
|
156
|
+
|
|
157
|
+
.DocSearch-Hit-path
|
|
158
|
+
// color $accentColor
|
|
159
|
+
font-size 0.75em
|
|
160
|
+
</style>
|