support restore

This commit is contained in:
Julian Freeman
2026-01-19 12:18:08 -04:00
parent f96033e421
commit 6439759b04
2 changed files with 26 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
<script setup lang="ts">
import { useGalleryStore } from "../stores/gallery";
import { Settings, CheckSquare, Type, Palette, Copy, Eraser, PlusSquare, Brush, Sparkles, Trash2, RotateCw } from 'lucide-vue-next';
import { Settings, CheckSquare, Type, Palette, Copy, Eraser, PlusSquare, Brush, Sparkles, Trash2, RotateCw, RotateCcw } from 'lucide-vue-next';
import { computed } from "vue";
const store = useGalleryStore();
@@ -227,6 +227,15 @@ const applyAll = () => {
<Eraser class="w-5 h-5" />
执行移除
</button>
<button
v-if="store.selectedImage && store.selectedImage.path !== store.selectedImage.originalPath"
@click="store.selectedIndex >= 0 && store.restoreImage(store.selectedIndex)"
class="w-full bg-gray-700 hover:bg-gray-600 text-gray-300 py-2 rounded text-sm transition-colors flex items-center justify-center gap-2"
>
<RotateCcw class="w-4 h-4" />
还原原图
</button>
</div>
</div>

View File

@@ -11,6 +11,7 @@ export interface MaskStroke {
export interface ImageItem {
path: string;
originalPath: string;
thumbnail: string;
name: string;
width?: number;
@@ -59,10 +60,22 @@ export const useGalleryStore = defineStore("gallery", () => {
});
function setImages(newImages: ImageItem[]) {
images.value = newImages;
images.value = newImages.map(img => ({
...img,
// Ensure originalPath is set if not already present from backend
originalPath: img.originalPath || img.path
}));
selectedIndex.value = -1;
}
function restoreImage(index: number) {
const img = images.value[index];
if (img) {
img.path = img.originalPath;
img.maskStrokes = []; // Also clear any masks if restoring
}
}
function updateWatermarkSettings(settings: Partial<WatermarkSettings>) {
watermarkSettings.value = { ...watermarkSettings.value, ...settings };
}
@@ -238,6 +251,7 @@ export const useGalleryStore = defineStore("gallery", () => {
clearMask,
detectAllWatermarks,
recalcAllWatermarks,
processInpainting
processInpainting,
restoreImage
};
});