feat: 进入插件后自动滚动到顶部

This commit is contained in:
ZiuChen 2022-08-16 12:19:27 +08:00
parent 527d0518ba
commit 4a48da9612
2 changed files with 8 additions and 2 deletions

View File

@ -178,6 +178,8 @@ const paste = () => {
const focus = () => document.querySelector('.clip-search input')?.focus() const focus = () => document.querySelector('.clip-search input')?.focus()
const toTop = () => (document.scrollingElement.scrollTop = 0)
const db = new DB(DBPath) const db = new DB(DBPath)
db.init() db.init()
@ -194,7 +196,10 @@ watchClipboard(db, (item) => {
db.addItem(item) db.addItem(item)
}) })
utools.onPluginEnter(() => focus()) utools.onPluginEnter(() => {
focus()
toTop()
})
window.db = db window.db = db
window.copy = copy window.copy = copy
@ -202,3 +207,4 @@ window.paste = paste
window.openFile = utools.shellOpenPath window.openFile = utools.shellOpenPath
window.getIcon = utools.getFileIcon window.getIcon = utools.getFileIcon
window.focus = focus window.focus = focus
window.toTop = toTop

View File

@ -56,7 +56,7 @@ const updateShowList = (type) => {
.filter((item) => item.data.indexOf(filterText.value) !== -1) .filter((item) => item.data.indexOf(filterText.value) !== -1)
.slice(0, GAP) .slice(0, GAP)
} }
document.scrollingElement.scrollTop = 0 window.toTop()
} }
const fullData = ref({ type: 'text', data: '' }) const fullData = ref({ type: 'text', data: '' })