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
1f801d14
authored
Apr 25, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: abort chat make page error
parent
d0e65431
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
src/pages/chat/index.tsx
+10
-0
No files found.
src/pages/chat/index.tsx
View file @
1f801d14
...
@@ -57,6 +57,8 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
...
@@ -57,6 +57,8 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
// 中断请求
// 中断请求
const
controller
=
useRef
(
new
AbortController
());
const
controller
=
useRef
(
new
AbortController
());
const
isResetPage
=
useRef
(
false
);
const
[
chatData
,
setChatData
]
=
useState
<
ChatType
>
({
const
[
chatData
,
setChatData
]
=
useState
<
ChatType
>
({
chatId
,
chatId
,
modelId
,
modelId
,
...
@@ -166,7 +168,9 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
...
@@ -166,7 +168,9 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
const
resetChat
=
useCallback
(
const
resetChat
=
useCallback
(
async
(
modelId
=
chatData
.
modelId
,
chatId
=
''
)
=>
{
async
(
modelId
=
chatData
.
modelId
,
chatId
=
''
)
=>
{
// 强制中断流
// 强制中断流
isResetPage
.
current
=
true
;
controller
.
current
?.
abort
();
controller
.
current
?.
abort
();
try
{
try
{
router
.
replace
(
`/chat?modelId=
${
modelId
}
&chatId=
${
chatId
}
`
);
router
.
replace
(
`/chat?modelId=
${
modelId
}
&chatId=
${
chatId
}
`
);
loadChatInfo
({
loadChatInfo
({
...
@@ -199,6 +203,7 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
...
@@ -199,6 +203,7 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
// create abort obj
// create abort obj
const
abortSignal
=
new
AbortController
();
const
abortSignal
=
new
AbortController
();
controller
.
current
=
abortSignal
;
controller
.
current
=
abortSignal
;
isResetPage
.
current
=
false
;
const
prompt
=
{
const
prompt
=
{
obj
:
prompts
.
obj
,
obj
:
prompts
.
obj
,
...
@@ -229,6 +234,11 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
...
@@ -229,6 +234,11 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
abortSignal
abortSignal
});
});
// 重置了页面,说明退出了当前聊天, 不缓存任何内容
if
(
isResetPage
.
current
)
{
return
;
}
let
newChatId
=
''
;
let
newChatId
=
''
;
// 保存对话信息
// 保存对话信息
try
{
try
{
...
...
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