@opentiny/vue-docs 3.20.4 → 3.20.5
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/package.json +6 -6
- package/src/main.js +12 -8
- package/src/style.css +5 -5
- package/src/tools/docsearch.js +26 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/vue-docs",
|
|
3
|
-
"version": "3.20.
|
|
3
|
+
"version": "3.20.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@opentiny/vue-repl": "^1.1.2",
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
"@docsearch/js": "^3.8.0",
|
|
20
20
|
"@docsearch/css": "^3.8.0",
|
|
21
21
|
"@docsearch/react": "npm:@docsearch/css",
|
|
22
|
-
"@opentiny/vue-design-saas": "~3.20.0",
|
|
23
|
-
"@opentiny/vue-common": "~3.20.1",
|
|
24
22
|
"@opentiny/vue": "~3.20.0",
|
|
25
|
-
"@opentiny/vue-
|
|
23
|
+
"@opentiny/vue-common": "~3.20.1",
|
|
26
24
|
"@opentiny/vue-design-aurora": "~3.20.0",
|
|
27
|
-
"@opentiny/vue-
|
|
25
|
+
"@opentiny/vue-design-saas": "~3.20.0",
|
|
28
26
|
"@opentiny/vue-design-smb": "~3.20.0",
|
|
27
|
+
"@opentiny/vue-directive": "~3.20.0",
|
|
29
28
|
"@opentiny/vue-hooks": "~3.20.0",
|
|
29
|
+
"@opentiny/vue-icon-multicolor": "~3.20.0",
|
|
30
|
+
"@opentiny/vue-icon": "~3.20.0",
|
|
30
31
|
"@opentiny/vue-icon-saas": "~3.20.0",
|
|
31
32
|
"@opentiny/vue-theme": "~3.20.0",
|
|
32
|
-
"@opentiny/vue-icon-multicolor": "~3.20.0",
|
|
33
33
|
"@opentiny/vue-theme-mobile": "~3.20.0",
|
|
34
34
|
"@opentiny/vue-vite-import": "~1.2.0",
|
|
35
35
|
"@opentiny/vue-theme-saas": "~3.20.0"
|
package/src/main.js
CHANGED
|
@@ -33,6 +33,7 @@ import css from 'highlight.js/lib/languages/css'
|
|
|
33
33
|
import html from 'highlight.js/lib/languages/xml'
|
|
34
34
|
import docsearch from '@docsearch/js'
|
|
35
35
|
import '@docsearch/css'
|
|
36
|
+
import { doSearchEverySite } from './tools/docsearch'
|
|
36
37
|
|
|
37
38
|
const envTarget = import.meta.env.VITE_BUILD_TARGET || 'open'
|
|
38
39
|
|
|
@@ -40,14 +41,17 @@ hljs.registerLanguage('javascript', javascript)
|
|
|
40
41
|
hljs.registerLanguage('css', css)
|
|
41
42
|
hljs.registerLanguage('html', html)
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
docsearch({
|
|
45
|
+
appId: 'AGPA5UXHMH',
|
|
46
|
+
apiKey: '5fa09fc20270efa61d68e2c2eb0f56df',
|
|
47
|
+
indexName: 'opentiny',
|
|
48
|
+
container: '.search-box',
|
|
49
|
+
debug: false
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
if (envTarget !== 'open') {
|
|
53
|
+
// 支持本地开发和内网使用全局搜索
|
|
54
|
+
doSearchEverySite()
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
// 实验后发现,先调用一次预热一下,后续再调用会有速度的提示,因此在main中预热一下。
|
package/src/style.css
CHANGED
|
@@ -37,7 +37,7 @@ strong {
|
|
|
37
37
|
left: 210px;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.DocSearch-Container {
|
|
40
|
+
.DocSearch.DocSearch-Container {
|
|
41
41
|
z-index: 1000;
|
|
42
42
|
font-size: 14px;
|
|
43
43
|
}
|
|
@@ -72,11 +72,11 @@ strong {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
@media screen and (max-width: 768px) {
|
|
75
|
-
.DocSearch-Modal {
|
|
76
|
-
margin-top: 60px;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
75
|
.search-box {
|
|
80
76
|
left: 230px;
|
|
81
77
|
}
|
|
78
|
+
|
|
79
|
+
.search-box .DocSearch-Button {
|
|
80
|
+
padding: 0 11px;
|
|
81
|
+
}
|
|
82
82
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const HIT_CLASS = 'DocSearch-Hit'
|
|
2
|
+
|
|
3
|
+
const findUrlLink = (target) => {
|
|
4
|
+
if (target?.nodeName?.toLocaleLowerCase?.() === 'a') {
|
|
5
|
+
return target.getAttribute('href')
|
|
6
|
+
} else if (target?.parentElement) {
|
|
7
|
+
return findUrlLink(target.parentElement)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const isAlgoliaHitDom = (dom) =>
|
|
12
|
+
dom?.className?.includes?.(HIT_CLASS) || dom?.parentElement?.className?.includes?.(HIT_CLASS)
|
|
13
|
+
|
|
14
|
+
export const doSearchEverySite = () => {
|
|
15
|
+
window.addEventListener('click', (event) => {
|
|
16
|
+
const target = event.target
|
|
17
|
+
if (isAlgoliaHitDom(target)) {
|
|
18
|
+
const openUrl = findUrlLink(target)
|
|
19
|
+
if (openUrl) {
|
|
20
|
+
const urlObj = new URL(openUrl)
|
|
21
|
+
event.preventDefault()
|
|
22
|
+
window.location.href = openUrl.replace(urlObj.origin, window.location.origin)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
}
|