show error when node data is invalid

This commit is contained in:
codetypes committed 2024-04-18 00:37:40 +08:00
1 parent 0e6aff2855
commit 7ceaf45971
9 files changed
+68 -20

No files matched your search

+4 -2
View File
@@ -1,5 +1,6 @@
import { useWorkspace } from "@/contexts/workspace-context";
import { toBreakWord } from "@/misc/b3util";
import { TreeGraphData } from "@/misc/b3type";
import { checkTreeData, toBreakWord } from "@/misc/b3util";
import i18n from "@/misc/i18n";
import G6 from "@antv/g6";
@@ -76,7 +77,8 @@ G6.registerNode(
let color = nodeDef.color || NODE_COLORS[classify] || NODE_COLORS["Other"];
if (
!workspace.hasNodeDef(cfg.name as string) ||
(cfg.path && (!cfg.children || (cfg.children as []).length == 0))
(cfg.path && (!cfg.children || (cfg.children as []).length == 0)) ||
!checkTreeData(cfg as TreeGraphData)
) {
classify = "Error";
color = NODE_COLORS[classify];