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
fd47f730
authored
Dec 10, 2024
by
Archer
Committed by
GitHub
Dec 10, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: auto send delay (#3352)
parent
fc8f73fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
25 deletions
+32
-25
projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx
+32
-25
No files found.
projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx
View file @
fd47f730
...
@@ -58,7 +58,7 @@ import dynamic from 'next/dynamic';
...
@@ -58,7 +58,7 @@ import dynamic from 'next/dynamic';
import
type
{
StreamResponseType
}
from
'@/web/common/api/fetch'
;
import
type
{
StreamResponseType
}
from
'@/web/common/api/fetch'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
useSystem
}
from
'@fastgpt/web/hooks/useSystem'
;
import
{
useSystem
}
from
'@fastgpt/web/hooks/useSystem'
;
import
{
useCreation
,
useMemoizedFn
,
useThrottleFn
}
from
'ahooks'
;
import
{
useCreation
,
use
DebounceEffect
,
use
MemoizedFn
,
useThrottleFn
}
from
'ahooks'
;
import
MyIcon
from
'@fastgpt/web/components/common/Icon'
;
import
MyIcon
from
'@fastgpt/web/components/common/Icon'
;
import
{
mergeChatResponseData
}
from
'@fastgpt/global/core/chat/utils'
;
import
{
mergeChatResponseData
}
from
'@fastgpt/global/core/chat/utils'
;
import
{
getWebReqUrl
}
from
'@fastgpt/web/common/system/utils'
;
import
{
getWebReqUrl
}
from
'@fastgpt/web/common/system/utils'
;
...
@@ -380,10 +380,11 @@ const ChatBox = ({
...
@@ -380,10 +380,11 @@ const ChatBox = ({
async
({
variables
=
{}
})
=>
{
async
({
variables
=
{}
})
=>
{
if
(
!
onStartChat
)
return
;
if
(
!
onStartChat
)
return
;
if
(
isChatting
)
{
if
(
isChatting
)
{
toast
({
!
hideInUI
&&
title
:
t
(
'chat:is_chatting'
),
toast
({
status
:
'warning'
title
:
t
(
'chat:is_chatting'
),
});
status
:
'warning'
});
return
;
return
;
}
}
...
@@ -834,27 +835,33 @@ const ChatBox = ({
...
@@ -834,27 +835,33 @@ const ChatBox = ({
},
[
isReady
,
resetInputVal
,
sendPrompt
]);
},
[
isReady
,
resetInputVal
,
sendPrompt
]);
// Auto send prompt
// Auto send prompt
useEffect
(()
=>
{
useDebounceEffect
(
if
(
()
=>
{
isReady
&&
if
(
chatBoxData
?.
app
?.
chatConfig
?.
autoExecute
?.
open
&&
isReady
&&
chatStarted
&&
chatBoxData
?.
app
?.
chatConfig
?.
autoExecute
?.
open
&&
chatRecords
.
length
===
0
&&
chatStarted
&&
isChatRecordsLoaded
chatRecords
.
length
===
0
&&
)
{
isChatRecordsLoaded
sendPrompt
({
)
{
text
:
chatBoxData
?.
app
?.
chatConfig
?.
autoExecute
?.
defaultPrompt
||
'AUTO_EXECUTE'
,
sendPrompt
({
hideInUI
:
true
text
:
chatBoxData
?.
app
?.
chatConfig
?.
autoExecute
?.
defaultPrompt
||
'AUTO_EXECUTE'
,
});
hideInUI
:
true
});
}
},
[
isReady
,
chatStarted
,
chatRecords
.
length
,
isChatRecordsLoaded
,
sendPrompt
,
chatBoxData
?.
app
?.
chatConfig
?.
autoExecute
],
{
wait
:
500
}
}
},
[
);
isReady
,
chatStarted
,
chatRecords
.
length
,
isChatRecordsLoaded
,
sendPrompt
,
chatBoxData
?.
app
?.
chatConfig
?.
autoExecute
]);
// output data
// output data
useImperativeHandle
(
ChatBoxRef
,
()
=>
({
useImperativeHandle
(
ChatBoxRef
,
()
=>
({
...
...
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