Skip to content

Commit

Permalink
perf: 选择器路径视图隐藏尾部节点
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Jan 18, 2024
1 parent 59197e6 commit 6d61926
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/components/TrackGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,36 @@ const visibleNodes = computed(() => {
graphNodes.forEach((n) => {
if (n.children.length < n._node.children.length) {
const rawGroup: RawNode[] = [];
const clear = () => {
while (rawGroup.length > 0) {
rawGroup.pop();
}
};
const insert = () => {
if (rawGroup.length == 0) return;
const children = rawGroup[0].parent!.children!;
const g = rawGroup[0];
if (
children.length > 1 &&
children.indexOf(g) == 1 &&
children.indexOf(rawGroup.at(-1)!) == children.length - 1
) {
clear();
return;
}
n.children.push({
_node: g,
children: [],
id: g.id.toString(),
label:
rawGroup.length == 1
? getLimitLabel(g)
: `[${g.parent!.children.indexOf(g)} ... ${g.parent!.children.indexOf(
: `[${children.indexOf(g)} ... ${children.indexOf(
rawGroup.at(-1)!,
)}]`,
tracked: trackId === g.id,
});
while (rawGroup.length > 0) {
rawGroup.pop();
}
clear();
};
n._node.children.forEach((c) => {
if (!n.children.find((g) => g.id === c.id.toString())) {
Expand Down

0 comments on commit 6d61926

Please sign in to comment.