fix: loading屏蔽高频请求
This commit is contained in:
@@ -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}`;
|
||||
|
Reference in New Issue
Block a user