From aee5b1f0c089413507df4ad4d2e731fb5d688251 Mon Sep 17 00:00:00 2001 From: zyh Date: Fri, 8 Sep 2023 10:19:07 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9tooltip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/chart/chartList.vue | 1 + .../src/components/chart/chartMixin.js | 23 ++++++++----------- .../common/alert/alertMessageInfo.vue | 7 +++++- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/nezha-fronted/src/components/chart/chartList.vue b/nezha-fronted/src/components/chart/chartList.vue index 22af7af49..23ddf8ebb 100644 --- a/nezha-fronted/src/components/chart/chartList.vue +++ b/nezha-fronted/src/components/chart/chartList.vue @@ -713,6 +713,7 @@ export default { bus.$off('creat-chart-success', this.createChartSuccess) bus.$off('groupChildMove', this.moveChart) window.removeEventListener('resize', this.resize) + document.onmousemove = null }, watch: { isShrink: { diff --git a/nezha-fronted/src/components/chart/chartMixin.js b/nezha-fronted/src/components/chart/chartMixin.js index 2274da12e..b1e3bb0b3 100644 --- a/nezha-fronted/src/components/chart/chartMixin.js +++ b/nezha-fronted/src/components/chart/chartMixin.js @@ -329,20 +329,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 e30d1cff6..57b86d035 100644 --- a/nezha-fronted/src/components/common/alert/alertMessageInfo.vue +++ b/nezha-fronted/src/components/common/alert/alertMessageInfo.vue @@ -64,8 +64,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, @@ -349,9 +350,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 } }