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
042b0c53
authored
Apr 03, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 发送按键
parent
f97c29b4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
17 deletions
+18
-17
src/pages/chat/index.tsx
+17
-13
src/service/events/generateQA.ts
+1
-4
No files found.
src/pages/chat/index.tsx
View file @
042b0c53
...
@@ -194,11 +194,7 @@ const Chat = ({ chatId }: { chatId: string }) => {
...
@@ -194,11 +194,7 @@ const Chat = ({ chatId }: { chatId: string }) => {
const
sendPrompt
=
useCallback
(
async
()
=>
{
const
sendPrompt
=
useCallback
(
async
()
=>
{
const
storeInput
=
inputVal
;
const
storeInput
=
inputVal
;
// 去除空行
// 去除空行
const
val
=
inputVal
const
val
=
inputVal
.
trim
().
replace
(
/
\n\s
*/g
,
'\n'
);
.
trim
()
.
split
(
'\n'
)
.
filter
((
val
)
=>
val
)
.
join
(
'\n'
);
if
(
!
chatData
?.
modelId
||
!
val
||
isChatting
)
{
if
(
!
chatData
?.
modelId
||
!
val
||
isChatting
)
{
toast
({
toast
({
...
@@ -458,8 +454,7 @@ const Chat = ({ chatId }: { chatId: string }) => {
...
@@ -458,8 +454,7 @@ const Chat = ({ chatId }: { chatId: string }) => {
</
Box
>
</
Box
>
{
/* 发送区 */
}
{
/* 发送区 */
}
<
Box
m=
{
media
(
'20px auto'
,
'0 auto'
)
}
w=
{
'100%'
}
maxW=
{
media
(
'min(750px, 100%)'
,
'auto'
)
}
>
<
Box
m=
{
media
(
'20px auto'
,
'0 auto'
)
}
w=
{
'100%'
}
maxW=
{
media
(
'min(750px, 100%)'
,
'auto'
)
}
>
<
Flex
<
Box
alignItems=
{
'center'
}
py=
{
5
}
py=
{
5
}
position=
{
'relative'
}
position=
{
'relative'
}
boxShadow=
{
`0 0 15px rgba(0,0,0,0.1)`
}
boxShadow=
{
`0 0 15px rgba(0,0,0,0.1)`
}
...
@@ -471,23 +466,23 @@ const Chat = ({ chatId }: { chatId: string }) => {
...
@@ -471,23 +466,23 @@ const Chat = ({ chatId }: { chatId: string }) => {
{
/* 输入框 */
}
{
/* 输入框 */
}
<
Textarea
<
Textarea
ref=
{
TextareaDom
}
ref=
{
TextareaDom
}
flex=
{
1
}
w=
{
0
}
py=
{
0
}
py=
{
0
}
pr=
{
0
}
pr=
{
[
'45px'
,
'55px'
]
}
border=
{
'none'
}
border=
{
'none'
}
_focusVisible=
{
{
_focusVisible=
{
{
border
:
'none'
border
:
'none'
}
}
}
}
placeholder=
"提问"
placeholder=
"提问"
resize=
{
'none'
}
resize=
{
'none'
}
v
alue=
{
inputVal
}
defaultV
alue=
{
inputVal
}
rows=
{
1
}
rows=
{
1
}
height=
{
'22px'
}
height=
{
'22px'
}
lineHeight=
{
'22px'
}
lineHeight=
{
'22px'
}
maxHeight=
{
'150px'
}
maxHeight=
{
'150px'
}
maxLength=
{
-
1
}
maxLength=
{
-
1
}
overflowY=
{
'auto'
}
overflowY=
{
'auto'
}
whiteSpace=
{
'pre-wrap'
}
wordBreak=
{
'break-all'
}
color=
{
useColorModeValue
(
'blackAlpha.700'
,
'white'
)
}
color=
{
useColorModeValue
(
'blackAlpha.700'
,
'white'
)
}
onChange=
{
(
e
)
=>
{
onChange=
{
(
e
)
=>
{
const
textarea
=
e
.
target
;
const
textarea
=
e
.
target
;
...
@@ -507,7 +502,16 @@ const Chat = ({ chatId }: { chatId: string }) => {
...
@@ -507,7 +502,16 @@ const Chat = ({ chatId }: { chatId: string }) => {
}
}
}
}
/>
/>
{
/* 发送和等待按键 */
}
{
/* 发送和等待按键 */
}
<
Flex
px=
{
4
}
h=
{
'30px'
}
alignItems=
{
'flex-end'
}
onClick=
{
sendPrompt
}
>
<
Flex
alignItems=
{
'center'
}
justifyContent=
{
'center'
}
h=
{
'30px'
}
w=
{
'30px'
}
position=
{
'absolute'
}
right=
{
[
'12px'
,
'20px'
]
}
bottom=
{
3
}
onClick=
{
sendPrompt
}
>
{
isChatting
?
(
{
isChatting
?
(
<
Image
<
Image
style=
{
{
transform
:
'translateY(4px)'
}
}
style=
{
{
transform
:
'translateY(4px)'
}
}
...
@@ -527,7 +531,7 @@ const Chat = ({ chatId }: { chatId: string }) => {
...
@@ -527,7 +531,7 @@ const Chat = ({ chatId }: { chatId: string }) => {
</
Box
>
</
Box
>
)
}
)
}
</
Flex
>
</
Flex
>
</
Fle
x
>
</
Bo
x
>
</
Box
>
</
Box
>
</
Flex
>
</
Flex
>
</
Flex
>
</
Flex
>
...
...
src/service/events/generateQA.ts
View file @
042b0c53
...
@@ -155,10 +155,7 @@ function splitText(text: string) {
...
@@ -155,10 +155,7 @@ function splitText(text: string) {
// 如果Q和A都存在,就将其添加到结果中
// 如果Q和A都存在,就将其添加到结果中
result
.
push
({
result
.
push
({
q
,
q
,
a
:
a
// 过滤空行
a
:
a
.
trim
().
replace
(
/
\n\s
*/g
,
'\n'
)
.
split
(
'\n'
)
.
filter
((
item
)
=>
item
)
.
join
(
'\n'
)
});
});
}
}
}
}
...
...
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