From b9da1e7f71173cfeac348d6863934c6be66cafca Mon Sep 17 00:00:00 2001
From: "Ray.Hao" <1490493387@qq.com>
Date: Thu, 6 Feb 2025 21:55:08 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=20:recycle:=20=E8=AE=BF=E9=97=AE?=
=?UTF-8?q?=E8=B6=8B=E5=8A=BF=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dashboard/components/visit-trend.vue | 34 +++++++------------
1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/src/views/dashboard/components/visit-trend.vue b/src/views/dashboard/components/visit-trend.vue
index 24fef6ad..b2ac7bad 100644
--- a/src/views/dashboard/components/visit-trend.vue
+++ b/src/views/dashboard/components/visit-trend.vue
@@ -23,7 +23,7 @@
-
+
@@ -32,33 +32,27 @@ import * as echarts from "echarts";
import LogAPI, { VisitTrendVO } from "@/api/system/log";
import { dayjs } from "element-plus";
-// 日期范围
-const recentDaysRange = ref(7);
-// 图表对象
-const chart: Ref = ref(null);
-
const props = defineProps({
id: {
type: String,
default: "VisitTrend",
},
- className: {
- type: String,
- default: "",
- },
width: {
type: String,
- default: "200px",
- required: true,
+ default: "100%",
},
height: {
type: String,
- default: "200px",
- required: true,
+ default: "500px",
},
});
-/** 设置图表 */
+// 日期范围
+const recentDaysRange = ref(7);
+// 图表对象
+const chart: Ref = ref(null);
+
+// 图表配置
const setChartOptions = (data: VisitTrendVO) => {
if (!chart.value) {
return;
@@ -69,7 +63,7 @@ const setChartOptions = (data: VisitTrendVO) => {
trigger: "axis",
},
legend: {
- data: ["浏览量(PV)", "IP"],
+ data: ["浏览量(PV)", "访客数(UV)"],
bottom: 0,
},
grid: {
@@ -108,7 +102,7 @@ const setChartOptions = (data: VisitTrendVO) => {
},
},
{
- name: "IP",
+ name: "访客数(UV)",
type: "line",
data: data.ipList,
areaStyle: {
@@ -194,14 +188,10 @@ const handleResize = () => {
onMounted(() => {
chart.value = markRaw(echarts.init(document.getElementById(props.id) as HTMLDivElement));
loadData();
-
+ // 监听窗口大小变化
window.addEventListener("resize", handleResize);
});
-onBeforeUnmount(() => {
- window.removeEventListener("resize", handleResize);
-});
-
onActivated(() => {
handleResize();
});