diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 80e76d2..00e4411 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -258,7 +258,7 @@ async fn export_batch(images: Vec, watermark: WatermarkSettings None => input_path.file_name().unwrap_or_default() }; let output_path = Path::new(&output_dir).join(file_name); - let output_path = Path::new(&output_dir).join(file_name); + let _output_path = Path::new(&output_dir).join(file_name); // Handle format specific saving // JPEG does not support Alpha channel. If we save Rgba8 to Jpeg, it might fail or look wrong. diff --git a/src/App.vue b/src/App.vue index e449dde..c4d6740 100644 --- a/src/App.vue +++ b/src/App.vue @@ -6,11 +6,27 @@ import { useGalleryStore } from "./stores/gallery"; import { open } from '@tauri-apps/plugin-dialog'; import { invoke } from '@tauri-apps/api/core'; import { FolderOpen, Download } from 'lucide-vue-next'; -import { ref } from "vue"; +import { ref, onMounted, onUnmounted } from "vue"; const store = useGalleryStore(); const isExporting = ref(false); +function handleKeydown(event: KeyboardEvent) { + if (event.key === 'ArrowRight') { + store.nextImage(); + } else if (event.key === 'ArrowLeft') { + store.prevImage(); + } +} + +onMounted(() => { + window.addEventListener('keydown', handleKeydown); +}); + +onUnmounted(() => { + window.removeEventListener('keydown', handleKeydown); +}); + async function openFolder() { try { const selected = await open({ diff --git a/src/stores/gallery.ts b/src/stores/gallery.ts index d112b3d..f43a3c7 100644 --- a/src/stores/gallery.ts +++ b/src/stores/gallery.ts @@ -287,6 +287,18 @@ export const useGalleryStore = defineStore("gallery", () => { } } + function nextImage() { + if (images.value.length === 0) return; + const nextIndex = (selectedIndex.value + 1) % images.value.length; + selectImage(nextIndex); + } + + function prevImage() { + if (images.value.length === 0) return; + const prevIndex = (selectedIndex.value - 1 + images.value.length) % images.value.length; + selectImage(prevIndex); + } + return { images, selectedIndex, @@ -310,6 +322,8 @@ export const useGalleryStore = defineStore("gallery", () => { recalcAllWatermarks, processInpainting, processAllInpainting, - restoreImage + restoreImage, + nextImage, + prevImage }; });