@opentiny/vue-docs 3.20.4 → 3.20.6

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.4",
3
+ "version": "3.20.6",
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-design-saas": "~3.20.0",
23
- "@opentiny/vue-common": "~3.20.1",
24
22
  "@opentiny/vue": "~3.20.0",
23
+ "@opentiny/vue-design-saas": "~3.20.0",
25
24
  "@opentiny/vue-directive": "~3.20.0",
26
25
  "@opentiny/vue-design-aurora": "~3.20.0",
27
- "@opentiny/vue-icon": "~3.20.0",
26
+ "@opentiny/vue-common": "~3.20.1",
28
27
  "@opentiny/vue-design-smb": "~3.20.0",
29
- "@opentiny/vue-hooks": "~3.20.0",
30
28
  "@opentiny/vue-icon-saas": "~3.20.0",
29
+ "@opentiny/vue-icon": "~3.20.0",
31
30
  "@opentiny/vue-theme": "~3.20.0",
32
31
  "@opentiny/vue-icon-multicolor": "~3.20.0",
33
- "@opentiny/vue-theme-mobile": "~3.20.0",
32
+ "@opentiny/vue-theme-saas": "~3.20.0",
33
+ "@opentiny/vue-hooks": "~3.20.0",
34
34
  "@opentiny/vue-vite-import": "~1.2.0",
35
- "@opentiny/vue-theme-saas": "~3.20.0"
35
+ "@opentiny/vue-theme-mobile": "~3.20.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@playwright/test": "~1.42.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
- if (envTarget === 'open') {
44
- docsearch({
45
- appId: 'AGPA5UXHMH',
46
- apiKey: '5fa09fc20270efa61d68e2c2eb0f56df',
47
- indexName: 'opentiny',
48
- container: '.search-box',
49
- debug: false
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,11 @@
1
+ export const doSearchEverySite = () => {
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)
6
+ }
7
+
8
+ resolve(data)
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,16 @@
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
+ const rep = /function\((.+)\)\s*?{\s*?(.+)new XMLHttpRequest/
8
+ const newCode = code.replace(rep, 'function($1) {$1=window.handleGlobalSearchData($1); $2new XMLHttpRequest')
9
+ return {
10
+ code: newCode,
11
+ map: null
12
+ }
13
+ }
14
+ }
15
+ }
16
+ }
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: {