mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
perf: 去除console,
This commit is contained in:
parent
52a752dab5
commit
bf81d23de4
|
|
@ -34,7 +34,7 @@ function responseSuccess(response: AxiosResponse<ResponseDataType>) {
|
|||
*/
|
||||
function checkRes(data: ResponseDataType) {
|
||||
if (data === undefined) {
|
||||
console.log(data, 'data is empty');
|
||||
console.error(data, 'data is empty');
|
||||
return Promise.reject('服务器异常');
|
||||
} else if (data.code < 200 || data.code >= 400) {
|
||||
return Promise.reject(data.message);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const Auth = ({ children }: { children: JSX.Element }) => {
|
|||
}
|
||||
},
|
||||
onError(error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
router.push('/login');
|
||||
toast();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@
|
|||
font-size: 28px;
|
||||
}
|
||||
.markdown h2 {
|
||||
border-bottom: 1px solid #cccccc;
|
||||
color: #000000;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import React, { memo } from 'react';
|
||||
import React, { memo, useMemo } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import styles from './index.module.scss';
|
||||
|
|
@ -9,9 +9,9 @@ import { useCopyData } from '@/utils/tools';
|
|||
import Icon from '@/components/Icon';
|
||||
|
||||
const Markdown = ({ source, isChatting }: { source: string; isChatting: boolean }) => {
|
||||
// const formatSource = useMemo(() => source.replace(/\n/g, '\n'), [source]);
|
||||
const formatSource = useMemo(() => source.replace(/\n/g, ' \n'), [source]);
|
||||
const { copyData } = useCopyData();
|
||||
// console.log(source);
|
||||
|
||||
return (
|
||||
<ReactMarkdown
|
||||
className={`${styles.markdown} ${
|
||||
|
|
@ -56,7 +56,7 @@ const Markdown = ({ source, isChatting }: { source: string; isChatting: boolean
|
|||
}
|
||||
}}
|
||||
>
|
||||
{source}
|
||||
{formatSource}
|
||||
</ReactMarkdown>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||
|
||||
res.end();
|
||||
} catch (err: any) {
|
||||
console.log(err?.response?.data || err);
|
||||
console.error(err?.response?.data || err);
|
||||
// 删除最一条数据库记录, 也就是预发送的那一条
|
||||
await ChatWindow.findByIdAndUpdate(windowId, {
|
||||
$pop: { content: 1 },
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
jsonRes(res, {
|
||||
code: 500,
|
||||
error: err
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||
if (req.method !== 'GET') return;
|
||||
|
||||
res.writeHead(200, {
|
||||
Connection: 'keep-alive',
|
||||
'Content-Encoding': 'none',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Content-Type': 'text/event-stream'
|
||||
});
|
||||
|
||||
let val = 0;
|
||||
|
||||
const timer = setInterval(() => {
|
||||
console.log('发送消息', val);
|
||||
res.write(`data: ${val++}\n\n`);
|
||||
if (val > 30) {
|
||||
clearInterval(timer);
|
||||
res.write(`data: [DONE]\n\n`);
|
||||
res.end();
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ const ModelEditForm = ({ model }: { model?: ModelType }) => {
|
|||
status: 'success'
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
toast({
|
||||
title: err as string,
|
||||
status: 'success'
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ const Training = ({ model }: { model: ModelType }) => {
|
|||
const res = await getModelTrainings(id);
|
||||
setRecords(res);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,10 +41,8 @@ const ModelDetail = () => {
|
|||
const res = await getModelById(modelId as string);
|
||||
res.security.expiredTime /= 60 * 60 * 1000;
|
||||
setModel(res);
|
||||
|
||||
console.log(res);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
setLoading(false);
|
||||
}, [modelId, setLoading]);
|
||||
|
|
@ -65,7 +63,7 @@ const ModelDetail = () => {
|
|||
});
|
||||
router.replace('/model/list');
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
setLoading(false);
|
||||
}, [setLoading, model, router, toast]);
|
||||
|
|
@ -79,7 +77,7 @@ const ModelDetail = () => {
|
|||
|
||||
router.push(`/chat?chatId=${chatId}`);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
setLoading(false);
|
||||
}, [setLoading, model, router]);
|
||||
|
|
@ -107,7 +105,7 @@ const ModelDetail = () => {
|
|||
title: typeof err === 'string' ? err : '文件格式错误',
|
||||
status: 'error'
|
||||
});
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
setLoading(false);
|
||||
},
|
||||
|
|
@ -123,7 +121,7 @@ const ModelDetail = () => {
|
|||
await putModelTrainingStatus(model._id);
|
||||
loadModel();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
}
|
||||
setLoading(false);
|
||||
}, [setLoading, loadModel, model]);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ const ModelList = () => {
|
|||
shallow: true
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
setIsLoading(false);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ export const jsonRes = (
|
|||
typeof error === 'string'
|
||||
? error
|
||||
: openaiError[error?.response?.data?.message] || error?.message || '请求错误';
|
||||
|
||||
console.log(msg);
|
||||
console.error(error);
|
||||
console.error(msg);
|
||||
}
|
||||
|
||||
res.json({
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export const sendCode = (email: string, code: string, type: `${EmailTypeEnum}`)
|
|||
};
|
||||
mailTransport.sendMail(options, function (err, msg) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
reject('邮箱异常');
|
||||
} else {
|
||||
resolve('');
|
||||
|
|
@ -53,7 +53,7 @@ export const sendTrainSucceed = (email: string, modelName: string) => {
|
|||
};
|
||||
mailTransport.sendMail(options, function (err, msg) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
reject('邮箱异常');
|
||||
} else {
|
||||
resolve('');
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export const useCopyData = () => {
|
|||
duration: 1000
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
toast({
|
||||
title: '复制失败',
|
||||
status: 'error'
|
||||
|
|
|
|||
Loading…
Reference in New Issue