Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8191490
commit 094dca9
Showing
24 changed files
with
75 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ VITE_APP_NAME=SoybeanAdmin | |
VITE_APP_TITLE=Soybean管理系统 | ||
|
||
VITE_APP_DESC=SoybeanAdmin是一个中后台管理系统模版 | ||
|
||
VITE_HTTP_PROXY=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,38 @@ | ||
/** 请求环境配置 */ | ||
type ServiceEnv = Record< | ||
Service.HttpEnv, | ||
EnvType, | ||
{ | ||
/** 请求环境 */ | ||
env: Service.HttpEnv; | ||
/** 请求地址 */ | ||
url: string; | ||
/** 代理地址 */ | ||
proxy: string; | ||
} | ||
>; | ||
|
||
/** 请求的环境 */ | ||
export const serviceEnv: ServiceEnv = { | ||
const serviceEnvConfig: ServiceEnv = { | ||
dev: { | ||
url: 'http://localhost:8080', | ||
proxy: '/api', | ||
}, | ||
test: { | ||
env: 'test', | ||
url: 'http://www.baidu.com', | ||
url: 'http://localhost:8080', | ||
proxy: '/api', | ||
}, | ||
prod: { | ||
env: 'prod', | ||
url: 'http://www.baidu.com', | ||
url: 'http://localhost:8080', | ||
proxy: '/api', | ||
}, | ||
}; | ||
|
||
/** | ||
* 获取环境配置 | ||
* @param env 环境描述 | ||
*/ | ||
export function getEnvConfig(env: ImportMetaEnv) { | ||
const { VITE_ENV_TYPE = 'dev' } = env; | ||
const envConfig = { | ||
http: serviceEnvConfig[VITE_ENV_TYPE], | ||
}; | ||
return envConfig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './common'; | ||
export * from './system'; | ||
export * from './router'; | ||
export * from './layout'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './common'; | ||
export * from './service'; | ||
export * from './regexp'; | ||
export * from './map-sdk'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { request } from '../request'; | ||
|
||
/** 测试请求代理 */ | ||
export function fetchTestProxy() { | ||
return request.get('/test'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './auth'; | ||
export * from './demo'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import { createRequest } from './request'; | ||
import { serviceEnv } from '~/.env-config'; | ||
import { getEnvConfig } from '~/.env-config'; | ||
|
||
const { VITE_HTTP_ENV = 'test' } = import.meta.env; | ||
const { http } = getEnvConfig(import.meta.env); | ||
const isHttpProxy = import.meta.env.VITE_HTTP_PROXY === 'true'; | ||
|
||
const { url } = serviceEnv[VITE_HTTP_ENV]; | ||
|
||
export const request = createRequest({ baseURL: url }); | ||
export const request = createRequest({ baseURL: isHttpProxy ? http.proxy : http.url }); | ||
|
||
export const mockRequest = createRequest({ baseURL: '/mock' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters