From 9609319569e2fa76c37fff366a84c4d37d15c247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E9=98=B3?= Date: Tue, 6 Jan 2026 20:22:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=95=99=E8=A8=80=E5=A2=99?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E6=98=A0=E5=B0=84=E8=A1=A8=E4=BB=A5=E4=BC=98=E5=8C=96=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E5=A4=84=E7=90=86=EF=BC=8C=E6=94=B9=E8=BF=9B=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E5=92=8C=E5=8A=A8=E7=94=BB=E6=95=88=E6=9E=9C=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C=E3=80=82?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=A0=B7=E5=BC=8F=E6=96=87=E4=BB=B6=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8D=A1=E7=89=87=E6=B7=A1=E5=85=A5=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=EF=BC=8C=E6=8F=90=E5=8D=87=E8=A7=86=E8=A7=89=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/wall/[cate]/page.tsx | 136 +++++++++++++++++++++++++---------- src/styles/index.scss | 16 +++++ 2 files changed, 114 insertions(+), 38 deletions(-) diff --git a/src/app/wall/[cate]/page.tsx b/src/app/wall/[cate]/page.tsx index 19008b8..686aa85 100755 --- a/src/app/wall/[cate]/page.tsx +++ b/src/app/wall/[cate]/page.tsx @@ -11,18 +11,21 @@ interface Props { searchParams: Promise<{ page: number }>; } +// 颜色映射表,将颜色值映射到对应的 Tailwind 类名 +const colorMap: Record = { + '#fcafa24d': 'bg-[#fcafa24d]', + '#a8ed8a4d': 'bg-[#a8ed8a4d]', + '#caa7f74d': 'bg-[#caa7f74d]', + '#ffe3944d': 'bg-[#ffe3944d]', + '#92e6f54d': 'bg-[#92e6f54d]', +}; + export default async (props: Props) => { const searchParams = await props.searchParams; const params = await props.params; const cate = params.cate; const page = searchParams.page || 1; - const active = '!text-primary !border-primary'; - - // 提前把颜色写好,否则会导致样式丢失 - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const colors = ['bg-[#fcafa24d]', 'bg-[#a8ed8a4d]', 'bg-[#caa7f74d]', 'bg-[#ffe3944d]', 'bg-[#92e6f54d]']; - const { data: cateList } = (await getCateListAPI()) || { data: [] as Cate[] }; const id = cateList.find((item) => item.mark === cate)?.id ?? 0; @@ -36,42 +39,99 @@ export default async (props: Props) => {
-
-

留言墙

-

有什么想对我说的,来吧

- {/* */} - -
- -
+ {/* 背景装饰元素 */} +
+
+
-
    - {cateList?.map((item) => ( -
  • - {item.name} -
  • - ))} -
- -
- {tallList.result?.map((item) => ( -
-
- {dayjs(+item.createTime!).format('YYYY-MM-DD HH:mm')} - {item.cate.name} -
- -
{item.content}
- -
{item.name ? item.name : '匿名'}
+
+ {/* 头部区域 */} +
+
+

留言墙

+

有什么想对我说的,来吧

- ))} -
- {tallList.total && } +
+ +
+
+ + {/* 分类标签 */} +
+ {cateList?.map((item) => ( + + {item.name} + + ))} +
+ + {/* 留言卡片网格 */} +
+ {tallList.result?.map((item, index) => { + const bgColor = colorMap[item.color] || 'bg-[#ffe3944d]'; + return ( +
+ {/* 卡片装饰边框 */} +
+ + {/* 顶部信息 */} +
+ {dayjs(+item.createTime!).format('YYYY-MM-DD HH:mm')} + {item.cate.name} +
+ + {/* 留言内容 */} +
{item.content}
+ + {/* 底部署名 */} +
+
+ + {item.name ? item.name : '匿名'} +
+
+ + {/* Hover 时的光效 */} +
+
+ ); + })} +
+ + {/* 分页 */} + {tallList.total && ( +
+ +
+ )} +
); diff --git a/src/styles/index.scss b/src/styles/index.scss index 5a43fd7..a73d2a4 100755 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -119,6 +119,22 @@ body { height: 0; } +// 留言墙卡片淡入动画 +@keyframes fade-in-up { + from { + opacity: 0; + transform: translateY(20px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +.animate-fade-in-up { + animation: fade-in-up 0.6s ease-out forwards; +} + // 瀑布流布局 .masonry-grid { display: -webkit-box;