forked from 77media/video-flow
修复 积分不足弹窗问题
This commit is contained in:
parent
6d9ed1501e
commit
608e7bf814
@ -14,24 +14,20 @@ const handleRequestError = (error: any, defaultMessage: string = '请求失败')
|
||||
|
||||
// 处理 402 状态码的特殊情况
|
||||
if (status === 402 && data?.detail) {
|
||||
import('./errorHandle').then(({ errorHandle }) => {
|
||||
errorHandle(status, errorMessage);
|
||||
// 调用积分不足通知,传入详细信息
|
||||
// 只显示通知,不调用 errorHandle
|
||||
import('../utils/notifications').then(({ showInsufficientPointsNotification }) => {
|
||||
showInsufficientPointsNotification(data.detail);
|
||||
});
|
||||
});
|
||||
return;
|
||||
return; // 直接返回,不再抛出错误
|
||||
}
|
||||
|
||||
errorHandle(status, errorMessage);
|
||||
} else if (error.request) {
|
||||
// 请求已发出但没有收到响应
|
||||
errorHandle(0);
|
||||
} else {
|
||||
// 请求配置出错
|
||||
errorHandle(0, error.message || defaultMessage);
|
||||
}
|
||||
return Promise.reject(error); // 将 reject 移到这里,避免 402 时重复处理
|
||||
};
|
||||
// 创建 axios 实例
|
||||
const request: AxiosInstance = axios.create({
|
||||
|
||||
@ -63,7 +63,11 @@ export const showInsufficientPointsNotification = (detail?: {
|
||||
required_tokens?: number;
|
||||
message?: string;
|
||||
}) => {
|
||||
// 生成唯一的 key
|
||||
const key = `insufficient-points-${Date.now()}`;
|
||||
|
||||
notification.warning({
|
||||
key, // 添加唯一的 key
|
||||
message: null,
|
||||
description: (
|
||||
<div data-alt="insufficient-points-notification" style={{ minWidth: '280px' }}>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user