From dff8ef1ba3d6c19c9060170a60ce56961e976cb7 Mon Sep 17 00:00:00 2001 From: yang <2636098325@qq.com> Date: Tue, 20 Jan 2026 21:11:47 +0800 Subject: [PATCH] fix(components): [sender] fix `autosize` resizable lose bug --- packages/core/src/components/Sender/index.vue | 102 ++++++++---------- 1 file changed, 43 insertions(+), 59 deletions(-) diff --git a/packages/core/src/components/Sender/index.vue b/packages/core/src/components/Sender/index.vue index 75f869f2..3104b6b2 100644 --- a/packages/core/src/components/Sender/index.vue +++ b/packages/core/src/components/Sender/index.vue @@ -56,8 +56,7 @@ const internalValue = computed({ return props.modelValue; }, set(val) { - if (props.readOnly || props.disabled) - return; + if (props.readOnly || props.disabled) return; emits('update:modelValue', val); } }); @@ -87,8 +86,7 @@ const popoverVisible = computed({ return props.triggerPopoverVisible; }, set(value) { - if (props.readOnly || props.disabled) - return; + if (props.readOnly || props.disabled) return; emits('update:triggerPopoverVisible', value); } }); @@ -100,8 +98,7 @@ const triggerString = ref(''); watch( () => internalValue.value, (newVal, oldVal) => { - if (isComposing.value) - return; + if (isComposing.value) return; // 触发逻辑:当输入值等于数组中的任意一个指令字符时触发 // 确保 oldVal 是字符串类型 const triggerStrings = props.triggerStrings || []; // 如果为 undefined,就使用空数组 @@ -120,8 +117,7 @@ watch( isOpen: true }); popoverVisible.value = true; - } - else { + } else { popoverVisible.value = true; } } @@ -135,8 +131,7 @@ watch( isOpen: false }); popoverVisible.value = false; - } - else { + } else { popoverVisible.value = false; } } @@ -151,8 +146,7 @@ watch( isOpen: true }); popoverVisible.value = true; - } - else { + } else { popoverVisible.value = true; } } @@ -173,19 +167,15 @@ function onContentMouseDown(e: MouseEvent) { /* 头部显示隐藏 开始 */ const visiableHeader = ref(false); function openHeader() { - if (!slots.header) - return false; + if (!slots.header) return false; - if (props.readOnly) - return false; + if (props.readOnly) return false; visiableHeader.value = true; } function closeHeader() { - if (!slots.header) - return; - if (props.readOnly) - return; + if (!slots.header) return; + if (props.readOnly) return; visiableHeader.value = false; } /* 头部显示隐藏 结束 */ @@ -195,8 +185,7 @@ const recognition = ref(null); const speechLoading = ref(false); function startRecognition() { - if (props.readOnly) - return; // 直接返回,不执行后续逻辑 + if (props.readOnly) return; // 直接返回,不执行后续逻辑 if (hasOnRecordingChangeListener.value) { speechLoading.value = true; emits('recordingChange', true); @@ -227,8 +216,7 @@ function startRecognition() { speechLoading.value = false; }; recognition.value.start(); - } - else { + } else { console.error('浏览器不支持 Web Speech API'); } } @@ -261,22 +249,19 @@ function submit() { } // 取消按钮 function cancel() { - if (props.readOnly) - return; + if (props.readOnly) return; emits('cancel', internalValue.value); } function clear() { - if (props.readOnly) - return; // 直接返回,不执行后续逻辑 + if (props.readOnly) return; // 直接返回,不执行后续逻辑 inputRef.value.clear(); internalValue.value = ''; } // 在这判断组合键的回车键 (目前支持四种模式) function handleKeyDown(e: { target: HTMLTextAreaElement } & KeyboardEvent) { - if (props.readOnly) - return; // 直接返回,不执行后续逻辑 + if (props.readOnly) return; // 直接返回,不执行后续逻辑 const _resetSelectionRange = () => { const cursorPosition = e.target.selectionStart; // 获取光标位置 const textBeforeCursor = internalValue.value.slice(0, cursorPosition); // 光标前的文本 @@ -307,8 +292,7 @@ function handleKeyDown(e: { target: HTMLTextAreaElement } & KeyboardEvent) { e.preventDefault(); if (props.submitType === 'enter') { _isComKeyDown ? _resetSelectionRange() : submit(); - } - else { + } else { _isComKeyDown ? submit() : _resetSelectionRange(); } } @@ -329,11 +313,9 @@ function focus(type = 'all') { } if (type === 'all') { inputRef.value.select(); - } - else if (type === 'start') { + } else if (type === 'start') { focusToStart(); - } - else if (type === 'end') { + } else if (type === 'end') { focusToEnd(); } } @@ -444,29 +426,31 @@ defineExpose({ - +
+ +