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
77dc961a
authored
Apr 06, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 账号页异步加载组件
parent
9a45fb64
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
187 additions
and
137 deletions
+187
-137
src/pages/api/chat/vectorGpt.ts
+3
-3
src/pages/number/components/BillTable.tsx
+61
-0
src/pages/number/components/PayRecordTable.tsx
+112
-0
src/pages/number/setting.tsx
+11
-134
No files found.
src/pages/api/chat/vectorGpt.ts
View file @
77dc961a
...
@@ -71,7 +71,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -71,7 +71,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
`idx:
${
VecModelDataPrefix
}
:hash`
,
`idx:
${
VecModelDataPrefix
}
:hash`
,
`@modelId:{
${
String
(
`@modelId:{
${
String
(
chat
.
modelId
.
_id
chat
.
modelId
.
_id
)}
} @vector:[VECTOR_RANGE 0.2
2
$blob]=>{$YIELD_DISTANCE_AS: score}`
,
)}
} @vector:[VECTOR_RANGE 0.2
4
$blob]=>{$YIELD_DISTANCE_AS: score}`
,
// `@modelId:{${String(chat.modelId._id)}}=>[KNN 10 @vector $blob AS score]`,
// `@modelId:{${String(chat.modelId._id)}}=>[KNN 10 @vector $blob AS score]`,
'RETURN'
,
'RETURN'
,
'1'
,
'1'
,
...
@@ -105,8 +105,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -105,8 +105,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
throw
new
Error
(
'对不起,我没有找到你的问题'
);
throw
new
Error
(
'对不起,我没有找到你的问题'
);
}
}
// textArr 筛选,最多 3
2
00 tokens
// textArr 筛选,最多 3
0
00 tokens
const
systemPrompt
=
systemPromptFilter
(
formatRedisPrompt
,
3
2
00
);
const
systemPrompt
=
systemPromptFilter
(
formatRedisPrompt
,
3
0
00
);
prompts
.
unshift
({
prompts
.
unshift
({
obj
:
'SYSTEM'
,
obj
:
'SYSTEM'
,
...
...
src/pages/number/components/BillTable.tsx
0 → 100644
View file @
77dc961a
import
React
from
'react'
;
import
{
Card
,
Box
,
Table
,
Thead
,
Tbody
,
Tr
,
Th
,
Td
,
TableContainer
}
from
'@chakra-ui/react'
;
import
ScrollData
from
'@/components/ScrollData'
;
import
{
BillTypeMap
}
from
'@/constants/user'
;
import
{
getUserBills
}
from
'@/api/user'
;
import
{
usePaging
}
from
'@/hooks/usePaging'
;
import
type
{
UserBillType
}
from
'@/types/user'
;
const
BillTable
=
()
=>
{
const
{
nextPage
,
isLoadAll
,
requesting
,
data
:
bills
}
=
usePaging
<
UserBillType
>
({
api
:
getUserBills
,
pageSize
:
30
});
return
(
<
Card
mt=
{
6
}
py=
{
4
}
>
<
Box
fontSize=
{
'xl'
}
fontWeight=
{
'bold'
}
px=
{
6
}
mb=
{
1
}
>
使用记录
</
Box
>
<
ScrollData
maxH=
{
'400px'
}
px=
{
6
}
isLoadAll=
{
isLoadAll
}
requesting=
{
requesting
}
nextPage=
{
nextPage
}
>
<
TableContainer
>
<
Table
>
<
Thead
>
<
Tr
>
<
Th
>
时间
</
Th
>
<
Th
>
类型
</
Th
>
<
Th
>
内容长度
</
Th
>
<
Th
>
Tokens 长度
</
Th
>
<
Th
>
消费
</
Th
>
</
Tr
>
</
Thead
>
<
Tbody
fontSize=
{
'sm'
}
>
{
bills
.
map
((
item
)
=>
(
<
Tr
key=
{
item
.
id
}
>
<
Td
>
{
item
.
time
}
</
Td
>
<
Td
>
{
BillTypeMap
[
item
.
type
]
}
</
Td
>
<
Td
>
{
item
.
textLen
}
</
Td
>
<
Td
>
{
item
.
tokenLen
}
</
Td
>
<
Td
>
{
item
.
price
}
元
</
Td
>
</
Tr
>
))
}
</
Tbody
>
</
Table
>
</
TableContainer
>
</
ScrollData
>
</
Card
>
);
};
export
default
BillTable
;
src/pages/number/components/PayRecordTable.tsx
0 → 100644
View file @
77dc961a
import
React
,
{
useState
,
useCallback
}
from
'react'
;
import
{
Card
,
Box
,
Flex
,
Button
,
Table
,
Thead
,
Tbody
,
Tr
,
Th
,
Td
,
TableContainer
,
useDisclosure
}
from
'@chakra-ui/react'
;
import
{
getPayOrders
,
checkPayResult
}
from
'@/api/user'
;
import
{
PaySchema
}
from
'@/types/mongoSchema'
;
import
dayjs
from
'dayjs'
;
import
{
useQuery
}
from
'@tanstack/react-query'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
WxConcat
from
'@/components/WxConcat'
;
import
{
useGlobalStore
}
from
'@/store/global'
;
import
{
useToast
}
from
'@/hooks/useToast'
;
const
PayRecordTable
=
()
=>
{
const
{
isOpen
:
isOpenWx
,
onOpen
:
onOpenWx
,
onClose
:
onCloseWx
}
=
useDisclosure
();
const
[
payOrders
,
setPayOrders
]
=
useState
<
PaySchema
[]
>
([]);
const
{
setLoading
}
=
useGlobalStore
();
const
{
toast
}
=
useToast
();
const
handleRefreshPayOrder
=
useCallback
(
async
(
payId
:
string
)
=>
{
setLoading
(
true
);
try
{
const
data
=
await
checkPayResult
(
payId
);
toast
({
title
:
data
,
status
:
'info'
});
const
res
=
await
getPayOrders
();
setPayOrders
(
res
);
}
catch
(
error
:
any
)
{
toast
({
title
:
error
?.
message
,
status
:
'warning'
});
console
.
log
(
error
);
}
setLoading
(
false
);
},
[
setLoading
,
toast
]
);
useQuery
([
'initPayOrder'
],
getPayOrders
,
{
onSuccess
(
res
)
{
setPayOrders
(
res
);
}
});
return
(
<>
<
Card
mt=
{
6
}
py=
{
4
}
>
<
Flex
alignItems=
{
'flex-end'
}
px=
{
6
}
mb=
{
1
}
>
<
Box
fontSize=
{
'xl'
}
fontWeight=
{
'bold'
}
>
充值记录
</
Box
>
<
Button
onClick=
{
onOpenWx
}
size=
{
'xs'
}
ml=
{
4
}
variant=
{
'outline'
}
>
异常问题,wx联系
</
Button
>
</
Flex
>
<
TableContainer
maxH=
{
'400px'
}
overflowY=
{
'auto'
}
px=
{
6
}
>
<
Table
>
<
Thead
>
<
Tr
>
<
Th
>
订单号
</
Th
>
<
Th
>
时间
</
Th
>
<
Th
>
金额
</
Th
>
<
Th
>
消费
</
Th
>
<
Th
></
Th
>
</
Tr
>
</
Thead
>
<
Tbody
fontSize=
{
'sm'
}
>
{
payOrders
.
map
((
item
)
=>
(
<
Tr
key=
{
item
.
_id
}
>
<
Td
>
{
item
.
orderId
}
</
Td
>
<
Td
>
{
item
.
createTime
?
dayjs
(
item
.
createTime
).
format
(
'YYYY/MM/DD HH:mm:ss'
)
:
'-'
}
</
Td
>
<
Td
>
{
formatPrice
(
item
.
price
)
}
元
</
Td
>
<
Td
>
{
item
.
status
}
</
Td
>
<
Td
>
{
item
.
status
===
'NOTPAY'
&&
(
<
Button
onClick=
{
()
=>
handleRefreshPayOrder
(
item
.
_id
)
}
size=
{
'sm'
}
>
更新
</
Button
>
)
}
</
Td
>
</
Tr
>
))
}
</
Tbody
>
</
Table
>
</
TableContainer
>
</
Card
>
{
/* wx 联系 */
}
{
isOpenWx
&&
<
WxConcat
onClose=
{
onCloseWx
}
/>
}
</>
);
};
export
default
PayRecordTable
;
src/pages/number/setting.tsx
View file @
77dc961a
...
@@ -13,28 +13,22 @@ import {
...
@@ -13,28 +13,22 @@ import {
TableContainer
,
TableContainer
,
Select
,
Select
,
Input
,
Input
,
IconButton
,
IconButton
useDisclosure
}
from
'@chakra-ui/react'
;
}
from
'@chakra-ui/react'
;
import
{
DeleteIcon
}
from
'@chakra-ui/icons'
;
import
{
DeleteIcon
}
from
'@chakra-ui/icons'
;
import
{
useForm
,
useFieldArray
}
from
'react-hook-form'
;
import
{
useForm
,
useFieldArray
}
from
'react-hook-form'
;
import
{
UserUpdateParams
}
from
'@/types/user'
;
import
{
UserUpdateParams
}
from
'@/types/user'
;
import
{
putUserInfo
,
getUserBills
,
getPayOrders
,
checkPayResult
}
from
'@/api/user'
;
import
{
putUserInfo
}
from
'@/api/user'
;
import
{
useToast
}
from
'@/hooks/useToast'
;
import
{
useToast
}
from
'@/hooks/useToast'
;
import
{
useGlobalStore
}
from
'@/store/global'
;
import
{
useGlobalStore
}
from
'@/store/global'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
{
UserType
}
from
'@/types/user'
;
import
{
UserType
}
from
'@/types/user'
;
import
{
usePaging
}
from
'@/hooks/usePaging'
;
import
type
{
UserBillType
}
from
'@/types/user'
;
import
{
useQuery
}
from
'@tanstack/react-query'
;
import
{
useQuery
}
from
'@tanstack/react-query'
;
import
dynamic
from
'next/dynamic'
;
import
dynamic
from
'next/dynamic'
;
import
{
PaySchema
}
from
'@/types/mongoSchema'
;
import
dayjs
from
'dayjs'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
WxConcat
from
'@/components/WxConcat'
;
import
ScrollData
from
'@/components/ScrollData'
;
import
{
BillTypeMap
}
from
'@/constants/user'
;
const
PayRecordTable
=
dynamic
(()
=>
import
(
'./components/PayRecordTable'
));
const
BilTable
=
dynamic
(()
=>
import
(
'./components/BillTable'
));
const
PayModal
=
dynamic
(()
=>
import
(
'./components/PayModal'
));
const
PayModal
=
dynamic
(()
=>
import
(
'./components/PayModal'
));
const
NumberSetting
=
()
=>
{
const
NumberSetting
=
()
=>
{
...
@@ -44,7 +38,6 @@ const NumberSetting = () => {
...
@@ -44,7 +38,6 @@ const NumberSetting = () => {
defaultValues
:
userInfo
as
UserType
defaultValues
:
userInfo
as
UserType
});
});
const
[
showPay
,
setShowPay
]
=
useState
(
false
);
const
[
showPay
,
setShowPay
]
=
useState
(
false
);
const
{
isOpen
:
isOpenWx
,
onOpen
:
onOpenWx
,
onClose
:
onCloseWx
}
=
useDisclosure
();
const
{
toast
}
=
useToast
();
const
{
toast
}
=
useToast
();
const
{
const
{
fields
:
accounts
,
fields
:
accounts
,
...
@@ -54,16 +47,6 @@ const NumberSetting = () => {
...
@@ -54,16 +47,6 @@ const NumberSetting = () => {
control
,
control
,
name
:
'accounts'
name
:
'accounts'
});
});
const
{
nextPage
,
isLoadAll
,
requesting
,
data
:
bills
}
=
usePaging
<
UserBillType
>
({
api
:
getUserBills
,
pageSize
:
30
});
const
[
payOrders
,
setPayOrders
]
=
useState
<
PaySchema
[]
>
([]);
const
onclickSave
=
useCallback
(
const
onclickSave
=
useCallback
(
async
(
data
:
UserUpdateParams
)
=>
{
async
(
data
:
UserUpdateParams
)
=>
{
...
@@ -83,39 +66,9 @@ const NumberSetting = () => {
...
@@ -83,39 +66,9 @@ const NumberSetting = () => {
useQuery
([
'init'
],
initUserInfo
);
useQuery
([
'init'
],
initUserInfo
);
useQuery
([
'initPayOrder'
],
getPayOrders
,
{
onSuccess
(
res
)
{
setPayOrders
(
res
);
}
});
const
handleRefreshPayOrder
=
useCallback
(
async
(
payId
:
string
)
=>
{
setLoading
(
true
);
try
{
const
data
=
await
checkPayResult
(
payId
);
toast
({
title
:
data
,
status
:
'info'
});
const
res
=
await
getPayOrders
();
setPayOrders
(
res
);
}
catch
(
error
:
any
)
{
toast
({
title
:
error
?.
message
,
status
:
'warning'
});
console
.
log
(
error
);
}
setLoading
(
false
);
},
[
setLoading
,
toast
]
);
return
(
return
(
<>
<>
{
/* 核心信息 */
}
<
Card
px=
{
6
}
py=
{
4
}
>
<
Card
px=
{
6
}
py=
{
4
}
>
<
Box
fontSize=
{
'xl'
}
fontWeight=
{
'bold'
}
>
<
Box
fontSize=
{
'xl'
}
fontWeight=
{
'bold'
}
>
账号信息
账号信息
...
@@ -141,6 +94,7 @@ const NumberSetting = () => {
...
@@ -141,6 +94,7 @@ const NumberSetting = () => {
</
Box
>
</
Box
>
</
Box
>
</
Box
>
</
Card
>
</
Card
>
{
/* 账号信息 */
}
<
Card
mt=
{
6
}
px=
{
6
}
py=
{
4
}
>
<
Card
mt=
{
6
}
px=
{
6
}
py=
{
4
}
>
<
Flex
mb=
{
5
}
justifyContent=
{
'space-between'
}
>
<
Flex
mb=
{
5
}
justifyContent=
{
'space-between'
}
>
<
Box
fontSize=
{
'xl'
}
fontWeight=
{
'bold'
}
>
<
Box
fontSize=
{
'xl'
}
fontWeight=
{
'bold'
}
>
...
@@ -209,88 +163,11 @@ const NumberSetting = () => {
...
@@ -209,88 +163,11 @@ const NumberSetting = () => {
</
Table
>
</
Table
>
</
TableContainer
>
</
TableContainer
>
</
Card
>
</
Card
>
<
Card
mt=
{
6
}
py=
{
4
}
>
{
/* 充值记录 */
}
<
Flex
alignItems=
{
'flex-end'
}
px=
{
6
}
mb=
{
1
}
>
<
PayRecordTable
/>
<
Box
fontSize=
{
'xl'
}
fontWeight=
{
'bold'
}
>
{
/* 账单表 */
}
充值记录
<
BilTable
/>
</
Box
>
<
Button
onClick=
{
onOpenWx
}
size=
{
'xs'
}
ml=
{
4
}
variant=
{
'outline'
}
>
异常问题,wx联系
</
Button
>
</
Flex
>
<
TableContainer
maxH=
{
'400px'
}
overflowY=
{
'auto'
}
px=
{
6
}
>
<
Table
>
<
Thead
>
<
Tr
>
<
Th
>
订单号
</
Th
>
<
Th
>
时间
</
Th
>
<
Th
>
金额
</
Th
>
<
Th
>
消费
</
Th
>
<
Th
></
Th
>
</
Tr
>
</
Thead
>
<
Tbody
fontSize=
{
'sm'
}
>
{
payOrders
.
map
((
item
)
=>
(
<
Tr
key=
{
item
.
_id
}
>
<
Td
>
{
item
.
orderId
}
</
Td
>
<
Td
>
{
item
.
createTime
?
dayjs
(
item
.
createTime
).
format
(
'YYYY/MM/DD HH:mm:ss'
)
:
'-'
}
</
Td
>
<
Td
>
{
formatPrice
(
item
.
price
)
}
元
</
Td
>
<
Td
>
{
item
.
status
}
</
Td
>
<
Td
>
{
item
.
status
===
'NOTPAY'
&&
(
<
Button
onClick=
{
()
=>
handleRefreshPayOrder
(
item
.
_id
)
}
size=
{
'sm'
}
>
更新
</
Button
>
)
}
</
Td
>
</
Tr
>
))
}
</
Tbody
>
</
Table
>
</
TableContainer
>
</
Card
>
<
Card
mt=
{
6
}
py=
{
4
}
>
<
Box
fontSize=
{
'xl'
}
fontWeight=
{
'bold'
}
px=
{
6
}
mb=
{
1
}
>
使用记录
</
Box
>
<
ScrollData
maxH=
{
'400px'
}
px=
{
6
}
isLoadAll=
{
isLoadAll
}
requesting=
{
requesting
}
nextPage=
{
nextPage
}
>
<
TableContainer
>
<
Table
>
<
Thead
>
<
Tr
>
<
Th
>
时间
</
Th
>
<
Th
>
类型
</
Th
>
<
Th
>
内容长度
</
Th
>
<
Th
>
Tokens 长度
</
Th
>
<
Th
>
消费
</
Th
>
</
Tr
>
</
Thead
>
<
Tbody
fontSize=
{
'sm'
}
>
{
bills
.
map
((
item
)
=>
(
<
Tr
key=
{
item
.
id
}
>
<
Td
>
{
item
.
time
}
</
Td
>
<
Td
>
{
BillTypeMap
[
item
.
type
]
}
</
Td
>
<
Td
>
{
item
.
textLen
}
</
Td
>
<
Td
>
{
item
.
tokenLen
}
</
Td
>
<
Td
>
{
item
.
price
}
元
</
Td
>
</
Tr
>
))
}
</
Tbody
>
</
Table
>
</
TableContainer
>
</
ScrollData
>
</
Card
>
{
showPay
&&
<
PayModal
onClose=
{
()
=>
setShowPay
(
false
)
}
/>
}
{
showPay
&&
<
PayModal
onClose=
{
()
=>
setShowPay
(
false
)
}
/>
}
{
/* wx 联系 */
}
{
isOpenWx
&&
<
WxConcat
onClose=
{
onCloseWx
}
/>
}
</>
</>
);
);
};
};
...
...
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