@opentiny/vue-docs 3.20.5 → 3.20.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/vue-docs",
3
- "version": "3.20.5",
3
+ "version": "3.20.7",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
6
  "@opentiny/vue-repl": "^1.1.2",
@@ -19,20 +19,20 @@
19
19
  "@docsearch/js": "^3.8.0",
20
20
  "@docsearch/css": "^3.8.0",
21
21
  "@docsearch/react": "npm:@docsearch/css",
22
- "@opentiny/vue": "~3.20.0",
22
+ "@opentiny/vue-design-saas": "~3.20.0",
23
23
  "@opentiny/vue-common": "~3.20.1",
24
24
  "@opentiny/vue-design-aurora": "~3.20.0",
25
- "@opentiny/vue-design-saas": "~3.20.0",
25
+ "@opentiny/vue": "~3.20.0",
26
26
  "@opentiny/vue-design-smb": "~3.20.0",
27
- "@opentiny/vue-directive": "~3.20.0",
28
27
  "@opentiny/vue-hooks": "~3.20.0",
29
- "@opentiny/vue-icon-multicolor": "~3.20.0",
30
- "@opentiny/vue-icon": "~3.20.0",
28
+ "@opentiny/vue-directive": "~3.20.0",
31
29
  "@opentiny/vue-icon-saas": "~3.20.0",
32
- "@opentiny/vue-theme": "~3.20.0",
30
+ "@opentiny/vue-icon": "~3.20.0",
31
+ "@opentiny/vue-icon-multicolor": "~3.20.0",
33
32
  "@opentiny/vue-theme-mobile": "~3.20.0",
33
+ "@opentiny/vue-theme-saas": "~3.20.0",
34
34
  "@opentiny/vue-vite-import": "~1.2.0",
35
- "@opentiny/vue-theme-saas": "~3.20.0"
35
+ "@opentiny/vue-theme": "~3.20.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@playwright/test": "~1.42.0",
@@ -1,26 +1,11 @@
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
1
  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)
2
+ window.handleGlobalSearchData = (resolve) => {
3
+ return (data) => {
4
+ if (typeof data.content === 'string') {
5
+ data.content = data.content.replaceAll('https://opentiny.design', window.location.origin)
23
6
  }
7
+
8
+ resolve(data)
24
9
  }
25
- })
10
+ }
26
11
  }
@@ -0,0 +1,19 @@
1
+ export default function viteDosearchPlugin() {
2
+ return {
3
+ name: 'vite-dosearch-plugin',
4
+ enforce: 'pre',
5
+ transform(code, id) {
6
+ if (id.includes('@docsearch')) {
7
+
8
+ const newCode = code.replace(
9
+ 'Promise((function(t){var n=new XMLHttpRequest;',
10
+ 'Promise((function(t){t=window.handleGlobalSearchData(t);var n=new XMLHttpRequest;'
11
+ )
12
+ return {
13
+ code: newCode,
14
+ map: null
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
package/vite.config.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { defineConfig, loadEnv } from 'vite'
2
2
  import vue from '@vitejs/plugin-vue'
3
+ import viteDosearchPlugin from './vite-dosearch-plugin'
3
4
  import Unocss from 'unocss/vite'
4
5
  import path from 'node:path'
5
6
  import UnoCssConfig from './uno.config'
@@ -42,6 +43,7 @@ export default defineConfig((config) => {
42
43
  const env = loadEnv(config.mode, process.cwd() + '/env', '')
43
44
  const isSaas = env.VITE_TINY_THEME === 'saas'
44
45
  const isPlus = env.VITE_APP_MODE === 'plus'
46
+ const isInner = env.VITE_BUILD_TARGET === 'inner'
45
47
  const demosPath = isPlus ? '../plusdocs/pc' : `./demos/${env.VITE_APP_MODE}`
46
48
  const apisPath = isPlus ? '../plusdocs/apis' : './demos/apis'
47
49
  const menuPath = isSaas ? path.resolve('./demos/saas') : path.resolve(demosPath)
@@ -115,7 +117,8 @@ export default defineConfig((config) => {
115
117
  viteStaticCopy({
116
118
  targets: copyTarget
117
119
  }),
118
- delStatic()
120
+ delStatic(),
121
+ isInner ? viteDosearchPlugin() : null
119
122
  ],
120
123
  optimizeDeps: getOptimizeDeps(3),
121
124
  build: {