fix:修改 topology 内存溢出的问题

This commit is contained in:
zhangyu
2022-07-12 11:51:12 +08:00
parent 1ac93fd7a4
commit f8e1657824

View File

@@ -336,7 +336,9 @@
</template> </template>
<script> <script>
import { Topology, registerNode } from '@topology/core' import { Topology, registerNode } from '@/components/common/@topology/core/index.js'
import { Store as le5leStore } from 'le5le-store'
// import { Topology, registerNode } from '@topology/core'
import imgDefault from '@/components/common/project/L5/services/img' import imgDefault from '@/components/common/project/L5/services/img'
import { import {
Tools, Tools,
@@ -363,6 +365,7 @@ import endpointTable from './popData/endpointTable'
import topoTooltip from './L5/topoTooltip' import topoTooltip from './L5/topoTooltip'
import { getMetricTypeValue, dealLegendAlias } from '../js/tools' import { getMetricTypeValue, dealLegendAlias } from '../js/tools'
import bus from '../../../libs/bus' import bus from '../../../libs/bus'
// 注册到画布 // 注册到画布
registerNode('rectangleImg', myShape, myAnchors, myIconRect, myTextRect) registerNode('rectangleImg', myShape, myAnchors, myIconRect, myTextRect)
registerNode('myCube', myCubec, myCubeAnchors, null, null) registerNode('myCube', myCubec, myCubeAnchors, null, null)
@@ -2280,8 +2283,21 @@ export default {
this.timer4 = null this.timer4 = null
} }
if (getTopology(this.topologyIndex)) { if (getTopology(this.topologyIndex)) {
getTopology(this.topologyIndex).open({ pens: [] })
getTopology(this.topologyIndex).off('contextmenu', this.onContextMenu) getTopology(this.topologyIndex).off('contextmenu', this.onContextMenu)
getTopology(this.topologyIndex).destroy() getTopology(this.topologyIndex).destroy()
const StoreData = le5leStore.get()
const arr = []
Object.keys(StoreData).forEach(key => {
const id = key.split('-')[0]
arr.push(id)
if (getTopology(this.topologyIndex).id == id) {
le5leStore.set(key, null)
delete StoreData[key]
}
})
console.log(this.$loadsh.uniq(arr))
console.log(le5leStore.get())
Object.keys(getTopology(this.topologyIndex)).forEach(key => { Object.keys(getTopology(this.topologyIndex)).forEach(key => {
getTopology(this.topologyIndex)[key] = null getTopology(this.topologyIndex)[key] = null
}) })
@@ -2292,6 +2308,9 @@ export default {
} }
window.removeEventListener('resize', this.winResize) window.removeEventListener('resize', this.winResize)
window.removeEventListener('click', this.contextmenuNone) window.removeEventListener('click', this.contextmenuNone)
},
destroyed () {
} }
} }
</script> </script>