From 00d06de84f287e03346b4f2553ec91a94c1e49c9 Mon Sep 17 00:00:00 2001 From: "Ray.Hao" <1490493387@qq.com> Date: Sun, 5 Apr 2026 16:20:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=8F=8A=E5=B1=95=E7=A4=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E5=AD=97=E6=AE=B5=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E4=B8=8EUI=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/log.mock.ts | 3 +- pnpm-lock.yaml | 3 ++ src/api/auth/index.ts | 5 +-- src/api/system/log/index.ts | 4 +- src/api/system/log/types.ts | 6 +-- src/composables/sse/useSse.ts | 8 ++-- src/views/dashboard/index.vue | 68 ++++++++++++++--------------- src/views/system/dict/dict-item.vue | 2 +- src/views/system/user/index.vue | 2 +- 9 files changed, 49 insertions(+), 52 deletions(-) diff --git a/mock/log.mock.ts b/mock/log.mock.ts index 3f865132..b800e52c 100644 --- a/mock/log.mock.ts +++ b/mock/log.mock.ts @@ -181,8 +181,7 @@ export default defineMock([ "2024-07-07", ], pvList: [1751, 5168, 4882, 5301, 4721, 4885, 1901, 1003], - uvList: null, - ipList: [207, 566, 565, 631, 579, 496, 222, 152], + uvList: [207, 566, 565, 631, 579, 496, 222, 152], }, msg: "一切ok", }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2d486932..44153f56 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -205,6 +205,9 @@ devDependencies: vite-plugin-mock-dev-server: specifier: ^2.1.1 version: 2.1.1(vite@8.0.3) + vue-eslint-parser: + specifier: ^10.4.0 + version: 10.4.0(eslint@10.1.0) vue-tsc: specifier: ^3.2.5 version: 3.2.6(typescript@5.9.3) diff --git a/src/api/auth/index.ts b/src/api/auth/index.ts index b41b40a8..be8c4852 100644 --- a/src/api/auth/index.ts +++ b/src/api/auth/index.ts @@ -36,13 +36,10 @@ const AuthAPI = { /** 刷新 token 接口*/ refreshToken(refreshToken: string) { - const params = new URLSearchParams(); - params.append("refresh_token", refreshToken); - return request({ url: `${AUTH_BASE_URL}/refresh-token`, method: "post", - data: params, + params: { refreshToken }, headers: { Authorization: "no-auth", }, diff --git a/src/api/system/log/index.ts b/src/api/system/log/index.ts index d5ea1523..99af549d 100644 --- a/src/api/system/log/index.ts +++ b/src/api/system/log/index.ts @@ -4,7 +4,7 @@ import type { LogItem, VisitTrendQueryParams, VisitTrendDetail, - VisitStatsDetail, + VisitOverviewDetail, } from "./types"; const LOG_BASE_URL = "/api/v1/logs"; @@ -30,7 +30,7 @@ const LogAPI = { /** 获取访问概览统计 */ getVisitOverview() { - return request({ + return request({ url: `${LOG_BASE_URL}/analytics/overview`, method: "get", }); diff --git a/src/api/system/log/types.ts b/src/api/system/log/types.ts index 11ec868f..871a715a 100644 --- a/src/api/system/log/types.ts +++ b/src/api/system/log/types.ts @@ -68,12 +68,10 @@ export interface VisitTrendDetail { pvList: number[]; /** 访客数(UV)列表 */ uvList: number[]; - /** IP数列表 */ - ipList: number[]; } -/** 访问量统计视图对象 */ -export interface VisitStatsDetail { +/** 访问概览视图对象 */ +export interface VisitOverviewDetail { /** 今日独立访客数(UV) */ todayUvCount: number; /** 累计独立访客数(UV) */ diff --git a/src/composables/sse/useSse.ts b/src/composables/sse/useSse.ts index 3e9d921a..700b4592 100644 --- a/src/composables/sse/useSse.ts +++ b/src/composables/sse/useSse.ts @@ -132,6 +132,8 @@ function createSseConnection(options: UseSseOptions = {}) { reader = r; const decoder = new TextDecoder(); let buffer = ""; + let currentEvent = "message"; + let currentData = ""; // SSE 文本协议解析:event / data / 空行分隔 const processChunk = ({ @@ -148,15 +150,13 @@ function createSseConnection(options: UseSseOptions = {}) { const lines = buffer.split("\n"); buffer = lines.pop() || ""; - let currentEvent = "message"; - let currentData = ""; - for (const line of lines) { if (line.startsWith(":")) continue; if (line.startsWith("event:")) { currentEvent = line.slice(6).trim(); } else if (line.startsWith("data:")) { - currentData = line.slice(5).trim(); + const dataLine = line.slice(5).trim(); + currentData = currentData ? `${currentData}\n${dataLine}` : dataLine; } else if (line === "") { if (currentData) { const handlers = eventHandlers.get(currentEvent); diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index cbafd7a1..95da2120 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -159,7 +159,7 @@ - +