From f110bc5dda4351696eef9990c7591d59870da017 Mon Sep 17 00:00:00 2001 From: ZiuChen <457353192@qq.com> Date: Tue, 16 Aug 2022 11:57:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=94=AE=E7=9B=98=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E4=B9=9F=E4=BC=9Afocus=20=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=A1=86=E8=81=9A=E7=84=A6=E7=BB=9F=E4=B8=80=E8=B0=83=E7=94=A8?= =?UTF-8?q?window.focus=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/preload.js | 5 +++++ src/cpns/ClipSearch.vue | 2 +- src/views/Main.vue | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/public/preload.js b/public/preload.js index 7934abe..cf33e7a 100644 --- a/public/preload.js +++ b/public/preload.js @@ -176,6 +176,8 @@ const paste = () => { } } +const focus = () => document.querySelector('.clip-search input')?.focus() + const db = new DB(DBPath) db.init() @@ -192,8 +194,11 @@ watchClipboard(db, (item) => { db.addItem(item) }) +utools.onPluginEnter(() => focus()) + window.db = db window.copy = copy window.paste = paste window.openFile = utools.shellOpenPath window.getIcon = utools.getFileIcon +window.focus = focus diff --git a/src/cpns/ClipSearch.vue b/src/cpns/ClipSearch.vue index d4a23c8..7dc8048 100644 --- a/src/cpns/ClipSearch.vue +++ b/src/cpns/ClipSearch.vue @@ -1,6 +1,6 @@ diff --git a/src/views/Main.vue b/src/views/Main.vue index 5108248..fef14d6 100644 --- a/src/views/Main.vue +++ b/src/views/Main.vue @@ -143,9 +143,11 @@ onMounted(() => { const target = index === list.length - 1 ? list[0] : list[index + 1] updateShowList(target) } else if (isSearch) { - document.querySelector('input').focus() + window.focus() } else if (isExit) { filterText.value = '' + } else { + window.focus() // 其他键盘事件 直接聚焦搜索框 } }) })