From dd0c6b8e2e155994df90bbdea9d0d6685eb373da Mon Sep 17 00:00:00 2001 From: "ethan.chen" Date: Mon, 26 May 2025 17:05:24 +0800 Subject: [PATCH] feat: modularize media display by creating MediaItem component, define Media interface, and simplify media list rendering --- src/App.svelte | 40 +++-------------------- src/lib/MediaItem.svelte | 69 ++++++++++++++++++++++++++++++++++++++++ src/lib/interfaces.ts | 12 +++++++ 3 files changed, 86 insertions(+), 35 deletions(-) create mode 100644 src/lib/MediaItem.svelte create mode 100644 src/lib/interfaces.ts diff --git a/src/App.svelte b/src/App.svelte index 8ef0542..2b09f3c 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,20 +1,9 @@ + +
+
+
+
+

{media.title}

+
+ {media.date ? new Date(media.date).toLocaleDateString() : '未设置日期'} +
+
+ +
+ + 状态:{statusMap[media.status] || media.status} + + {#if media.rating} +
+ 评分: +
+ {@html StarRating({ rating: media.rating / 2 })} +
+ ({media.rating}/10) +
+ {/if} + {#if media.platform} + + 平台:{media.platform} + + {/if} +
+ + {#if media.notes} +
+
{media.notes}
+
+ {/if} +
+
+
\ No newline at end of file diff --git a/src/lib/interfaces.ts b/src/lib/interfaces.ts new file mode 100644 index 0000000..5cac54f --- /dev/null +++ b/src/lib/interfaces.ts @@ -0,0 +1,12 @@ +export interface Media { + id: number; + title: string; + type: string; + status: 'completed' | 'in_progress' | 'plan_to_watch'; + rating?: number; + notes?: string; + platform?: string; + date?: string; + created_at: string; + updated_at: string; +}