From 569ac3c0ca9db28545f94e2dd490f079f35ba246 Mon Sep 17 00:00:00 2001 From: ajaxzheng <894103554@qq.com> Date: Mon, 9 Dec 2024 14:09:19 +0800 Subject: [PATCH] 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 --- examples/sites/index.html | 13 +------------ examples/sites/package.json | 6 ++++-- examples/sites/src/App.vue | 7 ------- examples/sites/src/main.js | 14 ++++++++++++++ examples/sites/src/style.css | 8 +++++--- 5 files changed, 24 insertions(+), 24 deletions(-) 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(`