Commit 22dfee7d1d0bea8549d18a20562e9d7687aca270
Merge branch 'fix/page-title' into 'main_dev'
fix: 修复刷新页面页标题显示问题 See merge request yunteng/thingskit-view!293
Showing
2 changed files
with
33 additions
and
26 deletions
1 | -import { Plugin } from 'vite' | |
2 | -import { createHtmlPlugin } from 'vite-plugin-html' | |
1 | +import { HtmlTagDescriptor, Plugin } from 'vite' | |
2 | +// import { createHtmlPlugin } from 'vite-plugin-html' | |
3 | 3 | |
4 | 4 | const GLOB_CONFIG_FILE_NAME = '_app.config.js' |
5 | 5 | |
... | ... | @@ -10,34 +10,45 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean): Plugin { |
10 | 10 | return `${path || '/'}${GLOB_CONFIG_FILE_NAME}?v=${Date.now()}` |
11 | 11 | } |
12 | 12 | |
13 | - const htmlPlugin = createHtmlPlugin({ | |
14 | - minify: isBuild, | |
15 | - inject: { | |
16 | - data: { | |
17 | - title: VITE_GLOB_APP_TITLE, | |
18 | - }, | |
19 | - tags: isBuild ? [ | |
20 | - { | |
21 | - tag: 'script', | |
22 | - attrs: { src: getAppConfigSrc() } | |
23 | - } | |
24 | - ] : [] | |
25 | - } | |
26 | - }) | |
13 | + // const htmlPlugin = createHtmlPlugin({ | |
14 | + // minify: isBuild, | |
15 | + // inject: { | |
16 | + // data: { | |
17 | + // title: VITE_GLOB_APP_TITLE, | |
18 | + // }, | |
19 | + // tags: isBuild ? [ | |
20 | + // { | |
21 | + // tag: 'script', | |
22 | + // attrs: { src: getAppConfigSrc() } | |
23 | + // } | |
24 | + // ] : [] | |
25 | + // } | |
26 | + // }) | |
27 | + | |
27 | 28 | |
28 | 29 | |
30 | + const tags:HtmlTagDescriptor[] = [ | |
31 | + { | |
32 | + tag: 'title', | |
33 | + children: VITE_GLOB_APP_TITLE | |
34 | + } | |
35 | + ] | |
29 | 36 | |
37 | + if (isBuild) { | |
38 | + tags.push( | |
39 | + { | |
40 | + tag: 'script', | |
41 | + attrs: { src: getAppConfigSrc() } | |
42 | + } | |
43 | + ) | |
44 | + } | |
30 | 45 | return { |
31 | 46 | name: 'html-plugin', |
32 | 47 | transformIndexHtml: (code, ctx) => { |
48 | + | |
33 | 49 | return { |
34 | 50 | html: code, |
35 | - tags: isBuild ? [ | |
36 | - { | |
37 | - tag: 'script', | |
38 | - attrs: { src: getAppConfigSrc() } | |
39 | - } | |
40 | - ] : [] | |
51 | + tags | |
41 | 52 | } |
42 | 53 | }, |
43 | 54 | ... | ... |
... | ... | @@ -11,9 +11,6 @@ |
11 | 11 | <meta name="viewport" |
12 | 12 | content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" /> |
13 | 13 | <link rel="icon" href="./favicon.ico" /> |
14 | - <title> | |
15 | - <%= title %> | |
16 | - </title> | |
17 | 14 | <!-- <link rel="stylesheet" href="./index.css" /> --> |
18 | 15 | <style> |
19 | 16 | * { |
... | ... | @@ -114,7 +111,6 @@ |
114 | 111 | opacity: 1; |
115 | 112 | } |
116 | 113 | } |
117 | - | |
118 | 114 | </style> |
119 | 115 | </head> |
120 | 116 | ... | ... |