diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue index d2e55ac4e..ba9a23670 100644 --- a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -327,7 +327,7 @@ import { myCubec, myCubeAnchors } from '../project/L5/services/canvas.js' -import { getTopology, setTopology } from '../js/common' +import {getTopology, getTopologyImg, setTopology, setTopologyImg} from '../js/common' import CanvasProps from '../project/L5/CanvasProps' import topologyTopTool from '../project/L5/topologyTopTool' import popDataMain from '../project/popData/Main' @@ -1744,13 +1744,27 @@ export default { res.data.list.forEach((item, index) => { item.imageName = item.name delete item.name - promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.id}/1`)) + const nowImage = getTopologyImg(item.id) ? JSON.parse(getTopologyImg(item.id)) : '' + if (nowImage && nowImage.data) { + console.log(nowImage) + promiseArr.push(nowImage) + } else { + promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.id}/1`)) + } imgArr.push({ ...item }) }) Promise.all(promiseArr).then((res2, header) => { this.iconArray = [...res.data.list] this.iconArray.forEach((item, index) => { item.image = res2[index].data + const nowImage = getTopologyImg(item.id) ? JSON.parse(getTopologyImg(item.id)) : '' + if (!nowImage || (nowImage && !nowImage.data)) { + setTopologyImg(item.id, JSON.stringify({ + data: res2[index].data, + width: res2[index].width, + height: res2[index].height + })) + } const group = this.tools.find(tool => tool.group === item.unit) if (group) { group.children.push({ @@ -1801,7 +1815,12 @@ export default { } imgidList.forEach((item, index) => { if (item.data.imageId && imageAllId.data.list.find(image => item.data.imageId === image.id)) { - promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.data.imageId}/1`)) + const nowImage = getTopologyImg(item.data.imageId) ? JSON.parse(getTopologyImg(item.data.imageId)) : '' + if (nowImage && nowImage.data) { + promiseArr.push(nowImage) + } else { + promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.data.imageId}/1`)) + } } else if (item.data.imageId) { promiseArr.push(imgDefault) } else { @@ -1817,6 +1836,14 @@ export default { this.iconArray.forEach((item, index) => { if (item.id) { item.image = res2[index].data + const nowImage = getTopologyImg(item.id) ? JSON.parse(getTopologyImg(item.id)) : '' + if (!nowImage || (nowImage && !nowImage.image)) { + setTopologyImg(item.id, JSON.stringify({ + data: res2[index].data, + width: res2[index].width, + height: res2[index].height + })) + } } }) this.imgInit = true diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index 0e5a0676c..c57e7cd5e 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -3,7 +3,7 @@ @import "./L5/css/props.css";