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