fix: 键盘事件触发也会focus 搜索框聚焦统一调用window.focus方法

This commit is contained in:
ZiuChen 2022-08-16 11:57:51 +08:00
parent c1aac6553e
commit f110bc5dda
3 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -1,6 +1,6 @@
<template>
<div class="clip-search">
<input v-model="filterText" autofocus type="text" placeholder="🔍 检索剪贴板历史" />
<input v-model="filterText" type="text" placeholder="🔍 检索剪贴板历史" />
</div>
</template>

View File

@ -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() //
}
})
})