refactor(keyboard): optimize keyboard event handling and initialization

This commit is contained in:
pandadev 2025-03-05 17:45:01 +01:00
parent c3b31bdde6
commit a5fbea31a1
No known key found for this signature in database
GPG key ID: C39629DACB8E762F
3 changed files with 117 additions and 110 deletions

18
app.vue
View file

@ -6,18 +6,28 @@
<script setup lang="ts">
import { listen } from "@tauri-apps/api/event";
import { app, window } from "@tauri-apps/api";
import { window } from "@tauri-apps/api";
import { disable, enable } from "@tauri-apps/plugin-autostart";
import { onMounted } from "vue";
import { keyboard } from "wrdu-keyboard";
const keyboard = useKeyboard();
const { $settings } = useNuxtApp();
const router = useRouter();
keyboard.init();
router.beforeEach((to, from) => {
if (to.path !== from.path) {
keyboard.init();
}
});
router.afterEach(() => {
keyboard.clear();
});
onMounted(async () => {
await listen("settings", async () => {
keyboard.clear();
await navigateTo("/settings");
await app.show();
await window.getCurrentWindow().show();
});