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
11f42ad9
authored
May 02, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: chat load
parent
90456301
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
src/pages/chat/components/SlideBar.tsx
+15
-5
src/pages/chat/index.tsx
+5
-6
No files found.
src/pages/chat/components/SlideBar.tsx
View file @
11f42ad9
...
...
@@ -50,11 +50,19 @@ const SlideBar = ({
const
{
isOpen
:
isOpenWx
,
onOpen
:
onOpenWx
,
onClose
:
onCloseWx
}
=
useDisclosure
();
const
preChatId
=
useRef
(
'chatId'
);
// 用于校验上一次chatId的情况,判断是否需要刷新历史记录
const
{
isSuccess
}
=
useQuery
([
'getMyModels'
],
getMyModels
,
{
cacheTime
:
5
*
60
*
1000
const
{
isSuccess
,
refetch
:
fetchMyModels
}
=
useQuery
([
'getMyModels'
],
getMyModels
,
{
cacheTime
:
5
*
60
*
1000
,
enabled
:
false
});
const
{
data
:
collectionModels
=
[]
}
=
useQuery
([
getCollectionModels
],
getCollectionModels
);
const
{
data
:
collectionModels
=
[],
refetch
:
fetchCollectionModels
}
=
useQuery
(
[
getCollectionModels
],
getCollectionModels
,
{
cacheTime
:
5
*
60
*
1000
,
enabled
:
false
}
);
const
models
=
useMemo
(()
=>
{
const
myModelList
=
myModels
.
map
((
item
)
=>
({
...
...
@@ -88,9 +96,11 @@ const SlideBar = ({
// init history
useEffect
(()
=>
{
setTimeout
(()
=>
{
fetchMyModels
();
fetchCollectionModels
();
loadChatHistory
();
},
1
0
00
);
},
[
loadChatHistory
]);
},
1
5
00
);
},
[
fetchCollectionModels
,
fetchMyModels
,
loadChatHistory
]);
/**
* export md
...
...
src/pages/chat/index.tsx
View file @
11f42ad9
...
...
@@ -32,14 +32,13 @@ import dynamic from 'next/dynamic';
import
{
useGlobalStore
}
from
'@/store/global'
;
import
{
useCopyData
}
from
'@/utils/tools'
;
import
{
streamFetch
}
from
'@/api/fetch'
;
import
Icon
from
'@/components/Icon'
;
import
MyIcon
from
'@/components/Icon'
;
import
{
throttle
}
from
'lodash'
;
import
{
Types
}
from
'mongoose'
;
import
Markdown
from
'@/components/Markdown'
;
const
SlideBar
=
dynamic
(()
=>
import
(
'./components/SlideBar'
));
const
Empty
=
dynamic
(()
=>
import
(
'./components/Empty'
));
const
Markdown
=
dynamic
(()
=>
import
(
'@/components/Markdown'
));
import
styles
from
'./index.module.scss'
;
...
...
@@ -149,7 +148,7 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
if
(
isScroll
&&
res
.
history
.
length
>
0
)
{
setTimeout
(()
=>
{
scrollToBottom
(
'auto'
);
},
1
2
00
);
},
1
0
00
);
}
}
catch
(
e
:
any
)
{
toast
({
...
...
@@ -428,7 +427,7 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
px=
{
7
}
>
<
Box
onClick=
{
onOpenSlider
}
>
<
Icon
<
My
Icon
name=
{
'menu'
}
w=
{
'20px'
}
h=
{
'20px'
}
...
...
@@ -615,7 +614,7 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
bottom=
{
'15px'
}
>
{
isChatting
?
(
<
Icon
<
My
Icon
className=
{
styles
.
stopIcon
}
width=
{
[
'22px'
,
'25px'
]
}
height=
{
[
'22px'
,
'25px'
]
}
...
...
@@ -627,7 +626,7 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
}
}
/>
)
:
(
<
Icon
<
My
Icon
name=
{
'chatSend'
}
width=
{
[
'18px'
,
'20px'
]
}
height=
{
[
'18px'
,
'20px'
]
}
...
...
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