前端启动成功
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
|
||||
import axios, { AxiosResponse, AxiosError, InternalAxiosRequestConfig } from "axios";
|
||||
import { ElLoading, ElMessage } from "element-plus";
|
||||
import type { ResultDomain } from "@/types";
|
||||
|
||||
/**
|
||||
* 扩展AxiosRequestConfig以支持自定义配置
|
||||
*/
|
||||
interface CustomAxiosRequestConfig extends AxiosRequestConfig {
|
||||
interface CustomAxiosRequestConfig extends Partial<InternalAxiosRequestConfig> {
|
||||
/** 是否显示加载动画 */
|
||||
showLoading?: boolean;
|
||||
/** 是否显示错误提示 */
|
||||
@@ -43,7 +43,7 @@ export const TokenManager = {
|
||||
* 创建axios实例
|
||||
*/
|
||||
const request = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL || "/api",
|
||||
baseURL: process.env.VITE_API_BASE_URL || "/api",
|
||||
timeout: 30000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
@@ -56,9 +56,11 @@ let loadingInstance: ReturnType<typeof ElLoading.service> | null = null;
|
||||
* 请求拦截器
|
||||
*/
|
||||
request.interceptors.request.use(
|
||||
(config: CustomAxiosRequestConfig) => {
|
||||
(config: InternalAxiosRequestConfig) => {
|
||||
const customConfig = config as CustomAxiosRequestConfig;
|
||||
|
||||
// 显示加载动画
|
||||
if (config.showLoading !== false) {
|
||||
if (customConfig.showLoading !== false) {
|
||||
loadingInstance = ElLoading.service({
|
||||
lock: true,
|
||||
text: "加载中...",
|
||||
|
||||
Reference in New Issue
Block a user