修复设备管理页,关闭IMEI模态弹框时自动跳转到设备详情页的问题。
This commit is contained in:
@@ -480,8 +480,23 @@ export default function DevicesPage() {
|
||||
}
|
||||
|
||||
// 设备详情页跳转
|
||||
const handleDeviceClick = (deviceId: number) => {
|
||||
router.push(`/devices/${deviceId}`)
|
||||
const handleDeviceClick = (deviceId: number, event: React.MouseEvent) => {
|
||||
// 判断点击事件是否来自ImeiDisplay组件或其后代元素
|
||||
// 如果点击事件已经被处理(例如ImeiDisplay中已阻止传播),则不执行跳转
|
||||
if (event.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果点击的元素或其父元素有imei-display类,则不跳转
|
||||
let target = event.target as HTMLElement;
|
||||
while (target && target !== event.currentTarget) {
|
||||
if (target.classList.contains('imei-display-area')) {
|
||||
return;
|
||||
}
|
||||
target = target.parentElement as HTMLElement;
|
||||
}
|
||||
|
||||
router.push(`/devices/${deviceId}`);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -574,7 +589,7 @@ export default function DevicesPage() {
|
||||
<Card
|
||||
key={device.id}
|
||||
className="p-3 hover:shadow-md transition-shadow cursor-pointer relative"
|
||||
onClick={() => handleDeviceClick(device.id)}
|
||||
onClick={(e) => handleDeviceClick(device.id, e)}
|
||||
>
|
||||
<div className="flex items-center space-x-3">
|
||||
<Checkbox
|
||||
@@ -595,7 +610,7 @@ export default function DevicesPage() {
|
||||
{device.status === "online" ? "在线" : "离线"}
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="text-sm text-gray-500 flex items-center">
|
||||
<div className="text-sm text-gray-500 flex items-center imei-display-area">
|
||||
<span className="mr-1">IMEI:</span>
|
||||
<ImeiDisplay imei={device.imei} containerWidth={180} />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user