diff --git a/internal/vite-config/src/plugins/appConfig.ts b/internal/vite-config/src/plugins/appConfig.ts index a4fb9542a..98594b1a0 100644 --- a/internal/vite-config/src/plugins/appConfig.ts +++ b/internal/vite-config/src/plugins/appConfig.ts @@ -74,7 +74,16 @@ async function createAppConfigPlugin({ * @param env */ const getVariableName = (title: string) => { - return `__PRODUCTION__${title || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, ''); + function strToHex(str: string) { + const result: string[] = []; + for (let i = 0; i < str.length; ++i) { + const hex = str.charCodeAt(i).toString(16); + result.push(('000' + hex).slice(-4)); + } + return result.join('').toUpperCase(); + } + + return `__PRODUCTION__${strToHex(title) || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, ''); }; async function getConfigSource(appTitle: string) { diff --git a/src/utils/env.ts b/src/utils/env.ts index 16af4f85a..ef0433cf5 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -2,9 +2,16 @@ import type { GlobEnvConfig } from '/#/config'; import pkg from '../../package.json'; const getVariableName = (title: string) => { - return `__PRODUCTION__${title.replace(/\s/g, '_').replace(/-/g, '_') || '__APP'}__CONF__` - .toUpperCase() - .replace(/\s/g, ''); + function strToHex(str: string) { + const result: string[] = []; + for (let i = 0; i < str.length; ++i) { + const hex = str.charCodeAt(i).toString(16); + result.push(('000' + hex).slice(-4)); + } + return result.join('').toUpperCase(); + } + + return `__PRODUCTION__${strToHex(title) || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, ''); }; export function getCommonStoragePrefix() {