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> = {