diff --git a/.env.development b/.env.development index e0299c1..2f5b04c 100644 --- a/.env.development +++ b/.env.development @@ -1,18 +1,14 @@ -NODE_ENV = 'development' - -ENV = 'development' - +# 资源公共路径,需要以 /开头和结尾 VITE_PUBLIC_PATH = '/' -# 是否使用MOCK +# 是否启用MOCK VITE_APP_USE_MOCK = true # proxy VITE_PROXY = [["/api","http://localhost:8080"],["/api-test","localhost:8080"]] # base api -# VITE_APP_GLOB_BASE_API = '/api' -VITE_APP_GLOB_BASE_API = '/api-mock' +VITE_APP_GLOB_BASE_API = '/api' # test base api VITE_APP_GLOB_BASE_API_TEST = '/api-test' \ No newline at end of file diff --git a/.env.production b/.env.production index 3eab16c..d046738 100644 --- a/.env.production +++ b/.env.production @@ -1,14 +1,11 @@ -NODE_ENV = 'production' - -ENV = 'production' - +# 资源公共路径,需要以 /开头和结尾 VITE_PUBLIC_PATH = '/' -# 是否使用MOCK +# 是否启用MOCK VITE_APP_USE_MOCK = true # base api -VITE_APP_GLOB_BASE_API = '/api-mock' +VITE_APP_GLOB_BASE_API = '/api' # test base api VITE_APP_GLOB_BASE_API_TEST = '/api-test' \ No newline at end of file diff --git a/.env.staging b/.env.staging index 529ec5c..873b602 100644 --- a/.env.staging +++ b/.env.staging @@ -1,14 +1,11 @@ -NODE_ENV = 'production' - -ENV = 'staging' - +# 资源公共路径,需要以 /开头和结尾 VITE_PUBLIC_PATH = '/' -# 是否使用MOCK +# 是否启用MOCK VITE_APP_USE_MOCK = false # base api -VITE_APP_GLOB_BASE_API = '/api-mock' +VITE_APP_GLOB_BASE_API = 'http://localhost:8080/api' # test base api -VITE_APP_GLOB_BASE_API_TEST = '/api-test' \ No newline at end of file +VITE_APP_GLOB_BASE_API_TEST = 'http://localhost:8080/api-test' \ No newline at end of file diff --git a/.env.test b/.env.test index e1eb3b2..847db2b 100644 --- a/.env.test +++ b/.env.test @@ -1,14 +1,10 @@ -NODE_ENV = 'production' - -ENV = 'test' - VITE_PUBLIC_PATH = '/' -# 是否使用MOCK -VITE_APP_USE_MOCK = false +# 是否启用MOCK +VITE_APP_USE_MOCK = true # base api -VITE_APP_GLOB_BASE_API = '/api-mock' +VITE_APP_GLOB_BASE_API = '/api' # test base api VITE_APP_GLOB_BASE_API_TEST = '/api-test' \ No newline at end of file diff --git a/mock/auth/index.js b/mock/auth/index.js index ac62f94..c8fa18e 100644 --- a/mock/auth/index.js +++ b/mock/auth/index.js @@ -7,7 +7,7 @@ const token = { export default [ { - url: '/api-mock/auth/login', + url: '/api/auth/login', method: 'post', response: ({ body }) => { if (['admin', 'editor'].includes(body?.name)) { @@ -26,7 +26,7 @@ export default [ }, }, { - url: '/api-mock/auth/refreshToken', + url: '/api/auth/refreshToken', method: 'post', response: ({ headers }) => { return { diff --git a/mock/user/index.js b/mock/user/index.js index b2603df..af2df28 100644 --- a/mock/user/index.js +++ b/mock/user/index.js @@ -24,7 +24,7 @@ const users = { } export default [ { - url: '/api-mock/user', + url: '/api/user', method: 'get', response: ({ headers }) => { const token = resolveToken(headers?.authorization) diff --git a/src/api/user/index.js b/src/api/user/index.js index 72e8017..200d115 100644 --- a/src/api/user/index.js +++ b/src/api/user/index.js @@ -1,4 +1,4 @@ -import { defAxios, mockAxios } from '@/utils/http' +import { defAxios } from '@/utils/http' export function getUsers(data = {}) { return defAxios({ diff --git a/src/utils/http/index.js b/src/utils/http/index.js index b76558c..2b40af4 100644 --- a/src/utils/http/index.js +++ b/src/utils/http/index.js @@ -13,6 +13,6 @@ function createAxios(option = {}) { export const defAxios = createAxios() -export const mockAxios = createAxios({ +export const testAxios = createAxios({ baseURL: window.__APP__GLOB__CONF__?.VITE_APP_GLOB_BASE_API_TEST || import.meta.env.VITE_APP_GLOB_BASE_API_TEST, })