From c99ef68b7b82097325532b9478cf5305d43ac9df Mon Sep 17 00:00:00 2001 From: jinmao88 <50581550+jinmao88@users.noreply.github.com> Date: Thu, 10 Aug 2023 15:16:22 +0800 Subject: [PATCH] fix: ci --- internal/vite-config/src/plugins/appConfig.ts | 2 +- src/utils/env.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/vite-config/src/plugins/appConfig.ts b/internal/vite-config/src/plugins/appConfig.ts index 70a2a5c2e..98594b1a0 100644 --- a/internal/vite-config/src/plugins/appConfig.ts +++ b/internal/vite-config/src/plugins/appConfig.ts @@ -73,7 +73,7 @@ async function createAppConfigPlugin({ * Get the configuration file variable name * @param env */ -export const getVariableName = (title: string) => { +const getVariableName = (title: string) => { function strToHex(str: string) { const result: string[] = []; for (let i = 0; i < str.length; ++i) { diff --git a/src/utils/env.ts b/src/utils/env.ts index b19ca0698..a169073dd 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -1,6 +1,5 @@ import type { GlobEnvConfig } from '/#/config'; import pkg from '../../package.json'; -import { getVariableName } from '@vben/vite-config/src/plugins/appConfig'; export function getCommonStoragePrefix() { const { VITE_GLOB_APP_TITLE } = getAppEnvConfig(); @@ -12,6 +11,19 @@ export function getStorageShortName() { return `${getCommonStoragePrefix()}${`__${pkg.version}`}__`.toUpperCase(); } +const getVariableName = (title: string) => { + 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 getAppEnvConfig() { console.log(import.meta.env.VITE_GLOB_APP_TITLE);