feat: 支持输入法组合状态,优化输入框键盘事件处理

This commit is contained in:
kuaifan 2026-01-14 10:11:28 +00:00
parent dd20711c04
commit 224703a6d0

View File

@ -99,7 +99,9 @@
:rows="inputRows || 1"
:autosize="inputAutosize || {minRows:1, maxRows:6}"
:maxlength="inputMaxlength || 500"
@on-keydown="onInputKeydown" />
@on-keydown="onInputKeydown"
@compositionstart.native="isComposing = true"
@compositionend.native="isComposing = false" />
<div class="ai-assistant-footer">
<div class="ai-assistant-footer-models">
<Select
@ -176,6 +178,9 @@ export default {
modelCacheKey: 'aiAssistant.model',
cachedModelId: '',
//
isComposing: false,
//
responses: [],
responseSeed: 1,
@ -405,9 +410,10 @@ export default {
/**
* 输入框键盘事件回车发送Shift+回车换行
* 注意输入法组合输入时如中文候选字不发送
*/
onInputKeydown(e) {
if (e.key === 'Enter' && !e.shiftKey) {
if (e.key === 'Enter' && !e.shiftKey && !this.isComposing) {
e.preventDefault();
this.onSubmit();
}