|
|
@ -61,9 +61,12 @@ onMounted(() => {
|
|
|
|
|
|
|
|
|
|
|
|
preconnect()
|
|
|
|
preconnect()
|
|
|
|
|
|
|
|
|
|
|
|
const handleSearchHotKey = (e: KeyboardEvent) => {
|
|
|
|
const handleSearchHotKey = (event: KeyboardEvent) => {
|
|
|
|
if (e.key === 'k' && (e.ctrlKey || e.metaKey)) {
|
|
|
|
if (
|
|
|
|
e.preventDefault()
|
|
|
|
(event.key.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey)) ||
|
|
|
|
|
|
|
|
(!isEditingContent(event) && event.key === '/')
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
event.preventDefault()
|
|
|
|
load()
|
|
|
|
load()
|
|
|
|
remove()
|
|
|
|
remove()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -101,6 +104,18 @@ function poll() {
|
|
|
|
}, 16)
|
|
|
|
}, 16)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isEditingContent(event: KeyboardEvent): boolean {
|
|
|
|
|
|
|
|
const element = event.target as HTMLElement
|
|
|
|
|
|
|
|
const tagName = element.tagName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
element.isContentEditable ||
|
|
|
|
|
|
|
|
tagName === 'INPUT' ||
|
|
|
|
|
|
|
|
tagName === 'SELECT' ||
|
|
|
|
|
|
|
|
tagName === 'TEXTAREA'
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Local search
|
|
|
|
// Local search
|
|
|
|
|
|
|
|
|
|
|
|
const showSearch = ref(false)
|
|
|
|
const showSearch = ref(false)
|
|
|
@ -112,6 +127,13 @@ if (__VP_LOCAL_SEARCH__) {
|
|
|
|
showSearch.value = true
|
|
|
|
showSearch.value = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onKeyStroke('/', (event) => {
|
|
|
|
|
|
|
|
if (!isEditingContent(event)) {
|
|
|
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
showSearch.value = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const metaKey = ref(`'Meta'`)
|
|
|
|
const metaKey = ref(`'Meta'`)
|
|
|
|