chore: 修改配置
This commit is contained in:
parent
2e7797be68
commit
7c1dee1bf6
|
@ -2,10 +2,10 @@
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
VITE_API_BASE_PATH=base
|
VITE_API_BASE_PATH=
|
||||||
|
|
||||||
# 打包路径
|
# 打包路径
|
||||||
VITE_BASE_PATH=/
|
VITE_BASE_PATH=/
|
||||||
|
|
||||||
# 标题
|
# 标题
|
||||||
VITE_APP_TITLE=ElementAdmin
|
VITE_APP_TITLE=ElementAdmin
|
2
.env.dev
2
.env.dev
|
@ -2,7 +2,7 @@
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
VITE_API_BASE_PATH=dev
|
VITE_API_BASE_PATH=
|
||||||
|
|
||||||
# 打包路径
|
# 打包路径
|
||||||
VITE_BASE_PATH=/dist-dev/
|
VITE_BASE_PATH=/dist-dev/
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
VITE_API_BASE_PATH=pro
|
VITE_API_BASE_PATH=
|
||||||
|
|
||||||
# 打包路径
|
# 打包路径
|
||||||
VITE_BASE_PATH=/vue-element-plus-admin/
|
VITE_BASE_PATH=/vue-element-plus-admin/
|
||||||
|
|
2
.env.pro
2
.env.pro
|
@ -2,7 +2,7 @@
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
VITE_API_BASE_PATH=pro
|
VITE_API_BASE_PATH=
|
||||||
|
|
||||||
# 打包路径
|
# 打包路径
|
||||||
VITE_BASE_PATH=/
|
VITE_BASE_PATH=/
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
VITE_API_BASE_PATH=test
|
VITE_API_BASE_PATH=
|
||||||
|
|
||||||
# 打包路径
|
# 打包路径
|
||||||
VITE_BASE_PATH=/dist-test/
|
VITE_BASE_PATH=/dist-test/
|
||||||
|
|
|
@ -8,23 +8,6 @@ import { ElMessage } from 'element-plus'
|
||||||
import qs from 'qs'
|
import qs from 'qs'
|
||||||
|
|
||||||
const config: AxiosConfig = {
|
const config: AxiosConfig = {
|
||||||
/**
|
|
||||||
* api请求基础路径
|
|
||||||
*/
|
|
||||||
baseUrl: {
|
|
||||||
// 开发环境接口前缀
|
|
||||||
base: '',
|
|
||||||
|
|
||||||
// 打包开发环境接口前缀
|
|
||||||
dev: '',
|
|
||||||
|
|
||||||
// 打包生产环境接口前缀
|
|
||||||
pro: '',
|
|
||||||
|
|
||||||
// 打包测试环境接口前缀
|
|
||||||
test: ''
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接口成功返回状态码
|
* 接口成功返回状态码
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,8 +4,8 @@ import config, { defaultRequestInterceptors, defaultResponseInterceptors } from
|
||||||
import { AxiosInstance, InternalAxiosRequestConfig, RequestConfig, AxiosResponse } from './types'
|
import { AxiosInstance, InternalAxiosRequestConfig, RequestConfig, AxiosResponse } from './types'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
|
|
||||||
const { interceptors, baseUrl } = config
|
const { interceptors } = config
|
||||||
export const PATH_URL = baseUrl[import.meta.env.VITE_API_BASE_PATH]
|
export const PATH_URL = import.meta.env.VITE_API_BASE_PATH
|
||||||
|
|
||||||
const { requestInterceptors, responseInterceptors } = interceptors
|
const { requestInterceptors, responseInterceptors } = interceptors
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,6 @@ interface RequestInterceptors<T> {
|
||||||
responseInterceptorsCatch?: (err: any) => any
|
responseInterceptorsCatch?: (err: any) => any
|
||||||
}
|
}
|
||||||
interface AxiosConfig<T = AxiosResponse> {
|
interface AxiosConfig<T = AxiosResponse> {
|
||||||
baseUrl: {
|
|
||||||
base: string
|
|
||||||
dev: string
|
|
||||||
pro: string
|
|
||||||
test: string
|
|
||||||
}
|
|
||||||
code: number
|
code: number
|
||||||
defaultHeaders: AxiosHeaders
|
defaultHeaders: AxiosHeaders
|
||||||
timeout: number
|
timeout: number
|
||||||
|
|
Loading…
Reference in New Issue