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; });