From fd11c4f3239677a5093b043f69216c2efce29169 Mon Sep 17 00:00:00 2001 From: liushilong <2224574157@qq.com> Date: Tue, 26 Mar 2024 18:36:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=A8=E5=B1=80=E7=83=AD=E9=94=AE?= =?UTF-8?q?=E7=9B=91=E5=90=AC10%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 5 +++++ src/hooks/event/mouseTrapBind.ts | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/hooks/event/mouseTrapBind.ts diff --git a/src/App.vue b/src/App.vue index 0a0737b..08ae4e4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,6 +3,11 @@ import { dateZhCN, zhCN } from "naive-ui"; import { computed, onMounted, nextTick } from "vue"; import { AppProvider } from "@/components/Application"; import { lighten } from "@/utils/index"; +import mouseTrapBind from '@/hooks/event/mouseTrapBind' + +onMounted(()=>{ + mouseTrapBind(); +}) const getThemeOverrides = computed(() => { const theme = "#1980FF"; diff --git a/src/hooks/event/mouseTrapBind.ts b/src/hooks/event/mouseTrapBind.ts new file mode 100644 index 0000000..b964ae6 --- /dev/null +++ b/src/hooks/event/mouseTrapBind.ts @@ -0,0 +1,14 @@ +import { inject } from 'vue' +const mousetrap = inject('mousetrap') as any +const commonKeyDown = (keyCode: number) => { + document.dispatchEvent(new KeyboardEvent('keydown', { keyCode })); +} +const c = () => { + commonKeyDown(27) +} + +const initBind = () => { + mousetrap.bind('c', c) +} + +export default initBind; \ No newline at end of file