Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/feature/album/4cut/components/ScreenAlbum4Cut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useQueryClient } from '@tanstack/react-query';
import { Download, Loader2, LucideIcon, Menu, Send } from 'lucide-react';
import dynamic from 'next/dynamic';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { useEffect, useRef, useState } from 'react';
import { useGetAlbumInfo } from '../../detail/hooks/useGetAlbumInfo';
import { use4CutAiSummary } from '../hooks/use4CutAiSummary';
Expand All @@ -37,11 +38,34 @@ interface ScreenAlbum4CutProps {
}

export default function ScreenAlbum4Cut({ albumId }: ScreenAlbum4CutProps) {
const router = useRouter();
const queryClient = useQueryClient();
const [isCaptureVisible, setIsCaptureVisible] = useState(false);
const [isDownloading, setIsDownloading] = useState(false);
const [showExplanation, setShowExplanation] = useState(false);
const captureRef = useRef<HTMLDivElement>(null);

const handleBackClick = () => {
if (typeof window === 'undefined') return;
// 공유 링크 등 외부 유입 시 외부 사이트로 되돌아가는 것을 방지합니다.
const isNewTab = window.history.length <= 1 || !document.referrer;
// referrer가 우리 서비스 origin일 때만 안전한 내부 이동으로 봅니다.
const isInternalReferrer = (() => {
if (!document.referrer) return false;
try {
return new URL(document.referrer).origin === window.location.origin;
} catch {
return false;
}
})();

if (isNewTab || !isInternalReferrer) {
// 히스토리/리퍼러가 신뢰되지 않으면 안전한 내부 경로로 보냅니다.
router.push('/main');
} else {
router.back();
}
};
Comment thread
dasosann marked this conversation as resolved.
const { data } = useGetAlbumInfo(albumId);
const { data: albumInformData } = useGetAlbumInform({ code: albumId });
const { data: { name } = {} } = useGetUserMe();
Expand Down Expand Up @@ -201,6 +225,7 @@ export default function ScreenAlbum4Cut({ albumId }: ScreenAlbum4CutProps) {
<>
<CustomHeader
isShowBack
onBackClick={handleBackClick}
title={data?.title ?? ''}
rightContent={
<div className='flex gap-4'>
Expand Down
Loading