From 38ad9eff13b5e1c1cf1d9e42c510e6fec984dda9 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 4 Nov 2024 12:04:27 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E5=85=B3=E9=97=AD=E5=85=B3=E7=B3=BB?= =?UTF-8?q?=E5=9B=BE=E6=97=B6=E8=BF=9B=E8=A1=8C=E9=94=80=E6=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/layout/dock/Graph.ts | 4 ++++ app/src/layout/dock/index.ts | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/layout/dock/Graph.ts b/app/src/layout/dock/Graph.ts index e6407bb7a..2ccf6c40f 100644 --- a/app/src/layout/dock/Graph.ts +++ b/app/src/layout/dock/Graph.ts @@ -505,6 +505,10 @@ export class Graph extends Model { this.network.selectNodes([id]); } + public destroy() { + this.network?.destroy(); + } + public onGraph(hl: boolean) { if (this.graphElement.clientHeight === 0) { // 界面没有渲染时不能进行渲染 diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.ts index aa8d5d930..94d808082 100644 --- a/app/src/layout/dock/index.ts +++ b/app/src/layout/dock/index.ts @@ -534,8 +534,12 @@ export class Dock { clearTimeout(this.hideResizeTimeout); this.hideDock(); } - if ((type === "graph" || type === "globalGraph") && this.layout.element.querySelector(".fullscreen")) { - document.getElementById("drag")?.classList.remove("fn__hidden"); + if ((type === "graph" || type === "globalGraph")) { + if (this.layout.element.querySelector(".fullscreen")) { + document.getElementById("drag")?.classList.remove("fn__hidden"); + } + const graph = this.data[type] as Graph + graph.destroy(); } // 关闭 dock 后设置光标,初始化的时候不能设置,否则关闭文档树且多页签时会请求两次 getDoc if (isSaveLayout && !document.querySelector(".layout__center .layout__wnd--active")) { @@ -752,6 +756,10 @@ export class Dock { } resizeTabs(isSaveLayout); this.showDock(); + if (target.classList.contains("dock__item--active") && !hide && (type === "graph" || type === "globalGraph")) { + const graph = this.data[type] as Graph + graph.onGraph(false); + } } public add(index: number, sourceElement: Element, previousType?: string) { @@ -794,7 +802,7 @@ export class Dock { saveLayout(); } - public remove(key: TDock|string) { + public remove(key: TDock | string) { this.toggleModel(key, false, true, true); this.element.querySelector(`[data-type="${key}"]`).remove(); const custom = this.data[key] as Custom;