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() // 其他键盘事件 直接聚焦搜索框 } }) })