fix: zoom using CSS + cleanup
This commit is contained in:
@@ -418,11 +418,6 @@ async fn unbind_face(uuid: String, face_id: String, file_uuid: String) -> Result
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(rename_all = "camelCase")]
|
|
||||||
async fn set_zoom(window: tauri::WebviewWindow, zoom_factor: f64) -> Result<(), String> {
|
|
||||||
window.set_zoom(zoom_factor).map_err(|e| e.to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
@@ -442,8 +437,7 @@ fn main() {
|
|||||||
get_face_candidates,
|
get_face_candidates,
|
||||||
merge_identities,
|
merge_identities,
|
||||||
bind_face,
|
bind_face,
|
||||||
unbind_face,
|
unbind_face
|
||||||
set_zoom
|
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|||||||
15
src/App.vue
15
src/App.vue
@@ -34,24 +34,23 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, onUnmounted, ref } from 'vue'
|
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) {
|
function handleKeydown(e: KeyboardEvent) {
|
||||||
if ((e.metaKey || e.ctrlKey)) {
|
if ((e.metaKey || e.ctrlKey)) {
|
||||||
if (e.key === '=' || e.key === '+') {
|
if (e.key === '=' || e.key === '+') {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
currentZoom.value = Math.min(currentZoom.value + 0.1, 3.0)
|
appZoom.value = Math.min(appZoom.value + 10, 300)
|
||||||
invoke('set_zoom', { zoomFactor: currentZoom.value }).catch(() => {})
|
document.documentElement.style.zoom = appZoom.value + '%'
|
||||||
} else if (e.key === '-') {
|
} else if (e.key === '-') {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
currentZoom.value = Math.max(currentZoom.value - 0.1, 0.5)
|
appZoom.value = Math.max(appZoom.value - 10, 50)
|
||||||
invoke('set_zoom', { zoomFactor: currentZoom.value }).catch(() => {})
|
document.documentElement.style.zoom = appZoom.value + '%'
|
||||||
} else if (e.key === '0') {
|
} else if (e.key === '0') {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
currentZoom.value = 1.0
|
appZoom.value = 100
|
||||||
invoke('set_zoom', { zoomFactor: 1.0 }).catch(() => {})
|
document.documentElement.style.zoom = '100%'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user