From c259eabc22f5300eb457f94a109661c6e944345e Mon Sep 17 00:00:00 2001 From: yangsy Date: Sun, 4 Jan 2026 10:30:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=87=AA=E5=85=B3=E8=81=94=E7=9A=84=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../current-diag/security-box-circuit-link-modal.vue | 4 +++- .../components/current-diag/switch-port-link-modal.vue | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/device/device-card/components/current-diag/security-box-circuit-link-modal.vue b/src/components/device/device-card/components/current-diag/security-box-circuit-link-modal.vue index ac99f62..c154a47 100644 --- a/src/components/device/device-card/components/current-diag/security-box-circuit-link-modal.vue +++ b/src/components/device/device-card/components/current-diag/security-box-circuit-link-modal.vue @@ -68,7 +68,9 @@ const { mutate: linkPortToDevice, isPending: linking } = useMutation({ const lowerDeviceDbId = lowerDevice.value?.id; if (!lowerDeviceDbId) throw new Error('该设备没有ID'); - // 0. 检查上游设备的linkDescription的downstream字段是否存在某个端口已经关联下游设备 + // 0. 检查是否会导致循环关联, + if (upperDeviceDbId === lowerDeviceDbId) throw new Error('不能关联到自身'); + // 以及检查上游设备的linkDescription的downstream字段是否存在某个端口已经关联下游设备 const duplicated = Object.entries(upperDeviceLinkDescription.value?.downstream ?? {}).find(([, deviceStoreIndex]) => { return deviceStoreIndex.deviceDbId === lowerDeviceDbId; }); diff --git a/src/components/device/device-card/components/current-diag/switch-port-link-modal.vue b/src/components/device/device-card/components/current-diag/switch-port-link-modal.vue index 70b4682..fe6636c 100644 --- a/src/components/device/device-card/components/current-diag/switch-port-link-modal.vue +++ b/src/components/device/device-card/components/current-diag/switch-port-link-modal.vue @@ -78,7 +78,9 @@ const { mutate: linkPortToDevice, isPending: linking } = useMutation({ const lowerDeviceDbId = lowerDevice.value?.id; if (!lowerDeviceDbId) throw new Error('该设备没有ID'); - // 0. 检查上游设备的linkDescription的downstream字段是否存在某个端口已经关联下游设备 + // 0. 检查是否会导致循环关联, + if (upperDeviceDbId === lowerDeviceDbId) throw new Error('不能关联到自身'); + // 以及检查上游设备的linkDescription的downstream字段是否存在某个端口已经关联下游设备 const duplicated = Object.entries(upperDeviceLinkDescription.value?.downstream ?? {}).find(([, deviceStoreIndex]) => { return deviceStoreIndex.deviceDbId === lowerDeviceDbId; });