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: '' })