diff --git a/.env b/.env index ef4471b8a0d1af43d7b83d61d0888431e2d6bd38..361dcb23e58d732e0d11c7c30ee91cb6ebdc3540 100644 --- a/.env +++ b/.env @@ -1,5 +1,2 @@ # spa-title VITE_GLOB_APP_TITLE = Vben Admin - -# spa shortname -VITE_GLOB_APP_SHORT_NAME = vue_vben_admin diff --git a/internal/vite-config/package.json b/internal/vite-config/package.json index aad9d9a86149adb9e7df0f927b8b2d5bd4648f1d..5be979d77ae4e9a34bbe4e5ecd325e80280ebe36 100644 --- a/internal/vite-config/package.json +++ b/internal/vite-config/package.json @@ -31,6 +31,7 @@ "stub": "pnpm unbuild --stub" }, "dependencies": { + "@ant-design/colors": "^7.0.0", "vite": "^4.3.0-beta.1" }, "devDependencies": { diff --git a/internal/vite-config/src/config/application.ts b/internal/vite-config/src/config/application.ts index d20ae1ffbc79df56c1b0aeeee4e94e4806881c27..19c7f881976a31f0604362f31aa81299730f26e5 100644 --- a/internal/vite-config/src/config/application.ts +++ b/internal/vite-config/src/config/application.ts @@ -74,7 +74,7 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) { output: { manualChunks: { vue: ['vue', 'pinia', 'vue-router'], - antdv: ['ant-design-vue', '@ant-design/icons-vue'], + antd: ['ant-design-vue', '@ant-design/icons-vue'], }, }, }, diff --git a/internal/vite-config/src/plugins/appConfig.ts b/internal/vite-config/src/plugins/appConfig.ts index 508b14805f72ec27d2911cb5512690626daee9d4..96395125578ee8500ff65f57e2eab0023ed51612 100644 --- a/internal/vite-config/src/plugins/appConfig.ts +++ b/internal/vite-config/src/plugins/appConfig.ts @@ -26,7 +26,8 @@ async function createAppConfigPlugin({ return { name: PLUGIN_NAME, async configResolved(_config) { - const appTitle = _config?.env?.VITE_GLOB_APP_SHORT_NAME ?? ''; + let appTitle = _config?.env?.VITE_GLOB_APP_TITLE ?? ''; + appTitle = appTitle.replace(/\s/g, '_'); publicPath = _config.base; source = await getConfigSource(appTitle); }, diff --git a/package.json b/package.json index 7c3c988193098a36ed941c7bfc7ac37ff3670dea..afa19b0c6dbbd6f046aa0297c38bb15c2b42ed1a 100644 --- a/package.json +++ b/package.json @@ -66,13 +66,10 @@ } }, "dependencies": { - "@ant-design/colors": "^7.0.0", "@ant-design/icons-vue": "^6.1.0", "@iconify/iconify": "^3.1.0", "@logicflow/core": "^1.2.1", "@logicflow/extension": "^1.2.1", - "@vue/runtime-core": "^3.2.47", - "@vue/shared": "^3.2.47", "@vueuse/core": "^9.13.0", "@vueuse/shared": "^9.13.0", "@zxcvbn-ts/core": "^2.2.1", @@ -111,6 +108,7 @@ }, "devDependencies": { "@commitlint/cli": "^17.5.1", + "@commitlint/config-conventional": "^17.4.4", "@iconify/json": "^2.2.45", "@purge-icons/generated": "^0.9.0", "@types/codemirror": "^5.60.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5d53b4ea43f12fa157c5b88d09013e5681e3b045..c15f14be0d955a25d1a770bf371f47b1ca039430 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,9 +4,6 @@ importers: .: dependencies: - '@ant-design/colors': - specifier: ^7.0.0 - version: 7.0.0 '@ant-design/icons-vue': specifier: ^6.1.0 version: 6.1.0(vue@3.2.47) @@ -19,12 +16,6 @@ importers: '@logicflow/extension': specifier: ^1.2.1 version: 1.2.1 - '@vue/runtime-core': - specifier: ^3.2.47 - version: 3.2.47 - '@vue/shared': - specifier: ^3.2.47 - version: 3.2.47 '@vueuse/core': specifier: ^9.13.0 version: 9.13.0(vue@3.2.47) @@ -134,6 +125,9 @@ importers: '@commitlint/cli': specifier: ^17.5.1 version: 17.5.1 + '@commitlint/config-conventional': + specifier: ^17.4.4 + version: 17.4.4 '@iconify/json': specifier: ^2.2.45 version: 2.2.45 @@ -378,6 +372,9 @@ importers: internal/vite-config: dependencies: + '@ant-design/colors': + specifier: ^7.0.0 + version: 7.0.0 vite: specifier: ^4.3.0-beta.1 version: 4.3.0-beta.1(@types/node@18.15.11)(less@4.1.3)(sass@1.60.0) @@ -791,6 +788,13 @@ packages: - '@swc/wasm' dev: true + /@commitlint/config-conventional@17.4.4: + resolution: {integrity: sha512-u6ztvxqzi6NuhrcEDR7a+z0yrh11elY66nRrQIpqsqW6sZmpxYkDLtpRH8jRML+mmxYQ8s4qqF06Q/IQx5aJeQ==} + engines: {node: '>=v14'} + dependencies: + conventional-changelog-conventionalcommits: 5.0.0 + dev: true + /@commitlint/config-validator@17.4.4: resolution: {integrity: sha512-bi0+TstqMiqoBAQDvdEP4AFh0GaKyLFlPPEObgI29utoKEYoPQTvF0EYqIwYYLEoJYhj5GfMIhPHJkTJhagfeg==} engines: {node: '>=v14'} @@ -3176,6 +3180,15 @@ packages: q: 1.5.1 dev: true + /conventional-changelog-conventionalcommits@5.0.0: + resolution: {integrity: sha512-lCDbA+ZqVFQGUj7h9QBKoIpLhl8iihkO0nCTyRNzuXtcd7ubODpYB04IFy31JloiJgG0Uovu8ot8oxRzn7Nwtw==} + engines: {node: '>=10'} + dependencies: + compare-func: 2.0.0 + lodash: 4.17.21 + q: 1.5.1 + dev: true + /conventional-commits-parser@3.2.4: resolution: {integrity: sha512-nK7sAtfi+QXbxHCYfhpZsfRtaitZLIA6889kFIouLvz6repszQDgxBu7wf2WbU+Dco7sAnNCJYERCwt54WPC2Q==} engines: {node: '>=10'} diff --git a/src/hooks/setting/index.ts b/src/hooks/setting/index.ts index 5fddaba8ff55337fb19631ce7980853b78540dd2..6a49893c83658afbe7d7ff3d1ec5bfd99dd2d864 100644 --- a/src/hooks/setting/index.ts +++ b/src/hooks/setting/index.ts @@ -1,28 +1,16 @@ import type { GlobConfig } from '/#/config'; -import { warn } from '/@/utils/log'; import { getAppEnvConfig } from '/@/utils/env'; export const useGlobSetting = (): Readonly => { - const { - VITE_GLOB_APP_TITLE, - VITE_GLOB_API_URL, - VITE_GLOB_APP_SHORT_NAME, - VITE_GLOB_API_URL_PREFIX, - VITE_GLOB_UPLOAD_URL, - } = getAppEnvConfig(); - - if (!/[a-zA-Z_]*/.test(VITE_GLOB_APP_SHORT_NAME)) { - warn( - `VITE_GLOB_APP_SHORT_NAME Variables can only be characters/underscores, please modify in the environment variables and re-running.`, - ); - } + const { VITE_GLOB_APP_TITLE, VITE_GLOB_API_URL, VITE_GLOB_API_URL_PREFIX, VITE_GLOB_UPLOAD_URL } = + getAppEnvConfig(); // Take global configuration const glob: Readonly = { title: VITE_GLOB_APP_TITLE, apiUrl: VITE_GLOB_API_URL, - shortName: VITE_GLOB_APP_SHORT_NAME, + shortName: VITE_GLOB_APP_TITLE.replace(/\s/g, '_'), urlPrefix: VITE_GLOB_API_URL_PREFIX, uploadUrl: VITE_GLOB_UPLOAD_URL, }; diff --git a/src/utils/env.ts b/src/utils/env.ts index a258bc821fec8cc10f930ceaec8ad960e7577c58..35596934d1e3fb1a54a479b8326eed39ad1ba61f 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -1,15 +1,16 @@ import type { GlobEnvConfig } from '/#/config'; -import { warn } from '/@/utils/log'; import pkg from '../../package.json'; const getVariableName = (title: string) => { - return `__PRODUCTION__${title || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, ''); + return `__PRODUCTION__${title.replace(/\s/g, '_') || '__APP'}__CONF__` + .toUpperCase() + .replace(/\s/g, ''); }; export function getCommonStoragePrefix() { - const { VITE_GLOB_APP_SHORT_NAME } = getAppEnvConfig(); - return `${VITE_GLOB_APP_SHORT_NAME}__${getEnv()}`.toUpperCase(); + const { VITE_GLOB_APP_TITLE } = getAppEnvConfig(); + return `${VITE_GLOB_APP_TITLE.replace(/\s/g, '_')}__${getEnv()}`.toUpperCase(); } // Generate cache key according to version @@ -18,31 +19,19 @@ export function getStorageShortName() { } export function getAppEnvConfig() { - const ENV_NAME = getVariableName(import.meta.env.VITE_GLOB_APP_SHORT_NAME); + const ENV_NAME = getVariableName(import.meta.env.VITE_GLOB_APP_TITLE); const ENV = (import.meta.env.DEV ? // Get the global configuration (the configuration will be extracted independently when packaging) (import.meta.env as unknown as GlobEnvConfig) : window[ENV_NAME as any]) as unknown as GlobEnvConfig; - const { - VITE_GLOB_APP_TITLE, - VITE_GLOB_API_URL, - VITE_GLOB_APP_SHORT_NAME, - VITE_GLOB_API_URL_PREFIX, - VITE_GLOB_UPLOAD_URL, - } = ENV; - - if (!/^[a-zA-Z_]*$/.test(VITE_GLOB_APP_SHORT_NAME)) { - warn( - `VITE_GLOB_APP_SHORT_NAME Variables can only be characters/underscores, please modify in the environment variables and re-running.`, - ); - } + const { VITE_GLOB_APP_TITLE, VITE_GLOB_API_URL, VITE_GLOB_API_URL_PREFIX, VITE_GLOB_UPLOAD_URL } = + ENV; return { VITE_GLOB_APP_TITLE, VITE_GLOB_API_URL, - VITE_GLOB_APP_SHORT_NAME, VITE_GLOB_API_URL_PREFIX, VITE_GLOB_UPLOAD_URL, }; diff --git a/types/config.d.ts b/types/config.d.ts index 8041e503ddd6b285c6cafd335e7e4854992a227f..18ef03ac4e4b3bf3d2be0fb50664845b0564e995 100644 --- a/types/config.d.ts +++ b/types/config.d.ts @@ -155,8 +155,6 @@ export interface GlobEnvConfig { VITE_GLOB_API_URL: string; // Service interface url prefix VITE_GLOB_API_URL_PREFIX?: string; - // Project abbreviation - VITE_GLOB_APP_SHORT_NAME: string; // Upload url VITE_GLOB_UPLOAD_URL?: string; } diff --git a/types/global.d.ts b/types/global.d.ts index 38d629e7f316fe7084b3d48ec3fc074e37ff9bb1..239c99afc1dd7362b4bdb6383b85f59d7da2c176 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -61,7 +61,6 @@ declare global { VITE_PUBLIC_PATH: string; VITE_PROXY: [string, string][]; VITE_GLOB_APP_TITLE: string; - VITE_GLOB_APP_SHORT_NAME: string; VITE_BUILD_COMPRESS: 'gzip' | 'brotli' | 'none'; }