From bb6453d3a2f2fc051bd133ac31e707781b28d613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Fri, 24 Oct 2025 12:01:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=8A=A0=E8=BD=BD=E6=9B=B4?= =?UTF-8?q?=E5=A4=9A=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=9B=B4=E6=96=B0=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E5=92=8C=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=81=94=E7=B3=BB=E4=BA=BA=E5=88=97=E8=A1=A8=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E5=8A=A0=E8=BD=BD=E7=8A=B6=E6=80=81=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C?= =?UTF-8?q?=E5=92=8C=E4=BB=A3=E7=A0=81=E5=8F=AF=E8=AF=BB=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SidebarMenu/WechatFriends/com.module.scss | 22 +++----- .../SidebarMenu/WechatFriends/index.tsx | 50 +++++++++++++------ 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/com.module.scss b/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/com.module.scss index 75a67032..70630da1 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/com.module.scss +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/com.module.scss @@ -157,24 +157,18 @@ padding: 10px; } - // 加载更多按钮 - .loadMoreBtn { - background: #fff; - border: 1px solid #d9d9d9; - border-radius: 4px; - padding: 6px 15px; + // 加载更多文字 + .loadMoreText { + text-align: center; + padding: 10px 15px; font-size: 14px; + color: #1890ff; cursor: pointer; transition: all 0.3s; - &:hover:not(:disabled) { - color: #1890ff; - border-color: #1890ff; - } - - &:disabled { - cursor: not-allowed; - opacity: 0.6; + &:hover { + color: #40a9ff; + background-color: #f5f5f5; } } } diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/index.tsx index 3987775e..22b4c34b 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/index.tsx @@ -26,6 +26,7 @@ const ContactListSimple: React.FC = ({ const [contactGroups, setContactGroups] = useState([]); const [labels, setLabels] = useState([]); const [loading, setLoading] = useState(false); + const [initializing, setInitializing] = useState(true); // 初始化状态 const [activeKey, setActiveKey] = useState([]); // 分页相关状态(合并为对象,减少状态数量) @@ -119,14 +120,36 @@ const ContactListSimple: React.FC = ({ if (!currentUser?.id || labels.length === 0) return; try { - const groupStats = await getGroupStatistics( + // 先检查本地数据库是否有数据 + const localContacts = await ContactManager.getUserContacts( currentUser.id, - labels, - currentCustomer?.id, ); - setContactGroups(groupStats); + + if (localContacts && localContacts.length > 0) { + // 有本地数据,直接加载分组统计(不显示骨架屏) + const groupStats = await getGroupStatistics( + currentUser.id, + labels, + currentCustomer?.id, + ); + setContactGroups(groupStats); + setInitializing(false); // 初始化完成 + } else { + // 没有本地数据,显示骨架屏 + setLoading(true); + const groupStats = await getGroupStatistics( + currentUser.id, + labels, + currentCustomer?.id, + ); + setContactGroups(groupStats); + setLoading(false); + setInitializing(false); // 初始化完成 + } } catch (error) { console.error("获取分组统计失败:", error); + setLoading(false); + setInitializing(false); // 即使失败也标记为完成 } }; @@ -358,21 +381,18 @@ const ContactListSimple: React.FC = ({ setActiveKey(newKeys); }; - // 渲染加载更多按钮 + // 渲染加载更多文字 const renderLoadMoreButton = (groupKey: string) => { if (!groupData.hasMore[groupKey]) { return
没有更多了
; } return ( -
- +
!groupData.loading[groupKey] && handleLoadMore(groupKey)} + > + {groupData.loading[groupKey] ? "加载中..." : "加载更多"}
); }; @@ -433,8 +453,8 @@ const ContactListSimple: React.FC = ({ return (
- {loading ? ( - // 加载状态:显示骨架屏(只在首次无本地数据时显示) + {loading || initializing ? ( + // 加载状态:显示骨架屏(初始化或首次无本地数据时显示) renderSkeleton() ) : isSearchMode ? ( // 搜索模式:直接显示搜索结果列表