fix: loading屏蔽高频请求

This commit is contained in:
tbphp
2025-07-12 21:50:21 +08:00
parent 4acf7193a4
commit 37b3bf715b
2 changed files with 10 additions and 4 deletions

View File

@@ -2,6 +2,9 @@ import { useAuthService } from "@/services/auth";
import axios from "axios";
import { appState } from "./app-state";
// 定义不需要显示 loading 的 API 地址列表
const noLoadingUrls = ["/tasks/status"];
declare module "axios" {
interface AxiosRequestConfig {
hideMessage?: boolean;
@@ -16,7 +19,10 @@ const http = axios.create({
// 请求拦截器
http.interceptors.request.use(config => {
appState.loading = true;
// 检查当前请求的 URL 是否在屏蔽列表中
if (config.url && !noLoadingUrls.includes(config.url)) {
appState.loading = true;
}
const authKey = localStorage.getItem("authKey");
if (authKey) {
config.headers.Authorization = `Bearer ${authKey}`;