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;