260629_02_ENH: PDF 미리보기 title 수정
This commit is contained in:
@@ -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) {
|
||||
const params = await searchParams;
|
||||
const images = parseImages(params.images);
|
||||
const type = params.type ?? (images.length > 0 ? "image" : "pdf");
|
||||
const src = params.src ?? "";
|
||||
const title = params.title ?? "파일 미리보기";
|
||||
const headerTitle = type === "pdf" ? await getPdfTitleFromSrc(src) : title;
|
||||
const title = await getTitle(params.title ?? "", src, type) ;
|
||||
|
||||
return (
|
||||
<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">
|
||||
<h1 className="truncate text-base font-medium text-foreground">{headerTitle}</h1>
|
||||
<h1 className="truncate text-base font-medium text-foreground">{title}</h1>
|
||||
</header>
|
||||
|
||||
{type === "image" ? (
|
||||
@@ -79,7 +86,7 @@ export default async function FilePreviewPage({ searchParams }: FilePreviewPageP
|
||||
>
|
||||
<img
|
||||
src={imageSrc}
|
||||
alt={`${headerTitle} ${index + 1}`}
|
||||
alt={`${title} ${index + 1}`}
|
||||
className="mx-auto max-h-[80vh] rounded border border-border bg-white object-contain"
|
||||
/>
|
||||
<figcaption className="mt-2 truncate text-xs text-muted-foreground">
|
||||
@@ -94,7 +101,7 @@ export default async function FilePreviewPage({ searchParams }: FilePreviewPageP
|
||||
)}
|
||||
</div>
|
||||
) : 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">
|
||||
미리보기 경로가 올바르지 않습니다.
|
||||
|
||||
@@ -163,7 +163,7 @@ function ReviewFileActions({
|
||||
|
||||
const previewPdf = () => {
|
||||
if (!pdfFileName || !userId) return;
|
||||
openPreviewWindow(buildReviewPdfPreviewUrl(performanceId, reviewType, userId));
|
||||
openPreviewWindow(buildReviewPdfPreviewUrl(performanceId, reviewType, userId, pdfFileName));
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user