fix: 공유하기 수정

This commit is contained in:
김성경 2026-08-20 16:35:17 +09:00
parent bdb581459d
commit 0d3167c1a2
6 changed files with 23 additions and 15 deletions

View File

@ -7,6 +7,7 @@ interface ContentCardSocialActionsProps {
videoId: number;
storeName: string;
region?: string;
title?: string | null;
commentCount: number;
initialLikeCount: number;
initialIsLiked?: boolean;
@ -15,7 +16,7 @@ interface ContentCardSocialActionsProps {
const ContentCardSocialActions: React.FC<ContentCardSocialActionsProps> = ({
videoId,
storeName,
region,
title,
commentCount,
initialLikeCount,
initialIsLiked = false,
@ -27,15 +28,13 @@ const ContentCardSocialActions: React.FC<ContentCardSocialActionsProps> = ({
const likeDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const shareUrl = buildVideoShareUrl(API_URL, videoId);
const shareTitle = storeName || t('videoDetail.kakaoDefaultTitle');
const shareDescription = t('videoDetail.kakaoDescription', { region: region ?? '' });
const shareTitle = title || storeName || t('videoDetail.kakaoDefaultTitle');
const handleShareBtnClick = async (e: React.MouseEvent) => {
e.stopPropagation();
const handled = await tryNativeShare({
title: shareTitle,
text: shareDescription,
url: shareUrl,
});
if (handled) {

View File

@ -103,26 +103,27 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
};
const shareUrl = buildVideoShareUrl(API_URL, videoId);
const shareTitle = video?.store_name ?? t('videoDetail.kakaoDefaultTitle');
const shareDescription = t('videoDetail.kakaoDescription', { region: video?.region ?? '' });
const shareTitle = video?.title || video?.store_name || t('videoDetail.kakaoDefaultTitle');
const handleCopyLink = async () => {
try {
await navigator.clipboard.writeText(shareUrl);
} catch {
// clipboard API 미지원 환경에서는 무시
}
setCopied(true);
setTimeout(() => setCopied(false), 2000);
};
const handleShareButtonClick = async () => {
const handled = await tryNativeShare({
title: shareTitle,
text: shareDescription,
url: shareUrl,
});
if (handled) {
return;
}
try {
await navigator.clipboard.writeText(shareUrl);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} catch {
// clipboard API 미지원 환경에서는 무시
}
await handleCopyLink();
};
const likeDebounceRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);
@ -252,6 +253,7 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
<button
className="video-detail-copy-btn"
onClick={handleShareButtonClick}
title={t('videoDetail.share')}
>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/>

View File

@ -194,6 +194,7 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = () => {
videoId={video.video_id}
storeName={video.store_name}
region={video.region}
title={video.title}
commentCount={video.comment_count ?? 0}
initialLikeCount={video.like_count ?? 0}
initialIsLiked={video.is_liked_by_me}

View File

@ -291,6 +291,7 @@ const MyContentsPage: React.FC<MyContentsPageProps> = ({ onNavigate }) => {
videoId={video.video_id}
storeName={video.store_name}
region={video.region}
title={video.title}
commentCount={video.comment_count ?? 0}
initialLikeCount={video.like_count ?? 0}
initialIsLiked={video.is_liked_by_me}

View File

@ -294,6 +294,8 @@ export interface VideoDetailItem {
poster_url?: string | null;
store_name: string;
region: string;
title?: string | null;
description?: string | null;
created_at: string;
like_count: number;
is_liked_by_me: boolean;

View File

@ -1,6 +1,9 @@
/**
* .
*
* `text` URL을 .
* · OG (`og:title`, `og:description`) , url( title) .
*
* .
*/
export async function tryNativeShare(data: ShareData): Promise<boolean> {