diff --git a/Cunkebao/app/devices/[id]/page.tsx b/Cunkebao/app/devices/[id]/page.tsx index eb203a8d..1989896a 100644 --- a/Cunkebao/app/devices/[id]/page.tsx +++ b/Cunkebao/app/devices/[id]/page.tsx @@ -180,82 +180,20 @@ export default function DeviceDetailPage() { fetchRelatedAccounts() } } else { - // 如果API返回错误,则使用备用模拟数据 - toast.error("获取设备信息失败,显示备用数据") - fallbackToMockDevice() + // 如果API返回错误,显示错误提示 + toast.error("获取设备信息失败: " + ((response as any)?.msg || "未知错误")) + setLoading(false) } } catch (error) { console.error("获取设备信息失败:", error) - toast.error("获取设备信息出错,显示备用数据") - fallbackToMockDevice() + toast.error("获取设备信息出错,请稍后重试") + setLoading(false) } finally { + // 确保loading状态被关闭 setLoading(false) } } - const fallbackToMockDevice = () => { - const mockDevice: Device = { - id: params.id as string, - imei: "sd123123", - name: "设备 1", - status: "online", - battery: 85, - lastActive: "2024-02-09 15:30:45", - historicalIds: ["vx412321", "vfbadasd"], - wechatAccounts: [ - { - id: "1", - avatar: "https://hebbkx1anhila5yf.public.blob.vercel-storage.com/image-q2rVrFbfDdAbSnT3ZTNE7gfn3QCbvr.png", - nickname: "老张", - wechatId: "wxid_abc123", - gender: 1, - status: 1, - statusText: "可加友", - wechatAlive: 1, - wechatAliveText: "正常", - addFriendStatus: 1, - totalFriend: 523, - lastActive: "2024-02-09 15:20:33", - }, - { - id: "2", - avatar: "https://hebbkx1anhila5yf.public.blob.vercel-storage.com/image-q2rVrFbfDdAbSnT3ZTNE7gfn3QCbvr.png", - nickname: "老李", - wechatId: "wxid_xyz789", - gender: 1, - status: 0, - statusText: "已停用", - wechatAlive: 0, - wechatAliveText: "异常", - addFriendStatus: 0, - totalFriend: 245, - lastActive: "2024-02-09 14:15:22", - }, - ], - features: { - autoAddFriend: true, - autoReply: true, - momentsSync: false, - aiChat: true, - }, - history: [ - { - time: "2024-02-09 15:30:45", - action: "开启自动加好友", - operator: "系统", - }, - { - time: "2024-02-09 14:20:33", - action: "添加微信号", - operator: "管理员", - }, - ], - totalFriend: 768, - thirtyDayMsgCount: 5678 - } - setDevice(mockDevice) - } - fetchDevice() }, [params.id, activeTab]) @@ -569,8 +507,35 @@ export default function DeviceDetailPage() { return nameMap[feature] || feature } - if (loading || !device) { - return
加载中...
+ if (loading) { + return ( +
+
+
+
正在加载设备详情...
+
+
+ ) + } + + if (!device) { + return ( +
+
+
+ +
+
设备不存在或已被删除
+
+ 无法加载ID为 "{params.id}" 的设备信息,请检查设备是否存在。 +
+ +
+
+ ) } return ( diff --git a/Server/application/cunkebao/controller/device/GetRelatedAccountsV1Controller.php b/Server/application/cunkebao/controller/device/GetRelatedAccountsV1Controller.php index 4bdd6e0f..c2d09b16 100644 --- a/Server/application/cunkebao/controller/device/GetRelatedAccountsV1Controller.php +++ b/Server/application/cunkebao/controller/device/GetRelatedAccountsV1Controller.php @@ -70,7 +70,7 @@ class GetRelatedAccountsV1Controller extends BaseController } /** - * 通过微信id获取微信最后活跃时间 + * TODO 通过微信id获取微信最后活跃时间 * * @param int $time * @return string @@ -81,7 +81,7 @@ class GetRelatedAccountsV1Controller extends BaseController } /** - * 加友状态 + * TODO 加友状态 * * @param string $wechatId * @return string @@ -92,7 +92,7 @@ class GetRelatedAccountsV1Controller extends BaseController } /** - * 账号状态 + * TODO 账号状态 * * @param string $wechatId * @return string