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 @@ - +