123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import type { GlobEnvConfig } from '/#/config';
- // import { warn } from '/@/utils/log';
- import pkg from '../../package.json';
- import { getConfigFileName } from '../../build/getConfigFileName';
- import { ThemeModel } from '/@/layouts/default/layout.data';
- export function getCommonStoragePrefix() {
- const { VITE_GLOB_APP_SHORT_NAME } = getAppEnvConfig();
- return `${VITE_GLOB_APP_SHORT_NAME}__${getEnv()}`.toUpperCase();
- }
- // Generate cache key according to version
- export function getStorageShortName() {
- return `${getCommonStoragePrefix()}${`__${pkg.version}`}__`.toUpperCase();
- }
- export function getAppEnvConfig() {
- const ENV_NAME = getConfigFileName(import.meta.env);
- 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_USE_MOCK,
- VITE_GLOB_APP_SHORT_NAME,
- VITE_GLOB_API_URL_PREFIX,
- VITE_GLOB_APP_OPEN_SSO,
- VITE_GLOB_APP_OPEN_QIANKUN,
- VITE_GLOB_APP_CAS_BASE_URL,
- VITE_GLOB_DOMAIN_URL,
- VITE_GLOB_ONLINE_VIEW_URL,
- VITE_3D_MODAL_ARR,
- } = 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.`
- // );
- }
- return {
- VITE_GLOB_APP_TITLE,
- VITE_GLOB_API_URL,
- VITE_USE_MOCK,
- VITE_GLOB_APP_SHORT_NAME,
- VITE_GLOB_API_URL_PREFIX,
- VITE_GLOB_APP_OPEN_SSO,
- VITE_GLOB_APP_OPEN_QIANKUN,
- VITE_GLOB_APP_CAS_BASE_URL,
- VITE_GLOB_DOMAIN_URL,
- VITE_GLOB_ONLINE_VIEW_URL,
- VITE_3D_MODAL_ARR,
- };
- }
- /**
- * @description: Development mode
- */
- export const devMode = 'development';
- /**
- * @description: Production mode
- */
- export const prodMode = 'production';
- /**
- * @description: Get environment variables
- * @returns:
- * @example:
- */
- export function getEnv(): string {
- return import.meta.env.MODE;
- }
- /**
- * @description: Is it a development mode
- * @returns:
- * @example:
- */
- export function isDevMode(): boolean {
- return import.meta.env.DEV;
- }
- /**
- * @description: Is it a production mode
- * @returns:
- * @example:
- */
- export function isProdMode(): boolean {
- return import.meta.env.PROD;
- }
- export function getHomePath(key): string {
- let homePath = '/micro-vent-3dModal/dashboard/analysis';
- switch (key) {
- case 'styleOne':
- // 显示6.0
- homePath = '/micro-vent-3dModal/dashboard/analysis';
- // switchTheme(ThemeModel.theme6_0);
- break;
- case 'styleTwo':
- // 显示5.5
- homePath = '/micro-vent-3dModal/modelchannel/model3D/home';
- switchTheme(ThemeModel.theme5_5);
- break;
- }
- return homePath;
- }
- function switchTheme(obj) {
- for (const key in obj) {
- document.getElementsByTagName('body')[0].style.setProperty(`--${key}`, obj[key]);
- }
- }
|