feat : update
This commit is contained in:
@@ -153,6 +153,7 @@ export async function updateGuideBasics(guideId: string, input: unknown) {
|
||||
...(data.posterArtMediaId !== undefined ? { posterArtMediaId } : {}),
|
||||
...(data.posterArtOffsetX !== undefined ? { posterArtOffsetX: Math.round(data.posterArtOffsetX) } : {}),
|
||||
...(data.posterArtOffsetY !== undefined ? { posterArtOffsetY: Math.round(data.posterArtOffsetY) } : {}),
|
||||
...(data.posterArtScale !== undefined ? { posterArtScale: Math.round(data.posterArtScale) } : {}),
|
||||
...(data.posterTopColors !== undefined ? { posterTopColors: data.posterTopColors } : {}),
|
||||
...(data.posterBottomColors !== undefined ? { posterBottomColors: data.posterBottomColors } : {}),
|
||||
}).where(eq(guides.id, guideId));
|
||||
@@ -168,6 +169,7 @@ export async function updateGuideBasics(guideId: string, input: unknown) {
|
||||
mediaId: layer.mediaId,
|
||||
amount: Math.round(layer.amount),
|
||||
scale: Math.round(layer.scale),
|
||||
blendMode: layer.blendMode,
|
||||
sortOrder,
|
||||
})));
|
||||
for (const layer of data.posterBleeding) {
|
||||
|
||||
@@ -27,8 +27,10 @@ import {
|
||||
} from "@/db/schema";
|
||||
import { getMediaStorage, publicMediaUrl } from "@/lib/media/storage";
|
||||
import { aliasesByItem } from "@/lib/glossary";
|
||||
import type { PosterBlendMode } from "@/components/public/material-poster";
|
||||
|
||||
const catalogVersionSchema = z.object({ version: z.string() });
|
||||
const posterBlendModes = new Set(["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"]);
|
||||
|
||||
function catalogCharacterWithUrls(
|
||||
item: typeof catalogCharacters.$inferSelect,
|
||||
@@ -140,7 +142,7 @@ export async function getGuideByCharacterKey(characterKey: string) {
|
||||
...row.guide,
|
||||
coverUrl: publicMediaUrl(row.cover.objectKey),
|
||||
posterArtUrl: poster[0] ? publicMediaUrl(poster[0].objectKey) : null,
|
||||
posterBleeding: bleeding.map(({ layer, asset }) => ({ ...layer, imageUrl: asset ? publicMediaUrl(asset.objectKey) : null })),
|
||||
posterBleeding: bleeding.map(({ layer, asset }) => ({ ...layer, blendMode: (posterBlendModes.has(layer.blendMode) ? layer.blendMode : "multiply") as PosterBlendMode, imageUrl: asset ? publicMediaUrl(asset.objectKey) : null })),
|
||||
character: catalogCharacterWithUrls(row.character, materialByKey),
|
||||
sections,
|
||||
};
|
||||
@@ -225,7 +227,7 @@ async function getGuideContent(slug: string, publicOnly: boolean) {
|
||||
...row.guide,
|
||||
coverUrl: publicMediaUrl(row.cover.objectKey),
|
||||
posterArtUrl: poster[0] ? publicMediaUrl(poster[0].objectKey) : null,
|
||||
posterBleeding: bleeding.map(({ layer, asset }) => ({ ...layer, imageUrl: asset ? publicMediaUrl(asset.objectKey) : null })),
|
||||
posterBleeding: bleeding.map(({ layer, asset }) => ({ ...layer, blendMode: (posterBlendModes.has(layer.blendMode) ? layer.blendMode : "multiply") as PosterBlendMode, imageUrl: asset ? publicMediaUrl(asset.objectKey) : null })),
|
||||
character: { ...catalogCharacterWithUrls(row.character, materialByKey), aliases: groupedAliases.character.get(row.character.key) ?? [] },
|
||||
elementIconUrls,
|
||||
sections,
|
||||
|
||||
@@ -39,12 +39,14 @@ export const updateGuideSchema = z.strictObject({
|
||||
posterArtMediaId: z.string().uuid().nullable().optional(),
|
||||
posterArtOffsetX: z.number().finite().min(-50).max(50).optional(),
|
||||
posterArtOffsetY: z.number().finite().min(-50).max(50).optional(),
|
||||
posterArtScale: z.number().finite().min(50).max(200).optional(),
|
||||
posterTopColors: z.tuple([z.string().regex(/^#[0-9a-fA-F]{6}$/u), z.string().regex(/^#[0-9a-fA-F]{6}$/u)]).optional(),
|
||||
posterBottomColors: z.tuple([z.string().regex(/^#[0-9a-fA-F]{6}$/u), z.string().regex(/^#[0-9a-fA-F]{6}$/u)]).optional(),
|
||||
posterBleeding: z.array(z.strictObject({
|
||||
mediaId: z.string().uuid(),
|
||||
amount: z.number().finite().min(0).max(100),
|
||||
scale: z.number().finite().min(25).max(300),
|
||||
blendMode: z.enum(["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"]),
|
||||
})).max(30).optional(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user