valaxy-theme-yun 0.13.1 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
2
|
import { computed } from '@vue/reactivity'
|
3
3
|
import { useSiteConfig } from 'valaxy'
|
4
|
-
import {
|
4
|
+
import { ref, watch } from 'vue'
|
5
5
|
import { useI18n } from 'vue-i18n'
|
6
6
|
import { useMagicKeys } from '@vueuse/core'
|
7
7
|
|
@@ -20,49 +20,19 @@ function load() {
|
|
20
20
|
|
21
21
|
const isAlgolia = computed(() => siteConfig.value.search.type === 'algolia')
|
22
22
|
|
23
|
-
onMounted(() => {
|
24
|
-
if (!isAlgolia.value)
|
25
|
-
return
|
26
|
-
|
27
|
-
const handleSearchHotKey = (e: KeyboardEvent) => {
|
28
|
-
if (e.key === 'k' && (e.ctrlKey || e.metaKey)) {
|
29
|
-
e.preventDefault()
|
30
|
-
load()
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
32
|
-
remove()
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
const remove = () => {
|
37
|
-
window.removeEventListener('keydown', handleSearchHotKey)
|
38
|
-
}
|
39
|
-
|
40
|
-
window.addEventListener('keydown', handleSearchHotKey)
|
41
|
-
|
42
|
-
onUnmounted(remove)
|
43
|
-
})
|
44
|
-
|
45
23
|
const open = ref(false)
|
46
24
|
|
47
|
-
const trigger = () => {
|
48
|
-
// todo, refactor shortcut
|
49
|
-
const e = new Event('keydown') as any
|
50
|
-
|
51
|
-
e.key = 'k'
|
52
|
-
e.metaKey = true
|
53
|
-
}
|
54
|
-
|
55
25
|
const togglePopup = () => {
|
56
26
|
open.value = !open.value
|
57
|
-
|
58
|
-
trigger()
|
59
27
|
}
|
60
28
|
|
61
29
|
const { Meta_K } = useMagicKeys()
|
62
30
|
|
63
31
|
watch(Meta_K, (val) => {
|
64
|
-
if (val)
|
32
|
+
if (val) {
|
65
33
|
togglePopup()
|
34
|
+
load()
|
35
|
+
}
|
66
36
|
})
|
67
37
|
</script>
|
68
38
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "valaxy-theme-yun",
|
3
|
-
"version": "0.13.
|
3
|
+
"version": "0.13.3",
|
4
4
|
"author": {
|
5
5
|
"email": "me@yunyoujun.cn",
|
6
6
|
"name": "YunYouJun",
|
@@ -22,6 +22,6 @@
|
|
22
22
|
"valaxy-addon-waline": "0.0.9"
|
23
23
|
},
|
24
24
|
"devDependencies": {
|
25
|
-
"valaxy": "0.13.
|
25
|
+
"valaxy": "0.13.3"
|
26
26
|
}
|
27
27
|
}
|