From 78e2105a62058f8893e4b80c209f9bdf95496d3e 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: Wed, 30 Jul 2025 15:19:02 +0800 Subject: [PATCH] =?UTF-8?q?FEAT=20=3D>=20=E6=9B=B4=E6=96=B0=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=BB=91=E5=AE=9A=E5=BC=95=E5=AF=BC=E9=A1=B5=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=AE=BE=E5=A4=87=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E4=BB=A5=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=AE=BE=E5=A4=87=E6=95=B0=E9=87=8F=E8=8E=B7=E5=8F=96?= =?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?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nkebao/src/pages/guide/index.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/nkebao/src/pages/guide/index.tsx b/nkebao/src/pages/guide/index.tsx index ce817144..da42ed05 100644 --- a/nkebao/src/pages/guide/index.tsx +++ b/nkebao/src/pages/guide/index.tsx @@ -8,10 +8,9 @@ import { QrcodeOutlined, } from "@ant-design/icons"; import Layout from "@/components/Layout/Layout"; -import { fetchDeviceQRCode, addDeviceByImei } from "./api"; +import { fetchDeviceQRCode, addDeviceByImei, fetchDeviceList } from "./api"; import { useUserStore } from "@/store/module/user"; import styles from "./index.module.scss"; - const Guide: React.FC = () => { const navigate = useNavigate(); const { user } = useUserStore(); @@ -72,10 +71,10 @@ const Guide: React.FC = () => { // 这里可以调用一个简单的设备数量接口来检查是否有新设备 // 或者使用其他方式检测设备状态变化 // 暂时使用store中的数量,实际项目中可能需要调用专门的接口 - const currentDeviceCount = user?.deviceTotal || 0; - - // 如果设备数量增加了,说明有新设备添加成功 - if (currentDeviceCount > initialDeviceCountRef.current) { + let currentDeviceCount = user?.deviceTotal || 0; + const res = await fetchDeviceList({ accountId: user?.s2_accountId }); + if (res.added) { + currentDeviceCount = 1; Toast.show({ content: "设备添加成功!", position: "top" }); setAddVisible(false); setDeviceCount(currentDeviceCount); @@ -85,7 +84,7 @@ const Guide: React.FC = () => { pollingRef.current = null; } // 可以选择跳转到首页或继续留在当前页面 - // navigate("/"); + navigate("/"); return; } } catch (error) { @@ -95,7 +94,7 @@ const Guide: React.FC = () => { // 每3秒检查一次设备状态 pollingRef.current = setInterval(pollDeviceStatus, 3000); - }, [isPolling, deviceCount, user?.deviceTotal]); + }, [isPolling, user?.s2_accountId]); // 停止轮询 const stopPolling = useCallback(() => { @@ -289,7 +288,7 @@ const Guide: React.FC = () => {
{qrCode && (