【解决todo】AI chat 输入框增加 shift + 回车 换行

This commit is contained in:
cherishsince 2024-05-21 22:05:56 +08:00
parent 2d7bf84593
commit f6698c0286
2 changed files with 16 additions and 5 deletions

View File

@ -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;
} }
} }

View File

@ -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"
@keyup.enter="onSend" @keydown="onSend"
@input="onPromptInput" @input="onPromptInput"
@compositionstart="onCompositionstart" @compositionstart="onCompositionstart"
@compositionend="onCompositionend" @compositionend="onCompositionend"
@ -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) => {
/** /**
* 发送消息 * 发送消息
*/ */
const onSend = async () => { const onSend = async (event) => {
// //
if (isComposing.value) { if (isComposing.value) {
return return
@ -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) => {