Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
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
Commit
f6698c02
authored
May 21, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【解决todo】AI chat 输入框增加 shift + 回车 换行
parent
2d7bf845
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
src/views/ai/chat/Message.vue
+1
-0
src/views/ai/chat/index.vue
+15
-5
No files found.
src/views/ai/chat/Message.vue
View file @
f6698c02
...
@@ -246,6 +246,7 @@ onMounted(async () => {
...
@@ -246,6 +246,7 @@ onMounted(async () => {
padding
:
10px
;
padding
:
10px
;
width
:
auto
;
width
:
auto
;
overflow-wrap
:
break-word
;
overflow-wrap
:
break-word
;
white-space
:
pre-wrap
;
}
}
}
}
...
...
src/views/ai/chat/index.vue
View file @
f6698c02
...
@@ -41,11 +41,11 @@
...
@@ -41,11 +41,11 @@
<!-- 底部 -->
<!-- 底部 -->
<el-footer
class=
"footer-container"
>
<el-footer
class=
"footer-container"
>
<form
@
submit
.
prevent=
"onSend"
class=
"prompt-from"
>
<form
class=
"prompt-from"
>
<textarea
<textarea
class=
"prompt-input"
class=
"prompt-input"
v-model=
"prompt"
v-model=
"prompt"
@
key
up
.
enter
=
"onSend"
@
key
down
=
"onSend"
@
input=
"onPromptInput"
@
input=
"onPromptInput"
@
compositionstart=
"onCompositionstart"
@
compositionstart=
"onCompositionstart"
@
compositionend=
"onCompositionend"
@
compositionend=
"onCompositionend"
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
<el-button
<el-button
type=
"primary"
type=
"primary"
size=
"default"
size=
"default"
@
click=
"onSend
()
"
@
click=
"onSend"
:loading=
"conversationInProgress"
:loading=
"conversationInProgress"
v-if=
"conversationInProgress == false"
v-if=
"conversationInProgress == false"
>
>
...
@@ -231,7 +231,7 @@ const onPromptInput = (event) => {
...
@@ -231,7 +231,7 @@ const onPromptInput = (event) => {
/**
/**
* 发送消息
* 发送消息
*/
*/
const
onSend
=
async
()
=>
{
const
onSend
=
async
(
event
)
=>
{
// 判断用户是否在输入
// 判断用户是否在输入
if
(
isComposing
.
value
)
{
if
(
isComposing
.
value
)
{
return
return
...
@@ -241,7 +241,17 @@ const onSend = async () => {
...
@@ -241,7 +241,17 @@ const onSend = async () => {
return
return
}
}
const
content
=
prompt
.
value
?.
trim
()
as
string
const
content
=
prompt
.
value
?.
trim
()
as
string
await
doSend
(
content
)
if
(
event
.
key
===
'Enter'
)
{
if
(
event
.
shiftKey
)
{
// 插入换行
prompt
.
value
+=
'\r\n'
;
event
.
preventDefault
();
// 防止默认的换行行为
}
else
{
// 发送消息
await
doSend
(
content
)
event
.
preventDefault
();
// 防止默认的提交行为
}
}
}
}
const
doSend
=
async
(
content
:
string
)
=>
{
const
doSend
=
async
(
content
:
string
)
=>
{
...
...
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