From c5c559f4efe53defdc70f6381ce2cb1b5af0154e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=B0=B8=E5=B9=B3?= Date: Fri, 4 Jul 2025 17:36:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nkebao/src/pages/devices/Devices.tsx | 266 +++++++++++++++------------ 1 file changed, 144 insertions(+), 122 deletions(-) diff --git a/nkebao/src/pages/devices/Devices.tsx b/nkebao/src/pages/devices/Devices.tsx index 4c9fde589..32f65a749 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 } from 'lucide-react'; +import { ChevronLeft, Plus, Filter, Search, RefreshCw, QrCode, Smartphone, Loader2, AlertTriangle, Trash2, X } from 'lucide-react'; import { devicesApi } from '../../api'; import { useToast } from '../../components/ui/toast'; @@ -247,6 +247,11 @@ export default function Devices() { messageType: 'default', showAnimation: false }); + + // 自动获取二维码 + setTimeout(() => { + fetchDeviceQRCode(); + }, 100); }; const handleCloseAddDeviceModal = () => { @@ -369,62 +374,62 @@ export default function Devices() { }); return ( -
+
{/* 固定header */} -
-
-
+
+
+
-

设备管理

+

设备管理

- {/* 可滚动的内容区域 */} -
+ {/* 内容区域 */} +
{/* 统计卡片 */}
-
-
总设备数
-
{stats.totalDevices}
+
+
总设备数
+
{stats.totalDevices}
-
-
在线设备
-
{stats.onlineDevices}
+
+
在线设备
+
{stats.onlineDevices}
{/* 搜索和过滤 */} -
-
+
+
- + setSearchQuery(e.target.value)} - className="w-full pl-9 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" + 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" />
-
-
- -
+
{/* 设备列表 */} -
+
{filteredDevices.map((device) => (
handleDeviceClick(device.id, e)} > -
+
e.stopPropagation()} - className="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded" + className="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded mt-0.5" />
-
-
{device.memo || "未命名设备"}
- +
{device.memo || "未命名设备"}
+ {device.status === "online" ? "在线" : "离线"}
-
- IMEI: {device.imei} -
-
微信号: {device.wechatId || "未绑定或微信离线"}
-
- 好友数: {device.totalFriend} +
+
IMEI: {device.imei}
+
微信号: {device.wechatId || "未绑定或微信离线"}
+
好友数: {device.totalFriend}
))} -
+
{isLoading &&
加载中...
} {!hasMore && devices.length > 0 &&
没有更多设备了
} {!hasMore && devices.length === 0 &&
暂无设备
} @@ -509,29 +510,43 @@ export default function Devices() { {/* 添加设备弹窗 */} {isAddDeviceOpen && ( -
-
-
+
+
+
-

添加设备

+

添加设备

-
+
{activeTab === "scan" && ( -
-
-
-
- {pollingStatus.isPolling || pollingStatus.showAnimation ? ( - <> - 正在检测添加结果 -
-
-
-
-
- - ) : ( - 5秒后将开始检测添加结果 - )} -
+
+
+ {/* 状态提示 */} +
+ {pollingStatus.isPolling || pollingStatus.showAnimation ? ( +
+ 正在检测添加结果 +
+
+
+
+
+
+ ) : ( + 5秒后将开始检测添加结果 + )}
-
+ + {/* 二维码区域 */} +
{isLoadingQRCode ? ( -
- +
+

正在获取二维码...

) : qrCodeImage ? ( -
-
+
+
设备添加二维码 -
- -

未能加载二维码,请点击刷新按钮重试

+
+ +

未能加载二维码,请点击刷新按钮重试

-

+

请使用手机扫描此二维码添加设备

) : (
- -

点击下方按钮获取二维码

+ +

点击下方按钮获取二维码

)}
+ + {/* 操作按钮 */} - -
+
+ +
+ +
)} @@ -675,21 +694,24 @@ export default function Devices() { {/* 删除确认弹窗 */} {isDeleteDialogOpen && ( -
-
-

确认删除

-

- 设备删除后,本设备配置的计划任务操作也将失效。 -

-
+
+
+
+ +

确认删除

+

+ 设备删除后,本设备配置的计划任务操作也将失效。 +

+
+