fix: clear instances when page hidden
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 ||
|
||||
''
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user