fix: prevent default browser action for ctrl + k key combination in RouterSearch component

- 阻止 RouterSearch 组件中 ctrl + k 组合键的默认浏览器操作
This commit is contained in:
AhJindeg
2024-12-17 16:30:58 +08:00
parent 8362665f2b
commit 413721bdfd

View File

@ -98,6 +98,8 @@ onUnmounted(() => {
// 监听 ctrl + k
function listenKey(event) {
if ((event.ctrlKey || event.metaKey) && event.key === 'k') {
// 阻止触发浏览器默认事件
event.preventDefault()
showSearch.value = !showSearch.value
// 这里可以执行相应的操作(例如打开搜索框等)
}