From 4a48da96125c8be2126a1542c0b370e85fb43923 Mon Sep 17 00:00:00 2001 From: ZiuChen <457353192@qq.com> Date: Tue, 16 Aug 2022 12:19:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BF=9B=E5=85=A5=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=90=8E=E8=87=AA=E5=8A=A8=E6=BB=9A=E5=8A=A8=E5=88=B0=E9=A1=B6?= =?UTF-8?q?=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/preload.js | 8 +++++++- src/views/Main.vue | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/public/preload.js b/public/preload.js index cf33e7a..8463ed5 100644 --- a/public/preload.js +++ b/public/preload.js @@ -178,6 +178,8 @@ const paste = () => { const focus = () => document.querySelector('.clip-search input')?.focus() +const toTop = () => (document.scrollingElement.scrollTop = 0) + const db = new DB(DBPath) db.init() @@ -194,7 +196,10 @@ watchClipboard(db, (item) => { db.addItem(item) }) -utools.onPluginEnter(() => focus()) +utools.onPluginEnter(() => { + focus() + toTop() +}) window.db = db window.copy = copy @@ -202,3 +207,4 @@ window.paste = paste window.openFile = utools.shellOpenPath window.getIcon = utools.getFileIcon window.focus = focus +window.toTop = toTop diff --git a/src/views/Main.vue b/src/views/Main.vue index fef14d6..a64df65 100644 --- a/src/views/Main.vue +++ b/src/views/Main.vue @@ -56,7 +56,7 @@ const updateShowList = (type) => { .filter((item) => item.data.indexOf(filterText.value) !== -1) .slice(0, GAP) } - document.scrollingElement.scrollTop = 0 + window.toTop() } const fullData = ref({ type: 'text', data: '' })