Fix prop confirmation bug, add Wan 2.7 model, refine multiple UI details, improve prop generation quality and aspect ratio, remove text overlays from Asset Center created images, and optimize prop filtering logic

This commit is contained in:
saturn
2026-04-03 22:36:41 +08:00
parent 854b932e67
commit 78b93331b4
136 changed files with 3393 additions and 875 deletions

View File

@@ -0,0 +1,75 @@
import { ApiError } from '@/lib/api-errors'
import { prisma } from '@/lib/prisma'
import { deleteObject } from '@/lib/storage'
import { resolveStorageKeyFromMediaValue } from '@/lib/media/service'
export async function confirmProjectLocationBackedSelection(assetId: string): Promise<{ success: true }> {
const location = await prisma.novelPromotionLocation.findUnique({
where: { id: assetId },
include: { images: { orderBy: { imageIndex: 'asc' } } },
})
if (!location) {
throw new ApiError('NOT_FOUND')
}
const selectedImage = location.selectedImageId
? location.images.find((image) => image.id === location.selectedImageId)
: location.images.find((image) => image.isSelected)
if (location.images.length <= 1) {
const onlyImage = location.images[0] ?? null
if (onlyImage) {
await prisma.$transaction(async (tx) => {
await tx.locationImage.update({
where: { id: onlyImage.id },
data: {
imageIndex: 0,
isSelected: true,
},
})
await tx.novelPromotionLocation.update({
where: { id: assetId },
data: { selectedImageId: onlyImage.id },
})
})
}
return { success: true }
}
if (!selectedImage || !selectedImage.imageUrl) {
throw new ApiError('INVALID_PARAMS')
}
const imagesToDelete = location.images.filter((image) => image.id !== selectedImage.id)
for (const image of imagesToDelete) {
if (!image.imageUrl) continue
const storageKey = await resolveStorageKeyFromMediaValue(image.imageUrl)
if (!storageKey) continue
try {
await deleteObject(storageKey)
} catch {
}
}
await prisma.$transaction(async (tx) => {
await tx.locationImage.deleteMany({
where: {
locationId: assetId,
id: { not: selectedImage.id },
},
})
await tx.locationImage.update({
where: { id: selectedImage.id },
data: {
imageIndex: 0,
isSelected: true,
},
})
await tx.novelPromotionLocation.update({
where: { id: assetId },
data: { selectedImageId: selectedImage.id },
})
})
return { success: true }
}