fix: loading屏蔽高频请求
This commit is contained in:
@@ -205,7 +205,7 @@ function resetPage() {
|
|||||||
</n-grid-item>
|
</n-grid-item>
|
||||||
<n-grid-item span="1">
|
<n-grid-item span="1">
|
||||||
<n-statistic
|
<n-statistic
|
||||||
:label="`近1小时:${formatNumber(stats?.hourly_stats?.total_requests ?? 0)}`"
|
:label="`1小时请求:${formatNumber(stats?.hourly_stats?.total_requests ?? 0)}`"
|
||||||
>
|
>
|
||||||
<n-tooltip trigger="hover">
|
<n-tooltip trigger="hover">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
@@ -228,7 +228,7 @@ function resetPage() {
|
|||||||
</n-grid-item>
|
</n-grid-item>
|
||||||
<n-grid-item span="1">
|
<n-grid-item span="1">
|
||||||
<n-statistic
|
<n-statistic
|
||||||
:label="`近24小时:${formatNumber(stats?.daily_stats?.total_requests ?? 0)}`"
|
:label="`24小时请求:${formatNumber(stats?.daily_stats?.total_requests ?? 0)}`"
|
||||||
>
|
>
|
||||||
<n-tooltip trigger="hover">
|
<n-tooltip trigger="hover">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
@@ -251,7 +251,7 @@ function resetPage() {
|
|||||||
</n-grid-item>
|
</n-grid-item>
|
||||||
<n-grid-item span="1">
|
<n-grid-item span="1">
|
||||||
<n-statistic
|
<n-statistic
|
||||||
:label="`近7天:${formatNumber(stats?.weekly_stats?.total_requests ?? 0)}`"
|
:label="`近7天请求:${formatNumber(stats?.weekly_stats?.total_requests ?? 0)}`"
|
||||||
>
|
>
|
||||||
<n-tooltip trigger="hover">
|
<n-tooltip trigger="hover">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
|
@@ -2,6 +2,9 @@ import { useAuthService } from "@/services/auth";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { appState } from "./app-state";
|
import { appState } from "./app-state";
|
||||||
|
|
||||||
|
// 定义不需要显示 loading 的 API 地址列表
|
||||||
|
const noLoadingUrls = ["/tasks/status"];
|
||||||
|
|
||||||
declare module "axios" {
|
declare module "axios" {
|
||||||
interface AxiosRequestConfig {
|
interface AxiosRequestConfig {
|
||||||
hideMessage?: boolean;
|
hideMessage?: boolean;
|
||||||
@@ -16,7 +19,10 @@ const http = axios.create({
|
|||||||
|
|
||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
http.interceptors.request.use(config => {
|
http.interceptors.request.use(config => {
|
||||||
|
// 检查当前请求的 URL 是否在屏蔽列表中
|
||||||
|
if (config.url && !noLoadingUrls.includes(config.url)) {
|
||||||
appState.loading = true;
|
appState.loading = true;
|
||||||
|
}
|
||||||
const authKey = localStorage.getItem("authKey");
|
const authKey = localStorage.getItem("authKey");
|
||||||
if (authKey) {
|
if (authKey) {
|
||||||
config.headers.Authorization = `Bearer ${authKey}`;
|
config.headers.Authorization = `Bearer ${authKey}`;
|
||||||
|
Reference in New Issue
Block a user