This commit is contained in:
암냥 2026-04-23 19:11:16 +09:00
commit 3c601295b1
No known key found for this signature in database
5 changed files with 82 additions and 13 deletions

View file

@ -9,12 +9,20 @@ type SourceType = "twitter" | "pixiv";
type PreviewItem = {
url: string;
type?: "image" | "video";
};
type TweetApiResponse = {
tweet?: {
author?: { name?: string };
media?: { photos?: Array<{ url?: string }> };
media?: {
photos?: Array<{ url?: string }>;
all?: Array<{
url?: string;
thumbnail_url?: string;
type?: "photo" | "video" | "gif";
}>;
};
};
};
@ -176,10 +184,13 @@ export default function AddPage() {
}
const data = (await response.json()) as TweetApiResponse;
const items = (data.tweet?.media?.photos ?? [])
.map((photo) => photo.url)
.filter((photoUrl): photoUrl is string => typeof photoUrl === "string" && photoUrl.length > 0)
.map((photoUrl) => ({ url: photoUrl }));
const mediaItems = data.tweet?.media?.all || data.tweet?.media?.photos || [];
const items: PreviewItem[] = mediaItems
.map((m) => ({
url: (m as any).thumbnail_url || (m as any).url || "",
type: ((m as any).type === "video" || (m as any).type === "gif") ? "video" : "image"
}))
.filter((item) => item.url.length > 0);
if (items.length === 0) {
throw new Error("이미지를 찾지 못했습니다.");
@ -462,6 +473,13 @@ export default function AddPage() {
decoding="async"
className={`aspect-4/5 w-full object-cover transition ${selected[index] ? "opacity-100" : "opacity-35 grayscale-20"}`}
/>
{item.type === "video" && (
<div className="absolute inset-0 flex items-center justify-center bg-black/10">
<svg className="h-10 w-10 text-white/80 drop-shadow-md" fill="currentColor" viewBox="0 0 20 20">
<path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z" clipRule="evenodd" />
</svg>
</div>
)}
<div className="absolute left-2 top-2 border border-border/60 bg-background/80 px-2 py-1 text-xs backdrop-blur">
<input
type="checkbox"