Commit 0347c83620df676fb02790c13b3304104b4e0e71

Authored by xiaoWangSec
Committed by GitHub
1 parent eb0fdb2c

fix: 修复VITE_GLOB_APP_TITLE中不能存在-的问题#1522 (#2794)

* fix #1522

fix #1522

* fix #1522

fix #1522

* fix #1522

fix #1522
internal/vite-config/src/plugins/appConfig.ts
... ... @@ -28,7 +28,7 @@ async function createAppConfigPlugin({
28 28 name: PLUGIN_NAME,
29 29 async configResolved(_config) {
30 30 let appTitle = _config?.env?.VITE_GLOB_APP_TITLE ?? '';
31   - appTitle = appTitle.replace(/\s/g, '_');
  31 + appTitle = appTitle.replace(/\s/g, '_').replace(/-/g, '_');
32 32 publicPath = _config.base;
33 33 source = await getConfigSource(appTitle);
34 34 },
... ...
src/hooks/setting/index.ts
... ... @@ -10,7 +10,7 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
10 10 const glob: Readonly<GlobConfig> = {
11 11 title: VITE_GLOB_APP_TITLE,
12 12 apiUrl: VITE_GLOB_API_URL,
13   - shortName: VITE_GLOB_APP_TITLE.replace(/\s/g, '_'),
  13 + shortName: VITE_GLOB_APP_TITLE.replace(/\s/g, '_').replace(/-/g, '_'),
14 14 urlPrefix: VITE_GLOB_API_URL_PREFIX,
15 15 uploadUrl: VITE_GLOB_UPLOAD_URL,
16 16 };
... ...
src/utils/env.ts
... ... @@ -2,7 +2,7 @@ import type { GlobEnvConfig } from &#39;/#/config&#39;;
2 2 import pkg from '../../package.json';
3 3  
4 4 const getVariableName = (title: string) => {
5   - return `__PRODUCTION__${title.replace(/\s/g, '_') || '__APP'}__CONF__`
  5 + return `__PRODUCTION__${title.replace(/\s/g, '_').replace(/-/g, '_') || '__APP'}__CONF__`
6 6 .toUpperCase()
7 7 .replace(/\s/g, '');
8 8 };
... ...