diff --git a/examples/sites/index.html b/examples/sites/index.html index 15fc4412d6..f2cf591476 100644 --- a/examples/sites/index.html +++ b/examples/sites/index.html @@ -21,24 +21,13 @@ window.DEPLOY_URL = '' window.process = { env: {} } -
- - - + diff --git a/examples/sites/package.json b/examples/sites/package.json index cd63daf69d..76d6f91a3a 100644 --- a/examples/sites/package.json +++ b/examples/sites/package.json @@ -1,6 +1,6 @@ { "name": "@opentiny/vue-docs", - "version": "3.20.2", + "version": "3.20.3", "license": "MIT", "scripts": { "start": "vite", @@ -47,7 +47,9 @@ "tailwindcss": "^3.2.4", "vue": "^3.4.31", "vue-i18n": "^9.1.10", - "vue-router": "4.1.5" + "vue-router": "4.1.5", + "@docsearch/js": "^3.8.0", + "@docsearch/css": "^3.8.0" }, "devDependencies": { "@opentiny-internal/unplugin-virtual-template": "workspace:~", diff --git a/examples/sites/src/App.vue b/examples/sites/src/App.vue index e2b1b75e14..231b73a998 100644 --- a/examples/sites/src/App.vue +++ b/examples/sites/src/App.vue @@ -17,8 +17,6 @@ import { iconClose } from '@opentiny/vue-icon' import { appData } from './tools' import useTheme from './tools/useTheme' -const envTarget = import.meta.env.VITE_BUILD_TARGET || 'open' - export default defineComponent({ name: 'AppVue', props: [], @@ -42,11 +40,6 @@ export default defineComponent({ } }) common.renderHeader() - - const searchBox = document.querySelector('.search-box') - if (searchBox && envTarget === 'open') { - searchBox.style.display = 'block' - } }) const { designConfig, currentThemeKey } = useTheme() diff --git a/examples/sites/src/main.js b/examples/sites/src/main.js index 25abda9e96..75b2342c0b 100644 --- a/examples/sites/src/main.js +++ b/examples/sites/src/main.js @@ -31,11 +31,25 @@ import hljs from 'highlight.js/lib/core' import javascript from 'highlight.js/lib/languages/javascript' import css from 'highlight.js/lib/languages/css' import html from 'highlight.js/lib/languages/xml' +import docsearch from '@docsearch/js' +import '@docsearch/css' + +const envTarget = import.meta.env.VITE_BUILD_TARGET || 'open' hljs.registerLanguage('javascript', javascript) hljs.registerLanguage('css', css) hljs.registerLanguage('html', html) +if (envTarget === 'open') { + docsearch({ + appId: 'AGPA5UXHMH', + apiKey: '5fa09fc20270efa61d68e2c2eb0f56df', + indexName: 'opentiny', + container: '.search-box', + debug: false + }) +} + // 实验后发现,先调用一次预热一下,后续再调用会有速度的提示,因此在main中预热一下。 setTimeout(() => { hljs.highlightAuto(`