260629_02_ENH: PDF 미리보기 title 수정

This commit is contained in:
2026-06-29 12:26:08 +09:00
parent 6ce187bcf1
commit 83fd8567de
2 changed files with 13 additions and 6 deletions

View File

@@ -56,18 +56,25 @@ const getPdfTitleFromSrc = async (src: string) => {
} }
}; };
const getTitle = async (paramTitle: string, src: string, type: "image" | "pdf") => {
const defaultTitle = "파일 미리보기";
if(paramTitle) return paramTitle;
if(type === "pdf") return await getPdfTitleFromSrc(src) ?? defaultTitle;
return defaultTitle;
}
export default async function FilePreviewPage({ searchParams }: FilePreviewPageProps) { export default async function FilePreviewPage({ searchParams }: FilePreviewPageProps) {
const params = await searchParams; const params = await searchParams;
const images = parseImages(params.images); const images = parseImages(params.images);
const type = params.type ?? (images.length > 0 ? "image" : "pdf"); const type = params.type ?? (images.length > 0 ? "image" : "pdf");
const src = params.src ?? ""; const src = params.src ?? "";
const title = params.title ?? "파일 미리보기"; const title = await getTitle(params.title ?? "", src, type) ;
const headerTitle = type === "pdf" ? await getPdfTitleFromSrc(src) : title;
return ( return (
<main className="flex min-h-screen flex-col bg-background text-foreground"> <main className="flex min-h-screen flex-col bg-background text-foreground">
<header className="flex h-14 shrink-0 items-center justify-between border-b border-border bg-card px-4"> <header className="flex h-14 shrink-0 items-center justify-between border-b border-border bg-card px-4">
<h1 className="truncate text-base font-medium text-foreground">{headerTitle}</h1> <h1 className="truncate text-base font-medium text-foreground">{title}</h1>
</header> </header>
{type === "image" ? ( {type === "image" ? (
@@ -79,7 +86,7 @@ export default async function FilePreviewPage({ searchParams }: FilePreviewPageP
> >
<img <img
src={imageSrc} src={imageSrc}
alt={`${headerTitle} ${index + 1}`} alt={`${title} ${index + 1}`}
className="mx-auto max-h-[80vh] rounded border border-border bg-white object-contain" className="mx-auto max-h-[80vh] rounded border border-border bg-white object-contain"
/> />
<figcaption className="mt-2 truncate text-xs text-muted-foreground"> <figcaption className="mt-2 truncate text-xs text-muted-foreground">
@@ -94,7 +101,7 @@ export default async function FilePreviewPage({ searchParams }: FilePreviewPageP
)} )}
</div> </div>
) : isAllowedSrc(src) ? ( ) : isAllowedSrc(src) ? (
<iframe src={src} title={headerTitle} className="min-h-0 flex-1 bg-white" /> <iframe src={src} title={title} className="min-h-0 flex-1 bg-white" />
) : ( ) : (
<div className="flex flex-1 items-center justify-center text-sm text-muted-foreground"> <div className="flex flex-1 items-center justify-center text-sm text-muted-foreground">
미리보기 경로가 올바르지 않습니다. 미리보기 경로가 올바르지 않습니다.

View File

@@ -163,7 +163,7 @@ function ReviewFileActions({
const previewPdf = () => { const previewPdf = () => {
if (!pdfFileName || !userId) return; if (!pdfFileName || !userId) return;
openPreviewWindow(buildReviewPdfPreviewUrl(performanceId, reviewType, userId)); openPreviewWindow(buildReviewPdfPreviewUrl(performanceId, reviewType, userId, pdfFileName));
}; };
return ( return (