From 9728afbc1b67a1214e4ea246c2fb269a3ab5dccf Mon Sep 17 00:00:00 2001 From: iven Date: Sat, 16 May 2026 00:55:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor(mp):=20=E8=BF=81=E7=A7=BB=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E5=88=97=E8=A1=A8=E9=A1=B5=20=E2=80=94=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=BB=9F=E4=B8=80=E7=BB=84=E4=BB=B6=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PageShell 替代手写 min-height/bg/padding - ContentCard 替代手写 article-card 卡片样式 - LoadingCard 替代初始加载态 - 精简 SCSS 删除已接管样式,保留分类筛选/卡片内容布局 Co-Authored-By: Claude Opus 4.7 --- apps/miniprogram/src/pages/article/index.scss | 44 ++------- apps/miniprogram/src/pages/article/index.tsx | 90 ++++++++++--------- 2 files changed, 54 insertions(+), 80 deletions(-) diff --git a/apps/miniprogram/src/pages/article/index.scss b/apps/miniprogram/src/pages/article/index.scss index 388b703..43d171f 100644 --- a/apps/miniprogram/src/pages/article/index.scss +++ b/apps/miniprogram/src/pages/article/index.scss @@ -1,13 +1,11 @@ @import '../../styles/variables.scss'; -@import '../../styles/mixins.scss'; -.article-page { - min-height: 100vh; - background: $bg; - padding: 24px; - padding-bottom: 40px; -} +// PageShell 已接管:min-height, background, padding +// ContentCard 已接管:article-card 背景/圆角/阴影/触摸反馈 +// LoadingCard 已接管:初始加载骨架屏 +// EmptyState 已接管:空状态样式 +/* ─── 分类筛选滚动条(页面特有) ─── */ .article-categories { white-space: nowrap; margin-bottom: 24px; @@ -31,20 +29,14 @@ } } +/* ─── 文章列表布局 ─── */ .article-list { display: flex; flex-direction: column; gap: 20px; } -.article-card { - display: flex; - background: $card; - border-radius: $r; - padding: 28px; - box-shadow: $shadow-sm; -} - +/* ─── 文章卡片内容(ContentCard 已接管外层卡片样式) ─── */ .article-card-body { flex: 1; display: flex; @@ -107,25 +99,3 @@ width: 100%; height: 100%; } - -.empty-state { - display: flex; - justify-content: center; - align-items: center; - padding: 120px 0; -} - -.empty-text { - font-size: var(--tk-font-body-lg); - color: var(--tk-text-secondary); -} - -.loading-hint { - text-align: center; - padding: 24px 0; -} - -.loading-text { - font-size: var(--tk-font-h2); - color: var(--tk-text-secondary); -} diff --git a/apps/miniprogram/src/pages/article/index.tsx b/apps/miniprogram/src/pages/article/index.tsx index d375a1e..849228c 100644 --- a/apps/miniprogram/src/pages/article/index.tsx +++ b/apps/miniprogram/src/pages/article/index.tsx @@ -3,9 +3,12 @@ import { View, Text, Image, ScrollView } from '@tarojs/components'; import Taro, { useReachBottom } from '@tarojs/taro'; import { usePageData } from '@/hooks/usePageData'; import { listArticles, listCategories, Article, ArticleCategory } from '../../services/article'; -import EmptyState from '../../components/EmptyState'; -import ErrorState from '../../components/ErrorState'; -import Loading from '../../components/Loading'; +import PageShell from '@/components/ui/PageShell'; +import ContentCard from '@/components/ui/ContentCard'; +import LoadingCard from '@/components/ui/LoadingCard'; +import EmptyState from '@/components/EmptyState'; +import ErrorState from '@/components/ErrorState'; +import Loading from '@/components/Loading'; import { useElderClass } from '../../hooks/useElderClass'; import './index.scss'; @@ -73,8 +76,12 @@ export default function ArticleList() { Taro.navigateTo({ url: `/pages/article/detail/index?id=${id}` }); }; + if (!loading && articles.length === 0 && !error && !categories.length) { + return ; + } + return ( - + {/* 分类筛选 */} {categories.length > 0 && ( @@ -96,47 +103,44 @@ export default function ArticleList() { )} - - {error ? ( - fetchData(1, false, null)} /> - ) : articles.map((a) => ( - goToDetail(a.id)} - > - - {a.title} - {a.summary && ( - {a.summary} - )} - - {(a.category_name || a.category) && ( - {a.category_name || a.category} - )} - {a.published_at && ( - - {a.published_at.slice(0, 10)} - - )} - - - {a.cover_image && ( - - - - )} - - ))} - - - {articles.length === 0 && !loading && ( + {error ? ( + fetchData(1, false, null)} /> + ) : articles.length === 0 && !loading ? ( + ) : ( + + {articles.map((a) => ( + goToDetail(a.id)} + > + + {a.title} + {a.summary && ( + {a.summary} + )} + + {(a.category_name || a.category) && ( + {a.category_name || a.category} + )} + {a.published_at && ( + + {a.published_at.slice(0, 10)} + + )} + + + {a.cover_image && ( + + + + )} + + ))} + )} - {loading && ( - - )} - + {loading && } + ); }