From ca3711e66da5dbfcc4af3e36e7495a409d584a10 Mon Sep 17 00:00:00 2001 From: "Ray.Hao" <1490493387@qq.com> Date: Sun, 5 Apr 2026 16:29:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E5=91=BD=E5=90=8D=20LogAP?= =?UTF-8?q?I=20=E6=8E=A5=E5=8F=A3=E5=8F=8A=E7=B1=BB=E5=9E=8B=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E4=BB=A5=E4=BC=98=E5=8C=96=E8=AF=AD=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/log.ts | 8 +++----- src/pages/index/index.vue | 24 +++++++++++------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/api/log.ts b/src/api/log.ts index ae65a5e..6dee565 100644 --- a/src/api/log.ts +++ b/src/api/log.ts @@ -35,8 +35,8 @@ const LogAPI = { * * @returns 访问概览数据 */ - getVisitStats() { - return request({ + getVisitOverview() { + return request({ url: `${LOG_BASE_URL}/analytics/overview`, method: "GET", }); @@ -103,8 +103,6 @@ export interface VisitTrend { pvList: number[]; /** 访客数(UV) */ uvList: number[]; - /** IP数 */ - ipList: number[]; } /** 访问趋势查询参数 */ @@ -116,7 +114,7 @@ export interface VisitTrendQuery { } /** 访问统计 */ -export interface VisitStats { +export interface VisitOverview { /** 今日访客数(UV) */ todayUvCount: number; /** 总访客数 */ diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 4591bc9..9326238 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -52,7 +52,7 @@ - {{ visitStatsData.todayUvCount }} + {{ visitOverviewData.todayUvCount }} @@ -62,7 +62,7 @@ - {{ visitStatsData.todayPvCount }} + {{ visitOverviewData.todayPvCount }} @@ -102,14 +102,14 @@ import { useRouter } from "uni-mini-router"; import { useUserStore } from "@/store"; import { menuConfig } from "@/config/menu"; import { checkLogin, isLoggedIn } from "@/utils/auth"; -import LogAPI, { type VisitStats as ApiVisitStats, type VisitTrend } from "@/api/log"; +import LogAPI, { type VisitOverview as ApiVisitOverview, type VisitTrend } from "@/api/log"; import NoticeAPI, { type NoticeItem } from "@/api/notice"; // ============================================================================ // 类型定义 // ============================================================================ -type VisitStatsVO = ApiVisitStats; +type VisitOverviewVO = ApiVisitOverview; interface NavItem { icon: string; @@ -135,7 +135,7 @@ const recentDaysRange = ref(7); const swiperList = ref(["https://www.youlai.tech/storage/blog/banner9.png"]); -const visitStatsData = ref({ +const visitOverviewData = ref({ todayUvCount: 0, uvGrowthRate: 0, totalUvCount: 0, @@ -257,9 +257,9 @@ async function loadNoticeData() { } } -async function loadVisitStatsData() { +async function loadVisitOverviewData() { try { - visitStatsData.value = await LogAPI.getVisitStats(); + visitOverviewData.value = await LogAPI.getVisitOverview(); } catch { // ignore } @@ -323,11 +323,9 @@ function handleNoticeClick() { router.push({ path: "/pages/work/notice/index" }); } -function handleSwiperClick(_e: any) { -} +function handleSwiperClick(_e: any) {} -function handleSwiperChange(_e: any) { -} +function handleSwiperChange(_e: any) {} function handleDataRangeChange({ value }: { value: number }) { recentDaysRange.value = value; @@ -341,13 +339,13 @@ function handleDataRangeChange({ value }: { value: number }) { onReady(() => { loadAppVersion(); loadNoticeData(); - loadVisitStatsData(); + loadVisitOverviewData(); loadVisitTrendData(); }); // 每次页面显示时刷新数据(登录后跳转回来也能更新) onShow(() => { - loadVisitStatsData(); + loadVisitOverviewData(); loadVisitTrendData(); });