refactor(projects): refactor service env config

This commit is contained in:
Soybean
2024-03-02 12:22:10 +08:00
parent bccd6cb3c3
commit 43193e2808
13 changed files with 145 additions and 574 deletions

25
src/typings/app.d.ts vendored
View File

@ -600,22 +600,29 @@ declare namespace App {
/** Service namespace */
namespace Service {
/** The backend service env type */
type EnvType = 'dev' | 'test' | 'prod';
/** Other baseURL key */
type OtherBaseURLKey = 'demo';
/** The backend service config */
interface ServiceConfig<T extends OtherBaseURLKey = OtherBaseURLKey> {
interface ServiceConfigItem {
/** The backend service base url */
baseURL: string;
/** Other backend service base url map */
otherBaseURL: Record<T, string>;
/** The proxy pattern of the backend service base url */
proxyPattern: string;
}
/** The backend service config map */
type ServiceConfigMap = Record<EnvType, ServiceConfig>;
interface OtherServiceConfigItem extends ServiceConfigItem {
key: OtherBaseURLKey;
}
/** The backend service config */
interface ServiceConfig extends ServiceConfigItem {
/** Other backend service config */
other: OtherServiceConfigItem[];
}
interface SimpleServiceConfig extends Pick<ServiceConfigItem, 'baseURL'> {
other: Record<OtherBaseURLKey, string>;
}
/** The backend service response data */
type Response<T = unknown> = {

10
src/typings/env.d.ts vendored
View File

@ -25,14 +25,20 @@ declare namespace Env {
* This prefix is start with the icon prefix
*/
readonly VITE_ICON_LOCAL_PREFIX: 'local-icon';
/** backend service base url */
readonly VITE_SERVICE_BASE_URL: string;
/**
* other backend service base url
*
* the value is a json
*/
readonly VITE_OTHER_SERVICE_BASE_URL: string;
/**
* Whether to enable the http proxy
*
* Only valid in the development environment
*/
readonly VITE_HTTP_PROXY?: CommonType.YesOrNo;
/** The back service env */
readonly VITE_SERVICE_ENV?: App.Service.EnvType;
/**
* The auth route mode
*