From 17b1bf1e8ae81ac66a9724a135ce3dab952bca46 Mon Sep 17 00:00:00 2001
From: xy <10816187@qq.com>
Date: Wed, 22 Jul 2026 00:14:42 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8D=9A=E5=AE=A2=E5=BD=92=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/BaseHeader.astro | 3 +-
src/pages/archive.astro | 193 ++++++++++++++++++++++++++++++++
src/types/archive.ts | 22 ++++
3 files changed, 217 insertions(+), 1 deletion(-)
create mode 100644 src/pages/archive.astro
create mode 100644 src/types/archive.ts
diff --git a/src/components/BaseHeader.astro b/src/components/BaseHeader.astro
index d94ab06..e3ddada 100644
--- a/src/components/BaseHeader.astro
+++ b/src/components/BaseHeader.astro
@@ -12,7 +12,7 @@ import ThemeIcon from './ThemeIcon.astro'
@@ -68,6 +68,7 @@ import ThemeIcon from './ThemeIcon.astro'
gap: 20px;
height: 100%;
align-items: center;
+ margin-right: 12px;
}
.menu-item {
diff --git a/src/pages/archive.astro b/src/pages/archive.astro
new file mode 100644
index 0000000..da91457
--- /dev/null
+++ b/src/pages/archive.astro
@@ -0,0 +1,193 @@
+---
+import Layout from "@/layouts/Layout.astro";
+import type {Archive} from "@/types/archive";
+import {createHttp} from "@/lib/request";
+
+const http = createHttp(Astro.request.headers);
+
+const {data} = await http.get
>("post/archive");
+---
+
+
+
+
+ {
+ data.map((year) => (
+
+
+ {year.year}
+ 共 {year.total} 篇
+
+
+ {year.list.map((month) => (
+
+
{month.month} 月
+
+ {month.list.map((post) => (
+ -
+
+ {post.published_at_display}
+
+ {post.title}
+ {post.category_name}
+
+ ))}
+
+
+ ))}
+
+
+ ))
+ }
+
+
+
+
+
diff --git a/src/types/archive.ts b/src/types/archive.ts
new file mode 100644
index 0000000..298c345
--- /dev/null
+++ b/src/types/archive.ts
@@ -0,0 +1,22 @@
+type ArchiveYear = {
+ year: number;
+ total: number;
+ list: ArchiveMonth[];
+};
+
+type ArchivePost = {
+ id: number;
+ slug: string;
+ title: string;
+ published_at: string;
+ published_at_display: string;
+ category_name: string;
+};
+
+type ArchiveMonth = {
+ month: number;
+ display_month: string;
+ list: ArchivePost[];
+};
+
+export type Archive = ArchiveYear[];