From 5061a0dd37431637dd66ea178478b9855c57707e Mon Sep 17 00:00:00 2001 From: zhangyu Date: Thu, 14 Jul 2022 11:31:03 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20=E8=A1=A5=E5=85=85=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E7=9A=84=E7=9B=91=E5=90=AC=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=20diagram=E7=BB=84=E4=BB=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/@topology/core/src/activeLayer.js | 2 +- .../common/@topology/core/src/core.js | 33 +++--- .../common/@topology/core/src/divLayer.js | 2 +- .../common/@topology/core/src/renderLayer.js | 3 +- .../common/ChartDiagram/diagram.vue | 101 +++++------------- .../components/common/project/topologyL5.vue | 3 +- 6 files changed, 50 insertions(+), 94 deletions(-) diff --git a/nezha-fronted/src/components/common/@topology/core/src/activeLayer.js b/nezha-fronted/src/components/common/@topology/core/src/activeLayer.js index bbb273789..f78094229 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/activeLayer.js +++ b/nezha-fronted/src/components/common/@topology/core/src/activeLayer.js @@ -43,7 +43,7 @@ const ActiveLayer = /** @class */ (function (_super) { _this.dockWatchers = [] _this.rotating = false Store.set(_this.generateStoreKey('LT:ActiveLayer'), _this) - // return _this + return _this } ActiveLayer.prototype.calcControlPoints = function () { if (this.pens.length === 1 && this.pens[0] instanceof Node) { diff --git a/nezha-fronted/src/components/common/@topology/core/src/core.js b/nezha-fronted/src/components/common/@topology/core/src/core.js index e3dd36826..317fc41c1 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/core.js +++ b/nezha-fronted/src/components/common/@topology/core/src/core.js @@ -820,17 +820,17 @@ const Topology = /** @class */ (function () { Store.set(this.generateStoreKey('LT:fontColor'), this.options.fontColor || '#222222') this.setupDom(parent) this.setupSubscribe() - // this.setupMouseEvent() + this.setupMouseEvent() // Wait for parent dom load - // setTimeout(function () { - // _this.canvasPos = _this.divLayer.canvas.getBoundingClientRect() - // }, 500) - // setTimeout(function () { - // _this.canvasPos = _this.divLayer.canvas.getBoundingClientRect() - // }, 1000) - // this.cache() + setTimeout(function () { + _this.canvasPos = _this.divLayer.canvas.getBoundingClientRect() + }, 500) + setTimeout(function () { + _this.canvasPos = _this.divLayer.canvas.getBoundingClientRect() + }, 1000) + this.cache() window.topology = this - // this.dispatch('loaded') + this.dispatch('loaded') } Object.defineProperty(Topology.prototype, 'ramCaches', { // 内存中的 caches 数量 @@ -2959,12 +2959,6 @@ const Topology = /** @class */ (function () { this.subcribeAnimateMoved.unsubscribe() this.subcribeMediaEnd.unsubscribe() this.subcribeEmit.unsubscribe() - this.animateLayer.destroy() - this.divLayer.destroy() - this.canvas.destroy() - this.activeLayer.destroy() - this.hoverLayer.destroy() - this.offscreen.destroy() // document.body.removeChild(this.tipMarkdown) window.removeEventListener('resize', this.winResize) this.parentElem.removeEventListener('scroll', this.onScroll) @@ -2975,9 +2969,15 @@ const Topology = /** @class */ (function () { document.removeEventListener('keydown', this.onkeydown) break case KeydownType.Canvas: - this.divLayer.canvas.removeEventListener('keydown', this.onkeydown) + this.divLayer.canvas && this.divLayer.canvas.removeEventListener('keydown', this.onkeydown) break } + this.animateLayer.destroy() + this.divLayer.destroy() + this.canvas.destroy() + this.activeLayer.destroy() + this.hoverLayer.destroy() + this.offscreen.destroy() this.closeSocket() this.closeMqtt() if (this.socketFn) { @@ -2987,6 +2987,7 @@ const Topology = /** @class */ (function () { this.cache = null this.data = null console.log(this.options) + this.options.on = null window.topology = null this.activeLayer = null this.hoverLayer = null diff --git a/nezha-fronted/src/components/common/@topology/core/src/divLayer.js b/nezha-fronted/src/components/common/@topology/core/src/divLayer.js index 1f4b52e02..71ce29648 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/divLayer.js +++ b/nezha-fronted/src/components/common/@topology/core/src/divLayer.js @@ -82,7 +82,7 @@ const DivLayer = /** @class */ (function (_super) { _this.setElemPosition(node, _this.gifs[node.id]) } else { _this.addGif(node) - _this.setElemPosition(node, node.id) + _this.setElemPosition(node, node.img) } } } diff --git a/nezha-fronted/src/components/common/@topology/core/src/renderLayer.js b/nezha-fronted/src/components/common/@topology/core/src/renderLayer.js index 0f22af1b7..d78cb84df 100644 --- a/nezha-fronted/src/components/common/@topology/core/src/renderLayer.js +++ b/nezha-fronted/src/components/common/@topology/core/src/renderLayer.js @@ -24,7 +24,7 @@ const RenderLayer = /** @class */ (function (_super) { _this.options = options _this.render = function () { if (_this.data && _this.data.bkImage && !_this.bkImg) { - _this.loadBkImg(_this) + _this.loadBkImg(_this.render) return } if (!_this.width || !_this.height || !_this.offscreen) { @@ -46,6 +46,7 @@ const RenderLayer = /** @class */ (function (_super) { _this.rule() } ctx.drawImage(_this.offscreen, 0, 0, _this.width, _this.height) + return _this } _this.offscreen = Store.get(_this.generateStoreKey('LT:offscreen')) _this.parentElem.appendChild(_this.canvas) diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue index ece24ddfd..1c9c483ef 100644 --- a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -312,7 +312,8 @@ diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index 4558d056c..0777ec4ad 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -354,6 +354,7 @@ import { myCubeAnchors } from './L5/services/canvas.js' import { getTopology, setTopology, dealImg, topologyImg } from '../js/common' + import CanvasProps from './L5/CanvasProps' import topologyTopTool from './L5//topologyTopTool' import CanvasContextMenu from './L5/CanvasContextMenu' @@ -782,7 +783,7 @@ export default { return } if (!getTopology(this.topologyIndex)) { - let canvas = new Topology('topology-canvas' + this.topologyIndexF) + let canvas = new Topology('topology-canvas' + this.topologyIndexF, canvasOptions) // canvas.open(data) setTopology(this.topologyIndex, canvas) canvas = null