From 52bea590eb4cfef634c9177e2244f5572f2f547e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E8=B6=A3=E4=BF=9D=E7=BD=97?= Date: Sat, 9 Nov 2024 14:06:32 +0800 Subject: [PATCH] Feat: Home Page Details MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 展示博文、日记和媒体 --- app/components/common/icons.tsx | 4 +++ app/routes/_index/route.tsx | 59 ++++++++++++++++++++++++++++++--- app/routes/note._index.tsx | 4 +-- app/types/api.sync.d.ts | 20 +++++++++++ 4 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 app/types/api.sync.d.ts diff --git a/app/components/common/icons.tsx b/app/components/common/icons.tsx index 9bf5d85..edb3821 100644 --- a/app/components/common/icons.tsx +++ b/app/components/common/icons.tsx @@ -2,6 +2,10 @@ import { SVGProps } from "react"; type IconProps = SVGProps; +export const ArrowDown = (props: IconProps) => ( + +) + export const StarFill = (props: IconProps) => ( ); diff --git a/app/routes/_index/route.tsx b/app/routes/_index/route.tsx index dfd3fa0..a2840f5 100644 --- a/app/routes/_index/route.tsx +++ b/app/routes/_index/route.tsx @@ -1,9 +1,12 @@ -import type { MetaFunction } from "@remix-run/node"; +import { Link, useLoaderData } from "@remix-run/react"; +import { type MetaFunction } from "@remix-run/node"; import { siteTitle } from "~/utils"; -import { BiliBili, CloudMusic, GitHub, QQ, Steam, TwitterX } from "~/components/common/icons"; +import { ArrowDown, BiliBili, CloudMusic, GitHub, QQ, Steam, TwitterX } from "~/components/common/icons"; import styles from "./styles.module.less"; +const year = new Date().getFullYear(); + export const meta: MetaFunction = () => { return [ { title: siteTitle() }, @@ -11,10 +14,20 @@ export const meta: MetaFunction = () => { ]; }; +export async function loader() { + const data = (await fetch("https://paul.ren/api/sync").then((res) => + res.json() + )) as unknown as API.Response; + + return { data }; +} + export default function Index() { + const { data } = useLoaderData(); + return ( -
-
+
+
@@ -43,6 +56,44 @@ export default function Index() {

+ +
+ +
+

近期博文

+
+ {data.data.blog.map((item) => ( +

+ {item.title} + {item.date} +

+ ))} +
+
+ +
+

近期日记

+
+ {data.data.note.map((item) => ( +

+ {item.title} + {item.date} +

+ ))} +
+
+ +
+

近期捕获

+
+ {data.data.media.map((item) => ( +
+ {item.title} +

{item.title}

+

{item.take_time.substring(0, 10)}

+
+ ))} +
); diff --git a/app/routes/note._index.tsx b/app/routes/note._index.tsx index 0e357c0..c16fc39 100644 --- a/app/routes/note._index.tsx +++ b/app/routes/note._index.tsx @@ -67,11 +67,11 @@ export default function Note() { {item.starred && ( )} -

+

{item.title}

{item.except}

-
+

{item.date}

diff --git a/app/types/api.sync.d.ts b/app/types/api.sync.d.ts new file mode 100644 index 0000000..80e24b2 --- /dev/null +++ b/app/types/api.sync.d.ts @@ -0,0 +1,20 @@ +interface IBlogData { + title: string + image: string + date: string + link: string + content: string +} + +declare namespace API { + namespace Sync { + interface ISyncData { + blog: IBlogData[] + video: unknown[] + note: API.Note.INoteData[] + say: API.Say.ISayData[] + media: API.Media.IMediaData[] + music: API.Music.IMusicData[] + } + } +}