返回 presentation-ai
previewSignature.ts
根目录 / src / hooks / presentation / previewSignature.ts
1 "use client";
2
3 // A small helper used to build a stable signature of a slide for memoization.
4 // Lives in hooks/presentation per request to centralize extra functions.
5 export function previewSignature(slide: unknown): string {
6 try {
7 const s = slide as {
8 id?: string;
9 content?: unknown;
10 alignment?: unknown;
11 layoutType?: unknown;
12 width?: unknown;
13 rootImage?: unknown;
14 bgColor?: unknown;
15 formatCategory?: unknown;
16 aspectRatio?: unknown;
17 };
18 return JSON.stringify({
19 id: s?.id,
20 content: s?.content,
21 alignment: s?.alignment,
22 layoutType: s?.layoutType,
23 width: s?.width,
24 rootImage: s?.rootImage,
25 bgColor: s?.bgColor,
26 formatCategory: s?.formatCategory,
27 aspectRatio: s?.aspectRatio,
28 });
29 } catch {
30 return "";
31 }
32 }
33
33 lines TYPESCRIPT