mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-28 09:03:53 +00:00
perf: code
This commit is contained in:
BIN
client/public/imgs/errImg.png
Normal file
BIN
client/public/imgs/errImg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
19
client/src/components/Markdown/Image.tsx
Normal file
19
client/src/components/Markdown/Image.tsx
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { Image, Skeleton } from '@chakra-ui/react';
|
||||||
|
|
||||||
|
const MdImage = ({ src }: { src: string }) => {
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
return (
|
||||||
|
<Skeleton minH="60px" isLoaded={!isLoading} fadeDuration={2}>
|
||||||
|
<Image
|
||||||
|
src={src}
|
||||||
|
alt={''}
|
||||||
|
fallbackSrc={'/imgs/errImg.png'}
|
||||||
|
onLoad={() => setIsLoading(false)}
|
||||||
|
onError={() => setIsLoading(false)}
|
||||||
|
/>
|
||||||
|
</Skeleton>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MdImage;
|
@@ -10,6 +10,7 @@ import styles from './index.module.scss';
|
|||||||
import CodeLight from './codeLight';
|
import CodeLight from './codeLight';
|
||||||
import Loading from './Loading';
|
import Loading from './Loading';
|
||||||
import MermaidCodeBlock from './MermaidCodeBlock';
|
import MermaidCodeBlock from './MermaidCodeBlock';
|
||||||
|
import MdImage from './Image';
|
||||||
|
|
||||||
const Markdown = ({
|
const Markdown = ({
|
||||||
source,
|
source,
|
||||||
@@ -33,6 +34,9 @@ const Markdown = ({
|
|||||||
rehypePlugins={[rehypeKatex]}
|
rehypePlugins={[rehypeKatex]}
|
||||||
components={{
|
components={{
|
||||||
pre: 'div',
|
pre: 'div',
|
||||||
|
img({ src = '' }) {
|
||||||
|
return <MdImage src={src} />;
|
||||||
|
},
|
||||||
code({ node, inline, className, children, ...props }) {
|
code({ node, inline, className, children, ...props }) {
|
||||||
const match = /language-(\w+)/.exec(className || '');
|
const match = /language-(\w+)/.exec(className || '');
|
||||||
|
|
||||||
|
@@ -73,6 +73,9 @@ export async function pushDataToKb({
|
|||||||
const set = new Set();
|
const set = new Set();
|
||||||
const filterData: DateItemType[] = [];
|
const filterData: DateItemType[] = [];
|
||||||
|
|
||||||
|
const time = Date.now();
|
||||||
|
console.log('push data', data.length);
|
||||||
|
|
||||||
data.forEach((item) => {
|
data.forEach((item) => {
|
||||||
const text = item.q + item.a;
|
const text = item.q + item.a;
|
||||||
|
|
||||||
@@ -153,6 +156,8 @@ export async function pushDataToKb({
|
|||||||
|
|
||||||
insertData.length > 0 && startQueue();
|
insertData.length > 0 && startQueue();
|
||||||
|
|
||||||
|
console.log('push data finish', Date.now() - time);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
insertLen: insertData.length
|
insertLen: insertData.length
|
||||||
};
|
};
|
||||||
|
@@ -12,7 +12,7 @@ import { startQueue } from '@/service/utils/tools';
|
|||||||
/* 校验支付结果 */
|
/* 校验支付结果 */
|
||||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
try {
|
try {
|
||||||
let { payId } = req.query as { payId: string };
|
const { payId } = req.query as { payId: string };
|
||||||
|
|
||||||
const { userId } = await authUser({ req, authToken: true });
|
const { userId } = await authUser({ req, authToken: true });
|
||||||
|
|
||||||
@@ -34,10 +34,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
throw new Error('找不到用户');
|
throw new Error('找不到用户');
|
||||||
}
|
}
|
||||||
// 获取邀请者
|
// 获取邀请者
|
||||||
let inviter: UserModelSchema | null = null;
|
const inviter = await (async () => {
|
||||||
if (user.inviterId) {
|
if (user.inviterId) {
|
||||||
inviter = await User.findById(user.inviterId);
|
return User.findById(user.inviterId, '_id promotion');
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
})();
|
||||||
|
|
||||||
const payRes = await getPayResult(payOrder.orderId);
|
const payRes = await getPayResult(payOrder.orderId);
|
||||||
|
|
||||||
@@ -79,22 +81,28 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
unlockTask(userId);
|
unlockTask(userId);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await Pay.findByIdAndUpdate(payId, {
|
|
||||||
status: 'NOTPAY'
|
|
||||||
});
|
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
try {
|
||||||
|
await Pay.findByIdAndUpdate(payId, {
|
||||||
|
status: 'NOTPAY'
|
||||||
|
});
|
||||||
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
} else if (payRes.trade_state === 'CLOSED' || diffInHours > 24) {
|
return jsonRes(res, {
|
||||||
|
code: 500,
|
||||||
|
data: '更新订单失败,请重试'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (payRes.trade_state === 'CLOSED' || diffInHours > 24) {
|
||||||
// 订单已关闭
|
// 订单已关闭
|
||||||
await Pay.findByIdAndUpdate(payId, {
|
await Pay.findByIdAndUpdate(payId, {
|
||||||
status: 'CLOSED'
|
status: 'CLOSED'
|
||||||
});
|
});
|
||||||
jsonRes(res, {
|
return jsonRes(res, {
|
||||||
data: '订单已过期'
|
data: '订单已过期'
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
throw new Error(payRes?.trade_state_desc || '订单无效');
|
|
||||||
}
|
}
|
||||||
|
throw new Error(payRes?.trade_state_desc || '订单无效');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// console.log(err);
|
// console.log(err);
|
||||||
jsonRes(res, {
|
jsonRes(res, {
|
||||||
|
@@ -182,7 +182,7 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
|
|||||||
<Box fontWeight={'bold'}>基本信息</Box>
|
<Box fontWeight={'bold'}>基本信息</Box>
|
||||||
<Flex alignItems={'center'} mt={4}>
|
<Flex alignItems={'center'} mt={4}>
|
||||||
<Box flex={'0 0 80px'} w={0}>
|
<Box flex={'0 0 80px'} w={0}>
|
||||||
modelId
|
AppId
|
||||||
</Box>
|
</Box>
|
||||||
<Box userSelect={'all'}>{getValues('_id')}</Box>
|
<Box userSelect={'all'}>{getValues('_id')}</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@@ -58,7 +58,7 @@ const PayModal = ({ onClose }: { onClose: () => void }) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: !!payId,
|
enabled: !!payId,
|
||||||
refetchInterval: 2000,
|
refetchInterval: 3000,
|
||||||
onSuccess(res) {
|
onSuccess(res) {
|
||||||
if (!res) return;
|
if (!res) return;
|
||||||
toast({
|
toast({
|
||||||
|
@@ -39,9 +39,9 @@ export async function connectToDatabase(): Promise<void> {
|
|||||||
global.mongodb = await mongoose.connect(process.env.MONGODB_URI as string, {
|
global.mongodb = await mongoose.connect(process.env.MONGODB_URI as string, {
|
||||||
bufferCommands: true,
|
bufferCommands: true,
|
||||||
dbName: process.env.MONGODB_NAME,
|
dbName: process.env.MONGODB_NAME,
|
||||||
maxPoolSize: 5,
|
maxConnecting: 30,
|
||||||
minPoolSize: 1,
|
maxPoolSize: 30,
|
||||||
maxConnecting: 5
|
minPoolSize: 10
|
||||||
});
|
});
|
||||||
console.log('mongo connected');
|
console.log('mongo connected');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Reference in New Issue
Block a user