Skip to content

Commit 569ac3c

Browse files
authored
fix: fixed the problem of global search js resource access failure (#2623)
* fix: fixed the problem of global search js resource access failure * feat: update docs version
1 parent 43333e4 commit 569ac3c

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

examples/sites/index.html

+1-12
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,13 @@
2121
window.DEPLOY_URL = ''
2222
window.process = { env: {} }
2323
</script>
24-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3"/>
2524
</head>
2625

2726
<body class="of-hidden">
2827
<div id="header"></div>
2928
<app-root></app-root>
3029
<div id="app" class="wp100 hp100 pt60 of-hidden"></div>
31-
<div class="search-box" style="display: none;"></div>
32-
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script>
33-
<script type="text/javascript">
34-
docsearch({
35-
appId: "AGPA5UXHMH",
36-
apiKey: "5fa09fc20270efa61d68e2c2eb0f56df",
37-
indexName: "opentiny",
38-
container: ".search-box",
39-
debug: false
40-
});
41-
</script>
30+
<div class="search-box"></div>
4231
<!-- prettier-ignore -->
4332
<script id="tinyui-design-common" src="/static/js/design-common.js"></script>
4433
<script type="module" src="./src/main.js"></script>

examples/sites/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opentiny/vue-docs",
3-
"version": "3.20.2",
3+
"version": "3.20.3",
44
"license": "MIT",
55
"scripts": {
66
"start": "vite",
@@ -47,7 +47,9 @@
4747
"tailwindcss": "^3.2.4",
4848
"vue": "^3.4.31",
4949
"vue-i18n": "^9.1.10",
50-
"vue-router": "4.1.5"
50+
"vue-router": "4.1.5",
51+
"@docsearch/js": "^3.8.0",
52+
"@docsearch/css": "^3.8.0"
5153
},
5254
"devDependencies": {
5355
"@opentiny-internal/unplugin-virtual-template": "workspace:~",

examples/sites/src/App.vue

-7
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import { iconClose } from '@opentiny/vue-icon'
1717
import { appData } from './tools'
1818
import useTheme from './tools/useTheme'
1919
20-
const envTarget = import.meta.env.VITE_BUILD_TARGET || 'open'
21-
2220
export default defineComponent({
2321
name: 'AppVue',
2422
props: [],
@@ -42,11 +40,6 @@ export default defineComponent({
4240
}
4341
})
4442
common.renderHeader()
45-
46-
const searchBox = document.querySelector('.search-box')
47-
if (searchBox && envTarget === 'open') {
48-
searchBox.style.display = 'block'
49-
}
5043
})
5144
const { designConfig, currentThemeKey } = useTheme()
5245

examples/sites/src/main.js

+14
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,25 @@ import hljs from 'highlight.js/lib/core'
3131
import javascript from 'highlight.js/lib/languages/javascript'
3232
import css from 'highlight.js/lib/languages/css'
3333
import html from 'highlight.js/lib/languages/xml'
34+
import docsearch from '@docsearch/js'
35+
import '@docsearch/css'
36+
37+
const envTarget = import.meta.env.VITE_BUILD_TARGET || 'open'
3438

3539
hljs.registerLanguage('javascript', javascript)
3640
hljs.registerLanguage('css', css)
3741
hljs.registerLanguage('html', html)
3842

43+
if (envTarget === 'open') {
44+
docsearch({
45+
appId: 'AGPA5UXHMH',
46+
apiKey: '5fa09fc20270efa61d68e2c2eb0f56df',
47+
indexName: 'opentiny',
48+
container: '.search-box',
49+
debug: false
50+
})
51+
}
52+
3953
// 实验后发现,先调用一次预热一下,后续再调用会有速度的提示,因此在main中预热一下。
4054
setTimeout(() => {
4155
hljs.highlightAuto(`<template>

examples/sites/src/style.css

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ html {
44
}
55

66
/* reset.css 引入后造成site官网中 b 和 strong 标签没有粗体,此处还原粗体 */
7-
b, strong {
7+
b,
8+
strong {
89
font-weight: 700;
910
}
1011

@@ -22,7 +23,8 @@ b, strong {
2223
z-index: 1000 !important;
2324
}
2425

25-
.tiny-grid td,.tiny-grid th {
26+
.tiny-grid td,
27+
.tiny-grid th {
2628
vertical-align: middle;
2729
}
2830

@@ -42,7 +44,7 @@ b, strong {
4244

4345
.DocSearch-Button {
4446
border-radius: 6px;
45-
transition: 0.4s
47+
transition: 0.4s;
4648
}
4749

4850
.DocSearch-Button:hover {

0 commit comments

Comments
 (0)