fix: clear instances when page hidden

This commit is contained in:
jialin
2025-01-19 20:51:06 +08:00
parent 4643dbce17
commit c49bfb97dd
12 changed files with 83 additions and 82 deletions
@@ -28,7 +28,7 @@ import React, {
useState
} from 'react';
import { CREAT_IMAGE_API } from '../apis';
import { promptList } from '../config';
import { extractErrorMessage, promptList } from '../config';
import {
ImageAdvancedParamsConfig,
ImageCustomSizeConfig,
@@ -336,8 +336,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
if (result.error) {
setTokenResult({
error: true,
errorMessage:
result?.data?.error?.message || result?.data?.error || ''
errorMessage: extractErrorMessage(result)
});
setImageList([]);
return;
@@ -30,6 +30,7 @@ import React, {
useState
} from 'react';
import { EDIT_IMAGE_API } from '../apis';
import { extractErrorMessage } from '../config';
import {
ImageAdvancedParamsConfig,
ImageCustomSizeConfig,
@@ -369,11 +370,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
if (result.error) {
setTokenResult({
error: true,
errorMessage:
result?.data?.data?.detail ||
result?.data?.error?.message ||
result?.data?.error ||
''
errorMessage: extractErrorMessage(result)
});
setImageList([]);
return;
+10
View File
@@ -156,3 +156,13 @@ export const promptList = [
'A full shot of two people jogging at sunset, featuring a vibrant, warm color palette shifting from twilight blues to peachy-orange tones, with visible sun rays and lens flares, conveying a sense of leisure and athleticism.',
'A close-up portrait of a golden retriever wearing black-framed glasses, exhibiting a rich golden-brown coat with a fluffy texture, and a neutral, light gray background.'
];
export const extractErrorMessage = (result: any) => {
return (
result?.data?.data?.detail ||
result?.data?.data?.message ||
result?.data?.error?.message ||
result?.data?.error ||
''
);
};
+2 -2
View File
@@ -451,7 +451,7 @@ export const ImageCustomSizeConfig: ParamsSchema[] = [
min: 256,
max: 3200,
step: 64,
inputnumber: true
inputnumber: false
},
rules: [
{
@@ -471,7 +471,7 @@ export const ImageCustomSizeConfig: ParamsSchema[] = [
min: 256,
max: 3200,
step: 64,
inputnumber: true
inputnumber: false
},
rules: [
{