diff --git a/app/api/axios-client.ts b/app/api/axios-client.ts index c28c391..8f1ebc4 100644 --- a/app/api/axios-client.ts +++ b/app/api/axios-client.ts @@ -1,6 +1,7 @@ import axios, { AxiosRequestConfig, AxiosResponse, isAxiosError } from 'axios'; import { mockData, type MockApiResponse } from './mock'; import { API_BASE_URL, DOCUMENT_URL } from '../config/api-config'; +import { toastService } from '../components/ui/Toast'; /** * API响应类型 @@ -173,6 +174,16 @@ axiosInstance.interceptors.response.use( } } + // 🔒 403 无权限错误处理 + if (isAxiosError(error) && error.response?.status === 403) { + console.warn('⚠️ [403 Forbidden] 无权限访问:', error.config?.url); + + // 只在客户端显示 toast 提示 + if (typeof window !== 'undefined') { + toastService.warning('无权限访问该资源'); + } + } + return Promise.reject(error); } );