mod:调整环境配置文件

This commit is contained in:
zhangchuanlong 2022-02-09 17:46:25 +08:00
parent 823d718d7b
commit dd0c8a86c4
8 changed files with 18 additions and 32 deletions

View File

@ -1,18 +1,14 @@
NODE_ENV = 'development' # 资源公共路径,需要以 /开头和结尾
ENV = 'development'
VITE_PUBLIC_PATH = '/' VITE_PUBLIC_PATH = '/'
# 是否使用MOCK # 是否启用MOCK
VITE_APP_USE_MOCK = true VITE_APP_USE_MOCK = true
# proxy # proxy
VITE_PROXY = [["/api","http://localhost:8080"],["/api-test","localhost:8080"]] VITE_PROXY = [["/api","http://localhost:8080"],["/api-test","localhost:8080"]]
# base api # base api
# VITE_APP_GLOB_BASE_API = '/api' VITE_APP_GLOB_BASE_API = '/api'
VITE_APP_GLOB_BASE_API = '/api-mock'
# test base api # test base api
VITE_APP_GLOB_BASE_API_TEST = '/api-test' VITE_APP_GLOB_BASE_API_TEST = '/api-test'

View File

@ -1,14 +1,11 @@
NODE_ENV = 'production' # 资源公共路径,需要以 /开头和结尾
ENV = 'production'
VITE_PUBLIC_PATH = '/' VITE_PUBLIC_PATH = '/'
# 是否使用MOCK # 是否启用MOCK
VITE_APP_USE_MOCK = true VITE_APP_USE_MOCK = true
# base api # base api
VITE_APP_GLOB_BASE_API = '/api-mock' VITE_APP_GLOB_BASE_API = '/api'
# test base api # test base api
VITE_APP_GLOB_BASE_API_TEST = '/api-test' VITE_APP_GLOB_BASE_API_TEST = '/api-test'

View File

@ -1,14 +1,11 @@
NODE_ENV = 'production' # 资源公共路径,需要以 /开头和结尾
ENV = 'staging'
VITE_PUBLIC_PATH = '/' VITE_PUBLIC_PATH = '/'
# 是否使用MOCK # 是否启用MOCK
VITE_APP_USE_MOCK = false VITE_APP_USE_MOCK = false
# base api # base api
VITE_APP_GLOB_BASE_API = '/api-mock' VITE_APP_GLOB_BASE_API = 'http://localhost:8080/api'
# test base api # test base api
VITE_APP_GLOB_BASE_API_TEST = '/api-test' VITE_APP_GLOB_BASE_API_TEST = 'http://localhost:8080/api-test'

View File

@ -1,14 +1,10 @@
NODE_ENV = 'production'
ENV = 'test'
VITE_PUBLIC_PATH = '/' VITE_PUBLIC_PATH = '/'
# 是否使用MOCK # 是否启用MOCK
VITE_APP_USE_MOCK = false VITE_APP_USE_MOCK = true
# base api # base api
VITE_APP_GLOB_BASE_API = '/api-mock' VITE_APP_GLOB_BASE_API = '/api'
# test base api # test base api
VITE_APP_GLOB_BASE_API_TEST = '/api-test' VITE_APP_GLOB_BASE_API_TEST = '/api-test'

View File

@ -7,7 +7,7 @@ const token = {
export default [ export default [
{ {
url: '/api-mock/auth/login', url: '/api/auth/login',
method: 'post', method: 'post',
response: ({ body }) => { response: ({ body }) => {
if (['admin', 'editor'].includes(body?.name)) { if (['admin', 'editor'].includes(body?.name)) {
@ -26,7 +26,7 @@ export default [
}, },
}, },
{ {
url: '/api-mock/auth/refreshToken', url: '/api/auth/refreshToken',
method: 'post', method: 'post',
response: ({ headers }) => { response: ({ headers }) => {
return { return {

View File

@ -24,7 +24,7 @@ const users = {
} }
export default [ export default [
{ {
url: '/api-mock/user', url: '/api/user',
method: 'get', method: 'get',
response: ({ headers }) => { response: ({ headers }) => {
const token = resolveToken(headers?.authorization) const token = resolveToken(headers?.authorization)

View File

@ -1,4 +1,4 @@
import { defAxios, mockAxios } from '@/utils/http' import { defAxios } from '@/utils/http'
export function getUsers(data = {}) { export function getUsers(data = {}) {
return defAxios({ return defAxios({

View File

@ -13,6 +13,6 @@ function createAxios(option = {}) {
export const defAxios = createAxios() 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, baseURL: window.__APP__GLOB__CONF__?.VITE_APP_GLOB_BASE_API_TEST || import.meta.env.VITE_APP_GLOB_BASE_API_TEST,
}) })