fix: 拓扑图节点排除LAN

This commit is contained in:
TsMask
2024-01-30 15:58:53 +08:00
parent 15ab2908be
commit 4d1b3d6a90
3 changed files with 25 additions and 21 deletions

View File

@@ -15,6 +15,8 @@ export const notNeNodes = [
'lan5', 'lan5',
'lan6', 'lan6',
'lan7', 'lan7',
'LAN',
'NR',
]; ];
/**图状态 */ /**图状态 */
@@ -114,9 +116,10 @@ export function neStateParse(neType: string, data: Record<string, any>) {
const neS = nodes.find((n: any) => n.id === edgeSource); const neS = nodes.find((n: any) => n.id === edgeSource);
const neT = nodes.find((n: any) => n.id === edgeTarget); const neT = nodes.find((n: any) => n.id === edgeTarget);
// console.log(neS, edgeSource, neT, edgeTarget); // console.log(neS, edgeSource, neT, edgeTarget);
// 通过 ID 查询节点实例
const item = graphG6.value.findById(edge.id); if (neS && neT) {
if (neS && neT && item) { // 通过 ID 查询节点实例
// const item = graphG6.value.findById(edge.id);
// console.log( // console.log(
// `${edgeSource} - ${edgeTarget}`, // `${edgeSource} - ${edgeTarget}`,
// neS.neState.online && neT.neState.online // neS.neState.online && neT.neState.online
@@ -136,16 +139,16 @@ export function neStateParse(neType: string, data: Record<string, any>) {
// }); // });
// 设置状态 // 设置状态
graphG6.value.setItemState( graphG6.value.setItemState(
item, edge.id,
'line-dash', 'line-dash',
neS.neState.online && neT.neState.online neS.neState.online && neT.neState.online
); );
} }
if (neS && notNeNodes.includes(edgeTarget)) { if (neS && notNeNodes.includes(edgeTarget)) {
graphG6.value.setItemState(item, 'line-dash', neT.neState.online); graphG6.value.setItemState(edge.id, 'line-path', neS.neState.online);
} }
if (neT && notNeNodes.includes(edgeSource)) { if (neT && notNeNodes.includes(edgeSource)) {
graphG6.value.setItemState(item, 'line-dash', neT.neState.online); graphG6.value.setItemState(edge.id, 'line-path', neT.neState.online);
} }
} }
} }

View File

@@ -57,6 +57,8 @@ const notNeNodes = [
'lan5', 'lan5',
'lan6', 'lan6',
'lan7', 'lan7',
'LAN',
'NR',
]; ];
/**图实例对象 */ /**图实例对象 */
@@ -419,9 +421,10 @@ function wsMessage(res: Record<string, any>) {
const neS = nodes.find((n: any) => n.id === edgeSource); const neS = nodes.find((n: any) => n.id === edgeSource);
const neT = nodes.find((n: any) => n.id === edgeTarget); const neT = nodes.find((n: any) => n.id === edgeTarget);
// console.log(neS, edgeSource, neT, edgeTarget); // console.log(neS, edgeSource, neT, edgeTarget);
// 通过 ID 查询节点实例
const item = graphG6.value.findById(edge.id); if (neS && neT) {
if (neS && neT && item) { // 通过 ID 查询节点实例
// const item = graphG6.value.findById(edge.id);
// console.log( // console.log(
// `${edgeSource} - ${edgeTarget}`, // `${edgeSource} - ${edgeTarget}`,
// neS.neState.online && neT.neState.online // neS.neState.online && neT.neState.online
@@ -441,16 +444,16 @@ function wsMessage(res: Record<string, any>) {
// }); // });
// 设置状态 // 设置状态
graphG6.value.setItemState( graphG6.value.setItemState(
item, edge.id,
'line-dash', 'line-dash',
neS.neState.online && neT.neState.online neS.neState.online && neT.neState.online
); );
} }
if (neS && notNeNodes.includes(edgeTarget)) { if (neS && notNeNodes.includes(edgeTarget)) {
graphG6.value.setItemState(item, 'line-dash', neT.neState.online); graphG6.value.setItemState(edge.id, 'line-path', neS.neState.online);
} }
if (neT && notNeNodes.includes(edgeSource)) { if (neT && notNeNodes.includes(edgeSource)) {
graphG6.value.setItemState(item, 'line-dash', neT.neState.online); graphG6.value.setItemState(edge.id, 'line-path', neT.neState.online);
} }
} }
} }

View File

@@ -208,11 +208,15 @@ export function edgeLineAnimateState() {
} }
return; return;
} }
// line-dash 虚线运动 // line-dash 虚线运动
if (name === 'line-dash') { if (name === 'line-dash') {
if (value) { if (value) {
if (keyShape.cfg.animating) return; keyShape.stopAnimate();
keyShape.attr({
lineDash: null,
lineDashOffset: null,
});
let index = 0; let index = 0;
keyShape.animate( keyShape.animate(
() => { () => {
@@ -221,7 +225,7 @@ export function edgeLineAnimateState() {
index = 0; index = 0;
} }
return { return {
lineDash: [4, 2, 2, 2], lineDash: [4, 2, 1, 2],
lineDashOffset: -index, lineDashOffset: -index,
}; };
}, },
@@ -230,12 +234,6 @@ export function edgeLineAnimateState() {
duration: 3000, // 执行一次的持续时间 duration: 3000, // 执行一次的持续时间
} }
); );
} else {
keyShape.stopAnimate();
keyShape.attr({
lineDash: null,
lineDashOffset: null,
});
} }
return; return;
} }