mirror of
				https://github.com/soybeanjs/soybean-admin.git
				synced 2025-11-04 15:53:43 +08:00 
			
		
		
		
	perf(projects): env config
This commit is contained in:
		@@ -25,7 +25,7 @@ export function createViteProxy(env: Env.ImportMeta) {
 | 
			
		||||
  const otherURLEntries = Object.entries(otherBaseURL);
 | 
			
		||||
 | 
			
		||||
  for (const [key, url] of otherURLEntries) {
 | 
			
		||||
    const proxyPattern = createProxyPattern(key);
 | 
			
		||||
    const proxyPattern = createProxyPattern(key as App.Service.OtherBaseURLKey);
 | 
			
		||||
 | 
			
		||||
    proxy[proxyPattern] = {
 | 
			
		||||
      target: url,
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@
 | 
			
		||||
export function createServiceConfig(env: Env.ImportMeta) {
 | 
			
		||||
  const mockURL = 'https://mock.apifox.com/m1/3109515-0-default';
 | 
			
		||||
 | 
			
		||||
  const serviceConfigMap = {
 | 
			
		||||
  const serviceConfigMap: App.Service.ServiceConfigMap = {
 | 
			
		||||
    dev: {
 | 
			
		||||
      baseURL: mockURL,
 | 
			
		||||
      otherBaseURL: {
 | 
			
		||||
@@ -24,7 +24,7 @@ export function createServiceConfig(env: Env.ImportMeta) {
 | 
			
		||||
        demo: 'http://localhost:9530'
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  } satisfies App.Service.ServiceConfigMap;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  const { VITE_SERVICE_ENV = 'dev' } = env;
 | 
			
		||||
 | 
			
		||||
@@ -35,7 +35,7 @@ export function createServiceConfig(env: Env.ImportMeta) {
 | 
			
		||||
 * get proxy pattern of service url
 | 
			
		||||
 * @param key if not set, will use the default key
 | 
			
		||||
 */
 | 
			
		||||
export function createProxyPattern(key?: string) {
 | 
			
		||||
export function createProxyPattern(key?: App.Service.OtherBaseURLKey) {
 | 
			
		||||
  if (!key) {
 | 
			
		||||
    return '/proxy';
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								src/typings/app.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								src/typings/app.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -523,10 +523,15 @@ declare namespace App {
 | 
			
		||||
     */
 | 
			
		||||
    type EnvType = 'dev' | 'test' | 'prod';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * other baseURL key
 | 
			
		||||
     */
 | 
			
		||||
    type OtherBaseURLKey = 'demo';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * the backend service config
 | 
			
		||||
     */
 | 
			
		||||
    interface ServiceConfig {
 | 
			
		||||
    interface ServiceConfig<T extends OtherBaseURLKey = OtherBaseURLKey> {
 | 
			
		||||
      /**
 | 
			
		||||
       * the backend service base url
 | 
			
		||||
       */
 | 
			
		||||
@@ -534,7 +539,7 @@ declare namespace App {
 | 
			
		||||
      /**
 | 
			
		||||
       * other backend service base url map
 | 
			
		||||
       */
 | 
			
		||||
      otherBaseURL: Record<string, string>;
 | 
			
		||||
      otherBaseURL: Record<T, string>;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user