Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
6f9e9292
authored
Jun 15, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: code
parent
bf1592d2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
17 deletions
+53
-17
client/public/imgs/errImg.png
+0
-0
client/src/components/Markdown/Image.tsx
+19
-0
client/src/components/Markdown/index.tsx
+4
-0
client/src/pages/api/openapi/kb/pushData.ts
+5
-0
client/src/pages/api/user/checkPayResult.ts
+20
-12
client/src/pages/model/components/detail/components/ModelEditForm.tsx
+1
-1
client/src/pages/number/components/PayModal.tsx
+1
-1
client/src/service/mongo.ts
+3
-3
No files found.
client/public/imgs/errImg.png
0 → 100644
View file @
6f9e9292
28 KB
client/src/components/Markdown/Image.tsx
0 → 100644
View file @
6f9e9292
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
;
client/src/components/Markdown/index.tsx
View file @
6f9e9292
...
...
@@ -10,6 +10,7 @@ import styles from './index.module.scss';
import
CodeLight
from
'./codeLight'
;
import
Loading
from
'./Loading'
;
import
MermaidCodeBlock
from
'./MermaidCodeBlock'
;
import
MdImage
from
'./Image'
;
const
Markdown
=
({
source
,
...
...
@@ -33,6 +34,9 @@ const Markdown = ({
rehypePlugins=
{
[
rehypeKatex
]
}
components=
{
{
pre
:
'div'
,
img
({
src
=
''
})
{
return
<
MdImage
src=
{
src
}
/>;
},
code
({
node
,
inline
,
className
,
children
,
...
props
})
{
const
match
=
/language-
(\w
+
)
/
.
exec
(
className
||
''
);
...
...
client/src/pages/api/openapi/kb/pushData.ts
View file @
6f9e9292
...
...
@@ -73,6 +73,9 @@ export async function pushDataToKb({
const
set
=
new
Set
();
const
filterData
:
DateItemType
[]
=
[];
const
time
=
Date
.
now
();
console
.
log
(
'push data'
,
data
.
length
);
data
.
forEach
((
item
)
=>
{
const
text
=
item
.
q
+
item
.
a
;
...
...
@@ -153,6 +156,8 @@ export async function pushDataToKb({
insertData
.
length
>
0
&&
startQueue
();
console
.
log
(
'push data finish'
,
Date
.
now
()
-
time
);
return
{
insertLen
:
insertData
.
length
};
...
...
client/src/pages/api/user/checkPayResult.ts
View file @
6f9e9292
...
...
@@ -12,7 +12,7 @@ import { startQueue } from '@/service/utils/tools';
/* 校验支付结果 */
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
try
{
le
t
{
payId
}
=
req
.
query
as
{
payId
:
string
};
cons
t
{
payId
}
=
req
.
query
as
{
payId
:
string
};
const
{
userId
}
=
await
authUser
({
req
,
authToken
:
true
});
...
...
@@ -34,10 +34,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
throw
new
Error
(
'找不到用户'
);
}
// 获取邀请者
let
inviter
:
UserModelSchema
|
null
=
null
;
if
(
user
.
inviterId
)
{
inviter
=
await
User
.
findById
(
user
.
inviterId
);
}
const
inviter
=
await
(
async
()
=>
{
if
(
user
.
inviterId
)
{
return
User
.
findById
(
user
.
inviterId
,
'_id promotion'
);
}
return
null
;
})();
const
payRes
=
await
getPayResult
(
payOrder
.
orderId
);
...
...
@@ -79,22 +81,28 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
unlockTask
(
userId
);
}
}
catch
(
error
)
{
await
Pay
.
findByIdAndUpdate
(
payId
,
{
status
:
'NOTPAY'
});
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
,
{
status
:
'CLOSED'
});
jsonRes
(
res
,
{
return
jsonRes
(
res
,
{
data
:
'订单已过期'
});
}
else
{
throw
new
Error
(
payRes
?.
trade_state_desc
||
'订单无效'
);
}
throw
new
Error
(
payRes
?.
trade_state_desc
||
'订单无效'
);
}
catch
(
err
)
{
// console.log(err);
jsonRes
(
res
,
{
...
...
client/src/pages/model/components/detail/components/ModelEditForm.tsx
View file @
6f9e9292
...
...
@@ -182,7 +182,7 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
<
Box
fontWeight=
{
'bold'
}
>
基本信息
</
Box
>
<
Flex
alignItems=
{
'center'
}
mt=
{
4
}
>
<
Box
flex=
{
'0 0 80px'
}
w=
{
0
}
>
model
Id
App
Id
</
Box
>
<
Box
userSelect=
{
'all'
}
>
{
getValues
(
'_id'
)
}
</
Box
>
</
Flex
>
...
...
client/src/pages/number/components/PayModal.tsx
View file @
6f9e9292
...
...
@@ -58,7 +58,7 @@ const PayModal = ({ onClose }: { onClose: () => void }) => {
},
{
enabled
:
!!
payId
,
refetchInterval
:
2
000
,
refetchInterval
:
3
000
,
onSuccess
(
res
)
{
if
(
!
res
)
return
;
toast
({
...
...
client/src/service/mongo.ts
View file @
6f9e9292
...
...
@@ -39,9 +39,9 @@ export async function connectToDatabase(): Promise<void> {
global
.
mongodb
=
await
mongoose
.
connect
(
process
.
env
.
MONGODB_URI
as
string
,
{
bufferCommands
:
true
,
dbName
:
process
.
env
.
MONGODB_NAME
,
max
PoolSize
:
5
,
m
inPoolSize
:
1
,
m
axConnecting
:
5
max
Connecting
:
30
,
m
axPoolSize
:
30
,
m
inPoolSize
:
10
});
console
.
log
(
'mongo connected'
);
}
catch
(
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment