From 0dbaa114aefbae81f50b595ef073d5c2d5d5849b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=B0=B8=E5=B9=B3?= Date: Sat, 5 Jul 2025 14:49:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BC=93=E5=AD=98=E4=B8=8B=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=20=E8=BF=99=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nkebao/src/api/wechat-accounts.ts | 2 +- nkebao/src/pages/devices/DeviceDetail.tsx | 16 +- nkebao/src/pages/devices/Devices.tsx | 6 +- .../pages/wechat-accounts/WechatAccounts.tsx | 385 +++++++++++++++++- 4 files changed, 394 insertions(+), 15 deletions(-) diff --git a/nkebao/src/api/wechat-accounts.ts b/nkebao/src/api/wechat-accounts.ts index c5e62463..7527870f 100644 --- a/nkebao/src/api/wechat-accounts.ts +++ b/nkebao/src/api/wechat-accounts.ts @@ -141,7 +141,7 @@ export const transformWechatAccount = (serverAccount: any): any => { todayAdded, remainingAdds: serverAccount.canAddFriendCount || (maxDailyAdds - todayAdded), maxDailyAdds, - status: serverAccount.wechatAlive === 1 ? "normal" : "abnormal" as "normal" | "abnormal", + status: serverAccount.wechatStatus === 1 ? "normal" : "abnormal" as "normal" | "abnormal", lastActive: new Date().toLocaleString() // 服务端未提供,使用当前时间 }; }; diff --git a/nkebao/src/pages/devices/DeviceDetail.tsx b/nkebao/src/pages/devices/DeviceDetail.tsx index 1911f9ff..75947165 100644 --- a/nkebao/src/pages/devices/DeviceDetail.tsx +++ b/nkebao/src/pages/devices/DeviceDetail.tsx @@ -656,15 +656,15 @@ export default function DeviceDetail() { disabled={accountsLoading} > {accountsLoading ? ( - <> + 刷新中 - + ) : ( - <> + 刷新 - + )} @@ -765,15 +765,15 @@ export default function DeviceDetail() { disabled={logsLoading} > {logsLoading ? ( - <> + 加载中 - + ) : ( - <> + 刷新 - + )} diff --git a/nkebao/src/pages/devices/Devices.tsx b/nkebao/src/pages/devices/Devices.tsx index 32f65a74..bc0e18c8 100644 --- a/nkebao/src/pages/devices/Devices.tsx +++ b/nkebao/src/pages/devices/Devices.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useRef, useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; -import { ChevronLeft, Plus, Filter, Search, RefreshCw, QrCode, Smartphone, Loader2, AlertTriangle, Trash2, X } from 'lucide-react'; +import { ChevronLeft, Plus, Search, RefreshCw, QrCode, Smartphone, Loader2, AlertTriangle, Trash2, X } from 'lucide-react'; import { devicesApi } from '../../api'; import { useToast } from '../../components/ui/toast'; @@ -425,9 +425,7 @@ export default function Devices() { className="w-full pl-10 pr-4 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors" /> - + +

微信号

+ + + + {/* 内容区域 */} +
+
+ {/* 搜索和操作栏 */} +
+
+
+ + setSearchQuery(e.target.value)} + onKeyPress={(e) => e.key === 'Enter' && handleSearch()} + /> +
+ + +
+
+ + {/* 账号列表 */} + {isLoading ? ( +
+ +
+ ) : accounts.length === 0 ? ( +
+

暂无微信账号数据

+ +
+ ) : ( +
+ {accounts.map((account) => ( +
{ + // 将需要的数据编码为 URL 安全的字符串 + const accountData = encodeURIComponent(JSON.stringify({ + avatar: account.avatar, + nickname: account.nickname, + status: account.status, + wechatId: account.wechatId, + wechatAccount: account.wechatAccount, + deviceName: account.deviceName, + deviceId: account.deviceId, + })); + navigate(`/wechat-accounts/${account.id}?data=${accountData}`); + }} + > +
+
+ {account.nickname} +
+
+
+
+
+

{account.nickname}

+ + {account.status === "normal" ? "正常" : "异常"} + +
+ +
+
+
微信号:{account.wechatAccount}
+
+
好友数量:{account.friendCount}
+
今日新增:+{account.todayAdded}
+
+
+
+
+ 今日可添加: + {account.remainingAdds} +
+ +
+ 每日最多添加 {account.maxDailyAdds} 个好友 +
+
+
+ + {account.todayAdded}/{account.maxDailyAdds} + +
+
+
+
+
+
+
所属设备:{account.deviceName || '未知设备'}
+
最后活跃:{account.lastActive}
+
+
+
+
+
+ ))} +
+ )} + + {/* 分页 */} + {!isLoading && accounts.length > 0 && totalPages > 1 && ( +
+
+ +
+ {Array.from({ length: Math.min(totalPages, 5) }, (_, i) => { + let pageToShow = i + 1; + if (currentPage > 3 && totalPages > 5) { + pageToShow = Math.min(currentPage - 2 + i, totalPages); + if (pageToShow > totalPages - 4) { + pageToShow = totalPages - 4 + i; + } + } + return ( + + ); + })} +
+ +
+
+ )} +
+
+ + {/* 好友转移确认对话框 */} + {isTransferDialogOpen && ( +
+
+

好友转移确认

+

+ 确认要将 {selectedAccount?.nickname} 的 {selectedAccount?.friendCount}{" "} + 个好友转移到场景获客吗?系统将自动创建一个获客计划。 +

+
+ + +
+
+
+ )} + + ); } \ No newline at end of file