diff --git a/nezha-fronted/src/components/chart/chartMixin.js b/nezha-fronted/src/components/chart/chartMixin.js index 8e2c28bf9..cfb60aafa 100644 --- a/nezha-fronted/src/components/chart/chartMixin.js +++ b/nezha-fronted/src/components/chart/chartMixin.js @@ -360,20 +360,17 @@ export default { // 提示框大小 const boxWidth = size.contentSize[0] const boxHeight = size.contentSize[1] - const chartDom = document.getElementById('chart-local-' + this.chartInfo.id) - if (chartDom) { - if (windowMouse.x < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框 - x = pointX + 15 - } else { - x = pointX - boxWidth - 15 - } - if (windowMouse.y + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框 - y = pointY + 15 - } else { - y = pointY - boxHeight - 10 - } - return [x, y] + if (windowMouse.x < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框 + x = pointX + 15 + } else { + x = pointX - boxWidth - 15 } + if (windowMouse.y + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框 + y = pointY + 15 + } else { + y = pointY - boxHeight - 10 + } + return [x, y] }, mouseLeaveChart () { const myChart = getChart(this.chartId) diff --git a/nezha-fronted/src/components/common/alert/alertMessageInfo.vue b/nezha-fronted/src/components/common/alert/alertMessageInfo.vue index 3b4ee4e63..c7502d8a7 100644 --- a/nezha-fronted/src/components/common/alert/alertMessageInfo.vue +++ b/nezha-fronted/src/components/common/alert/alertMessageInfo.vue @@ -67,8 +67,9 @@ import logsData from '@/components/chart/logsData' import lodash from 'lodash' import alertMessageInfoTab from '@/components/common/alert/alertMessageInfoTab' import alertMessageInfoTimeLine from '@/components/common/alert/alertMessageInfoTimeLine' +import { lineChartMove } from '@/components/common/js/common' export default { - name: 'panelChart', + name: 'alertMessageInfo', components: { alertMessageInfoTab, chart, @@ -354,9 +355,13 @@ export default { this.showAllData = !this.showMultiple(this.chartInfo.type) this.getAlertMessageInfo() window.addEventListener('resize', this.resize) + if (!document.onmousemove) { // 添加鼠标移动事件监听 + document.onmousemove = lineChartMove + } }, destroyed () { window.removeEventListener('resize', this.resize) + document.onmousemove = null } }