From 21a97b887118c085ae51117af47e4be01523e4c5 Mon Sep 17 00:00:00 2001 From: tisonhuang Date: Mon, 2 Mar 2026 14:09:07 +0800 Subject: [PATCH] feat(sns): cache page data and show count loading state --- src/components/Sns/SnsFilterPanel.tsx | 20 ++- src/pages/SnsPage.scss | 8 ++ src/pages/SnsPage.tsx | 176 +++++++++++++++++++++++--- src/services/config.ts | 78 ++++++++++++ 4 files changed, 258 insertions(+), 24 deletions(-) diff --git a/src/components/Sns/SnsFilterPanel.tsx b/src/components/Sns/SnsFilterPanel.tsx index 6c914a0..f514f94 100644 --- a/src/components/Sns/SnsFilterPanel.tsx +++ b/src/components/Sns/SnsFilterPanel.tsx @@ -8,6 +8,7 @@ interface Contact { displayName: string avatarUrl?: string postCount?: number + postCountStatus?: 'loading' | 'ready' | 'error' } interface SnsFilterPanelProps { @@ -58,6 +59,16 @@ export const SnsFilterPanel: React.FC = ({ setJumpTargetDate(undefined) } + const getPostCountDisplay = (contact: Contact) => { + if (contact.postCountStatus === 'error') { + return { text: '统计失败', className: 'is-error' } + } + if (contact.postCountStatus !== 'ready') { + return { text: '统计中', className: 'is-loading' } + } + return { text: `${Math.max(0, Number(contact.postCount || 0))} 条`, className: '' } + } + return (