From c6bbdfbc0a85c1e88dca5b80c5abfd7e98b88a02 Mon Sep 17 00:00:00 2001 From: WeiFeng-mindinsight Date: Fri, 23 Apr 2021 15:24:35 +0800 Subject: [PATCH] UI fix bug that cannot get parameters when the page is initialized --- mindinsight/ui/src/views/debugger/debugger.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mindinsight/ui/src/views/debugger/debugger.vue b/mindinsight/ui/src/views/debugger/debugger.vue index d8b8bd52..f757cf5f 100644 --- a/mindinsight/ui/src/views/debugger/debugger.vue +++ b/mindinsight/ui/src/views/debugger/debugger.vue @@ -1212,7 +1212,7 @@ export default { * Initialization method executed after the graph rendering is complete */ startApp() { - this.initSvgSize(); + this.initSvgSize(true); this.graph.dom = document.querySelector(`#graph #graph0`); const graphBox = this.graph.dom.getBBox(); this.graph.size = {width: graphBox.width, height: graphBox.height}; @@ -1789,13 +1789,18 @@ export default { this.collapseTable = !this.collapseTable; this.initSvgSize(); }, - initSvgSize() { - if (this.resizeTimer) clearTimeout(this.resizeTimer); - this.resizeTimer = setTimeout(() => { + initSvgSize(immediate = false) { + const setData = () => { const svgRect = document.querySelector('#graph svg').getBoundingClientRect(); this.svg.size = {width: svgRect.width, height: svgRect.height, left: svgRect.left, top: svgRect.top}; this.resizeTimer = null; - }, this.resizeDelay); + }; + if (!immediate) { + if (this.resizeTimer) clearTimeout(this.resizeTimer); + this.resizeTimer = setTimeout(setData, this.resizeDelay); + } else { + setData(); + } }, }, destroyed() {