feat: 修复热键监听导致的问题

pull/1/head
刘释隆 1 year ago
parent fd11c4f323
commit f6544852d0

@ -1,12 +1,12 @@
<script lang="ts" setup> <script lang="ts" setup>
import { dateZhCN, zhCN } from "naive-ui"; import { dateZhCN, zhCN } from "naive-ui";
import { computed, onMounted, nextTick } from "vue"; import { computed, onMounted, nextTick,inject } from "vue";
import { AppProvider } from "@/components/Application"; import { AppProvider } from "@/components/Application";
import { lighten } from "@/utils/index"; import { lighten } from "@/utils/index";
import mouseTrapBind from '@/hooks/event/mouseTrapBind' import mouseTrapBind from '@/hooks/event/mouseTrapBind'
const mousetrap = inject('mousetrap') as any
onMounted(()=>{ onMounted(()=>{
mouseTrapBind(); mouseTrapBind(mousetrap);
}) })
const getThemeOverrides = computed(() => { const getThemeOverrides = computed(() => {

@ -1,13 +1,10 @@
import { inject } from 'vue'
const mousetrap = inject('mousetrap') as any
const commonKeyDown = (keyCode: number) => { const commonKeyDown = (keyCode: number) => {
document.dispatchEvent(new KeyboardEvent('keydown', { keyCode })); document.dispatchEvent(new KeyboardEvent('keydown', { keyCode }));
} }
const c = () => { const c = () => {
commonKeyDown(27) commonKeyDown(27)
} }
const initBind = (mousetrap) => {
const initBind = () => {
mousetrap.bind('c', c) mousetrap.bind('c', c)
} }

Loading…
Cancel
Save