diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue index 25b548a08..3455c6ce0 100644 --- a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -825,8 +825,9 @@ export default { opacity: data.data.opacity, name: data.name } - if (this.fromOverView) { // 优化从首页来的加载速度 + if (this.fromOverView || this.fromChartBox) { // 优化从首页来的加载速度 const arr = data.pens.filter(item => !item.type) + this.imgInit = false this.addNodeInit(arr) } const timer = setInterval(() => { @@ -1577,7 +1578,7 @@ export default { const group = this.tools.find(tool => tool.group === this.uploadPic.unit) this.iconArray.push({ ...iconInfo.data.list[0], - image: data + image: data.data }) if (group) { group.children.push({ @@ -1585,9 +1586,13 @@ export default { data: { ...imageTemp2.data, text: res.data.imageName, - image: data, + image: data.data, imageId: res.data.id, - unit: this.uploadPic.unit + unit: this.uploadPic.unit, + rect: { + width: data.width, + height: data.height + } } }) } else { @@ -1598,9 +1603,13 @@ export default { data: { ...imageTemp2.data, text: res.data.imageName, - image: data, + image: data.data, imageId: res.data.id, - unit: this.uploadPic.unit + unit: this.uploadPic.unit, + rect: { + width: data.width, + height: data.height + } } }] }) diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index 3ae46332d..fa9e29897 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -1588,7 +1588,7 @@ export default { const group = this.tools.find(tool => tool.group === this.uploadPic.unit) this.iconArray.push({ ...iconInfo.data.list[0], - image: data + image: data.data }) if (group) { group.children.push({ @@ -1598,7 +1598,11 @@ export default { text: res.data.imageName, image: data, imageId: res.data.id, - unit: this.uploadPic.unit + unit: this.uploadPic.unit, + rect: { + width: data.width, + height: data.height + } } }) } else { @@ -1611,7 +1615,11 @@ export default { text: res.data.imageName, image: data, imageId: res.data.id, - unit: this.uploadPic.unit + unit: this.uploadPic.unit, + rect: { + width: data.width, + height: data.height + } } }] }) @@ -1678,7 +1686,7 @@ export default { Promise.all(promiseArr).then((res2, header) => { this.iconArray = [...res.data.list] this.iconArray.forEach((item, index) => { - item.image = res2[index] + item.image = res2[index].data const group = this.tools.find(tool => tool.group === item.unit) if (group) { group.children.push({ @@ -1686,9 +1694,13 @@ export default { data: { ...imageTemp.data, text: item.imageName, - image: res2[index], + image: res2[index].data, imageId: item.id, - unit: item.unit + unit: item.unit, + rect: { + width: res2[index].width, + height: res2[index].height + } } }) } else { @@ -1701,7 +1713,11 @@ export default { text: item.imageName, image: res2[index], imageId: item.id, - unit: item.unit + unit: item.unit, + rect: { + width: res2[index].width, + height: res2[index].height + } } }] }) @@ -1733,7 +1749,7 @@ export default { }) this.iconArray.forEach((item, index) => { if (item.id) { - item.image = res2[index] + item.image = res2[index].data } }) this.imgInit = true @@ -1750,12 +1766,29 @@ export default { this.$axios .get(url) .then((res) => { - return { - data: ('data:image/jpeg;base64,' + res.data) + const imageInfo = { + data: ('data:image/jpeg;base64,' + res.data), + // width: res.headers.width === -1 ? 100 : (res.headers.width > 900 ? 900 : res.headers.width), + // height: res.headers.height === -1 ? 100 : (res.headers.height > 900 ? 900 : res.headers.height) + width: res.headers.width === -1 ? 100 : Number(res.headers.width), + height: res.headers.height === -1 ? 100 : Number(res.headers.height) } + if (imageInfo.width > 900 || imageInfo.height > 900) { + if (imageInfo.height > imageInfo.width) { + imageInfo.width = imageInfo.width * 900 / imageInfo.height + imageInfo.height = 900 + } else if (imageInfo.height < imageInfo.width) { + imageInfo.height = imageInfo.height * 900 / imageInfo.width + imageInfo.width = 900 + } else { + imageInfo.height = 900 + imageInfo.width = 900 + } + } + return imageInfo }) .then(data => { - resolve(data.data, data.header) + resolve(data) // changeImage(data,(img)=>{ // resolve(img) // })