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