From 9c0e7518f8991b08c1c5b53c96fe7e91f66bd77d Mon Sep 17 00:00:00 2001 From: hisoka0728 <1399952343@qq.com> Date: Wed, 11 Sep 2024 09:54:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E5=9B=9E=E8=BD=A6=E6=97=B6=E6=8E=A7=E5=88=B6=E5=8F=B0?= =?UTF-8?q?=E6=8A=A5=E9=94=99,=E8=B0=83=E6=95=B4=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E8=AE=A1=E6=95=B0=E6=96=87=E6=9C=AC=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editor/text-box/input/input.scss | 4 ++++ src/editor/text-box/input/input.tsx | 32 ++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/editor/text-box/input/input.scss b/src/editor/text-box/input/input.scss index fe08edf67..7b962b7c7 100644 --- a/src/editor/text-box/input/input.scss +++ b/src/editor/text-box/input/input.scss @@ -47,6 +47,10 @@ $input: ( @include overflow-wrap; } + .el-input__count{ + bottom: 0; + } + @include b(input-input) { height: 100%; diff --git a/src/editor/text-box/input/input.tsx b/src/editor/text-box/input/input.tsx index 905fbc208..0c37bbda7 100644 --- a/src/editor/text-box/input/input.tsx +++ b/src/editor/text-box/input/input.tsx @@ -1,5 +1,6 @@ /* eslint-disable no-nested-ternary */ import { computed, defineComponent, onUnmounted, ref, watch } from 'vue'; +import { debounce } from 'lodash-es'; import { getEditorEmits, getInputProps, @@ -125,6 +126,8 @@ export const IBizInput = defineComponent({ } }; + let isDebounce = false; + let awaitSearch: () => void; let blurCacheValue: string | undefined; // 值变更 const handleChange = (val: string | number) => { @@ -135,18 +138,35 @@ export const IBizInput = defineComponent({ blurCacheValue = undefined; }; + const debounceChange = debounce( + (val: string | number) => { + // 拦截掉blur触发后change + if (blurCacheValue !== val) { + onEmit(val, 'input'); + } + blurCacheValue = undefined; + isDebounce = false; + if (awaitSearch) { + awaitSearch(); + } + }, + 300, + { leading: true }, + ); + const handleInput = (val: string | number) => { - // 拦截掉blur触发后change - if (blurCacheValue !== val) { - onEmit(val, 'input'); - } - blurCacheValue = undefined; + isDebounce = true; + debounceChange(val); }; const handleKeyUp = (e: KeyboardEvent) => { if (e && e.code === 'Enter') { emit('enter', e); - editorRef.value.$el.dispatchEvent(e); + if (isDebounce) { + awaitSearch = () => { + editorRef.value.$el.dispatchEvent(e); + }; + } } }; -- Gitee