fix: zoom using CSS + cleanup

This commit is contained in:
2026-06-14 23:33:05 +08:00
parent 2544ab36b5
commit 11b3b4b395
2 changed files with 8 additions and 15 deletions

View File

@@ -34,24 +34,23 @@
<script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue'
import { invoke } from '@tauri-apps/api/core'
let currentZoom = ref(1.0)
const appZoom = ref(100)
function handleKeydown(e: KeyboardEvent) {
if ((e.metaKey || e.ctrlKey)) {
if (e.key === '=' || e.key === '+') {
e.preventDefault()
currentZoom.value = Math.min(currentZoom.value + 0.1, 3.0)
invoke('set_zoom', { zoomFactor: currentZoom.value }).catch(() => {})
appZoom.value = Math.min(appZoom.value + 10, 300)
document.documentElement.style.zoom = appZoom.value + '%'
} else if (e.key === '-') {
e.preventDefault()
currentZoom.value = Math.max(currentZoom.value - 0.1, 0.5)
invoke('set_zoom', { zoomFactor: currentZoom.value }).catch(() => {})
appZoom.value = Math.max(appZoom.value - 10, 50)
document.documentElement.style.zoom = appZoom.value + '%'
} else if (e.key === '0') {
e.preventDefault()
currentZoom.value = 1.0
invoke('set_zoom', { zoomFactor: 1.0 }).catch(() => {})
appZoom.value = 100
document.documentElement.style.zoom = '100%'
}
}
}