From 0444f4c56e37e1336103dfcfa802392a4f289fe3 Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Sun, 24 Sep 2023 21:52:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=BF=E6=8D=A2Input=E3=80=81Mes?= =?UTF-8?q?sage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Input.vue | 32 +++++++++++++++++-- src/components/NumberInput.vue | 21 ++++++++++-- src/plugins/directive/message.ts | 0 src/utils/message.ts | 2 +- src/views/Editor/Canvas/LinkDialog.vue | 2 +- src/views/Editor/CanvasTool/MediaInput.vue | 8 ++--- .../Editor/CanvasTool/TableGenerator.vue | 2 +- src/views/Editor/EditorHeader/index.vue | 8 ++--- src/views/Editor/SearchPanel.vue | 9 +++--- .../ElementStylePanel/TextStylePanel.vue | 14 ++++---- .../Editor/Toolbar/SlideAnimationPanel.vue | 3 +- 11 files changed, 72 insertions(+), 29 deletions(-) delete mode 100644 src/plugins/directive/message.ts diff --git a/src/components/Input.vue b/src/components/Input.vue index afaf89ac..5a583de5 100644 --- a/src/components/Input.vue +++ b/src/components/Input.vue @@ -11,12 +11,15 @@ @@ -38,13 +41,36 @@ withDefaults(defineProps<{ const emit = defineEmits<{ (event: 'update:value', payload: string): void + (event: 'input', payload: Event): void + (event: 'change', payload: Event): void + (event: 'blur', payload: Event): void + (event: 'focus', payload: Event): void + (event: 'enter', payload: Event): void }>() const focused = ref(false) const handleInput = (e: Event) => { emit('update:value', (e.target as HTMLInputElement).value) + emit('input', e) } +const handleBlur = (e: Event) => { + focused.value = false + emit('blur', e) +} +const handleFocus = (e: Event) => { + focused.value = true + emit('focus', e) +} + +const inputRef = ref() +const focus = () => { + if (inputRef.value) inputRef.value.focus() +} + +defineExpose({ + focus, +})