mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
fix: img compress (#546)
This commit is contained in:
@@ -13,10 +13,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
|
||||
await authChat({ req, authToken: true, chatId });
|
||||
|
||||
await MongoChat.findOneAndUpdate({ chatId }, {
|
||||
...(customTitle && { customTitle }),
|
||||
...(top && { top })
|
||||
});
|
||||
await MongoChat.findOneAndUpdate(
|
||||
{ chatId },
|
||||
{
|
||||
...(customTitle !== undefined && { customTitle }),
|
||||
...(top !== undefined && { top })
|
||||
}
|
||||
);
|
||||
jsonRes(res);
|
||||
} catch (err) {
|
||||
jsonRes(res, {
|
||||
|
@@ -328,7 +328,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
|
||||
}}
|
||||
onSetCustomTitle={async (e) => {
|
||||
try {
|
||||
await putChatHistory({
|
||||
putChatHistory({
|
||||
chatId: e.chatId,
|
||||
customTitle: e.title
|
||||
});
|
||||
|
@@ -84,8 +84,8 @@ const ImportData = ({
|
||||
title={<Box {...TitleStyle}>{t('dataset.data.File import')}</Box>}
|
||||
isOpen
|
||||
isCentered
|
||||
maxW={['90vw', '85vw']}
|
||||
w={['90vw', '85vw']}
|
||||
maxW={['90vw', 'min(1440px,85vw)']}
|
||||
w={['90vw', 'min(1440px,85vw)']}
|
||||
h={'90vh'}
|
||||
>
|
||||
<ModalCloseButton onClick={onClose} />
|
||||
|
@@ -92,6 +92,7 @@ export const compressBase64ImgAndUpload = ({
|
||||
reject(error);
|
||||
}
|
||||
};
|
||||
img.onerror = reject;
|
||||
});
|
||||
};
|
||||
export const compressImgFileAndUpload = async ({
|
||||
|
@@ -187,6 +187,7 @@ export const formatMarkdown = async (rawText: string = '') => {
|
||||
maxH: 4329,
|
||||
maxSize: 1024 * 1024 * 5
|
||||
});
|
||||
|
||||
rawText = rawText.replace(base64, str);
|
||||
} catch (error) {
|
||||
rawText = rawText.replace(base64, '');
|
||||
@@ -194,6 +195,7 @@ export const formatMarkdown = async (rawText: string = '') => {
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// Remove white space on both sides of the picture
|
||||
const trimReg = /\s*(!\[.*\]\(.*\))\s*/g;
|
||||
if (trimReg.test(rawText)) {
|
||||
|
Reference in New Issue
Block a user