use a variable to represent the max number of images

This commit is contained in:
l.tingting 2024-06-19 16:26:13 +08:00
parent b6735bffe4
commit 251d6920d5

View File

@ -99,6 +99,8 @@ import { getClientConfig } from "../config/client";
import { useAllModels } from "../utils/hooks";
import { MultimodalContent } from "../client/api";
const maxImagesNumber = 3;
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
loading: () => <LoadingIcon />,
});
@ -1150,8 +1152,8 @@ function _Chat() {
);
const imagesLength = images.length;
if (imagesLength > 3) {
images.splice(3, imagesLength - 3);
if (imagesLength > maxImagesNumber) {
images.splice(maxImagesNumber, imagesLength - maxImagesNumber);
}
setAttachImages(images);
}
@ -1182,7 +1184,7 @@ function _Chat() {
.then((dataUrl) => {
imagesData.push(dataUrl);
if (
imagesData.length === 3 ||
imagesData.length === maxImagesNumber ||
imagesData.length === files.length
) {
setUploading(false);
@ -1200,8 +1202,8 @@ function _Chat() {
);
const imagesLength = images.length;
if (imagesLength > 3) {
images.splice(3, imagesLength - 3);
if (imagesLength > maxImagesNumber) {
images.splice(maxImagesNumber, imagesLength - maxImagesNumber);
}
setAttachImages(images);
}