@@ -1,6 +1,3 @@ | |||||
# Whether to open mock | |||||
VITE_USE_MOCK = false | |||||
# public path | # public path | ||||
VITE_PUBLIC_PATH = / | VITE_PUBLIC_PATH = / | ||||
@@ -11,7 +8,7 @@ VITE_DROP_CONSOLE = false | |||||
VITE_GLOB_API_URL = https://test.vogocm.com:9697 | VITE_GLOB_API_URL = https://test.vogocm.com:9697 | ||||
# File upload address, optional | # File upload address, optional | ||||
VITE_GLOB_UPLOAD_URL=/upload | |||||
VITE_GLOB_UPLOAD_URL = https://test.vogocm.com:9697/admin-api/infra/upload | |||||
# Interface prefix | # Interface prefix | ||||
VITE_GLOB_API_URL_PREFIX= | VITE_GLOB_API_URL_PREFIX= |
@@ -1,6 +1,3 @@ | |||||
# Whether to open mock | |||||
VITE_USE_MOCK = false | |||||
# public path | # public path | ||||
VITE_PUBLIC_PATH = / | VITE_PUBLIC_PATH = / | ||||
@@ -16,7 +13,7 @@ VITE_BUILD_COMPRESS = 'none' | |||||
VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false | VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false | ||||
# Basic interface address SPA | # Basic interface address SPA | ||||
VITE_GLOB_API_URL= | |||||
VITE_GLOB_API_URL = https://test.vogocm.com:9697 | |||||
# File upload address, optional | # File upload address, optional | ||||
# It can be forwarded by nginx or write the actual address directly | # It can be forwarded by nginx or write the actual address directly | ||||
@@ -0,0 +1,30 @@ | |||||
import type { GlobConfig } from '/#/config'; | |||||
import { warn } from '@/utils/log'; | |||||
import { getAppEnvConfig } from '@/utils/env'; | |||||
export const useGlobSetting = (): Readonly<GlobConfig> => { | |||||
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.`, | |||||
); | |||||
} | |||||
// Take global configuration | |||||
const glob: Readonly<GlobConfig> = { | |||||
title: VITE_GLOB_APP_TITLE, | |||||
apiUrl: VITE_GLOB_API_URL, | |||||
shortName: VITE_GLOB_APP_SHORT_NAME, | |||||
urlPrefix: VITE_GLOB_API_URL_PREFIX, | |||||
uploadUrl: VITE_GLOB_UPLOAD_URL, | |||||
}; | |||||
return glob as Readonly<GlobConfig>; | |||||
}; |
@@ -7,6 +7,10 @@ import axios, { | |||||
} from 'axios'; | } from 'axios'; | ||||
import {antdUtils} from '@/utils/antd'; | import {antdUtils} from '@/utils/antd'; | ||||
import { useGlobSetting } from '@/hooks/use-global-settings'; | |||||
const { apiUrl = '' } = useGlobSetting(); | |||||
// axios.defaults.withCredentials = true; | // axios.defaults.withCredentials = true; | ||||
export type Response<T> = Promise<[boolean, T, AxiosResponse<T>]>; | export type Response<T> = Promise<[boolean, T, AxiosResponse<T>]>; | ||||
@@ -151,6 +155,6 @@ class Request { | |||||
} | } | ||||
} | } | ||||
const request = new Request({timeout: 60 * 1000 * 5, baseURL: 'https://test.vogocm.com:9697'}); | |||||
const request = new Request({timeout: 60 * 1000 * 5, baseURL: apiUrl}); | |||||
export default request; | export default request; |
@@ -16,7 +16,7 @@ export function getStorageShortName() { | |||||
export function getAppEnvConfig() { | export function getAppEnvConfig() { | ||||
const ENV_NAME = getConfigFileName(import.meta.env); | const ENV_NAME = getConfigFileName(import.meta.env); | ||||
const ENV = (import.meta.env.DEV | const ENV = (import.meta.env.DEV | ||||
? // Get the global configuration (the configuration will be extracted independently when packaging) | ? // Get the global configuration (the configuration will be extracted independently when packaging) | ||||
(import.meta.env as unknown as GlobEnvConfig) | (import.meta.env as unknown as GlobEnvConfig) | ||||
@@ -45,39 +45,17 @@ export function getAppEnvConfig() { | |||||
}; | }; | ||||
} | } | ||||
/** | |||||
* @description: Development mode | |||||
*/ | |||||
export const devMode = 'development'; | export const devMode = 'development'; | ||||
/** | |||||
* @description: Production mode | |||||
*/ | |||||
export const prodMode = 'production'; | export const prodMode = 'production'; | ||||
/** | |||||
* @description: Get environment variables | |||||
* @returns: | |||||
* @example: | |||||
*/ | |||||
export function getEnv(): string { | export function getEnv(): string { | ||||
return import.meta.env.MODE; | return import.meta.env.MODE; | ||||
} | } | ||||
/** | |||||
* @description: Is it a development mode | |||||
* @returns: | |||||
* @example: | |||||
*/ | |||||
export function isDevMode(): boolean { | export function isDevMode(): boolean { | ||||
return import.meta.env.DEV; | return import.meta.env.DEV; | ||||
} | } | ||||
/** | |||||
* @description: Is it a production mode | |||||
* @returns: | |||||
* @example: | |||||
*/ | |||||
export function isProdMode(): boolean { | export function isProdMode(): boolean { | ||||
return import.meta.env.PROD; | return import.meta.env.PROD; | ||||
} | } |
@@ -25,7 +25,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { | |||||
}, | }, | ||||
}, | }, | ||||
server: { | server: { | ||||
https: true, | |||||
https: false, | |||||
host: true, | host: true, | ||||
port: VITE_PORT, | port: VITE_PORT, | ||||
}, | }, | ||||