新增 现在参考图可以拖动排序了;

修复 双参考图生成结果显示问题;
This commit is contained in:
2025-09-22 22:39:45 +08:00
parent 690a530031
commit 260a7e4f0f
6 changed files with 430 additions and 192 deletions

View File

@@ -94,6 +94,7 @@ interface AppState {
addUploadedImage: (url: string) => void;
removeUploadedImage: (index: number) => void;
reorderUploadedImage: (fromIndex: number, toIndex: number) => void;
clearUploadedImages: () => void;
addEditReferenceImage: (url: string) => void;
@@ -194,6 +195,12 @@ export const useAppStore = create<AppState>()(
uploadedImages: state.uploadedImages.filter((_, i) => i !== index)
};
}),
reorderUploadedImage: (fromIndex, toIndex) => set((state) => {
const newUploadedImages = [...state.uploadedImages];
const [movedItem] = newUploadedImages.splice(fromIndex, 1);
newUploadedImages.splice(toIndex, 0, movedItem);
return { uploadedImages: newUploadedImages };
}),
clearUploadedImages: () => set((state) => {
// 删除所有存储在IndexedDB中的参考图像
state.uploadedImages.forEach(imageUrl => {
@@ -557,19 +564,27 @@ export const useAppStore = create<AppState>()(
}),
// 释放指定的Blob URLs
revokeBlobUrls: () => set((state) => {
// 不再自动清理Blob URL,以确保参考图像不会被意外删除
// 只有在用户明确请求清除会话时才清理
console.log('Blob清理已禁用参考图像将被永久保留');
return state;
revokeBlobUrls: (urls: string[]) => set((state) => {
// 清理指定的Blob URL
const newBlobStore = new Map(state.blobStore);
urls.forEach(url => {
if (url.startsWith('blob:')) {
URL.revokeObjectURL(url);
newBlobStore.delete(url);
}
});
return { blobStore: newBlobStore };
}),
// 释放所有Blob URLs
cleanupAllBlobUrls: () => set((state) => {
// 不再自动清理Blob URL,以确保参考图像不会被意外删除
// 只有在用户明确请求清除会话时才清理
console.log('Blob清理已禁用,参考图像将被永久保留');
return state;
// 清理所有Blob URL
state.blobStore.forEach((blob, url) => {
if (url.startsWith('blob:')) {
URL.revokeObjectURL(url);
}
});
return { blobStore: new Map() };
}),
// 定期清理Blob URL