From 834df6cd83687e371df3e43d5421fab2f3bdeb46 Mon Sep 17 00:00:00 2001 From: "Ray.Hao" <1490493387@qq.com> Date: Mon, 23 Mar 2026 21:34:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(profile):=20=E9=87=8D=E6=9E=84=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=B8=AD=E5=BF=83=E9=A1=B5=E9=9D=A2=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=97=A5=E5=BF=97=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 重构个人中心页面布局和样式 - 优化日志模块类型定义和页面展示 - 添加用户统计接口 - 更新环境配置切换到线上API --- .env.development | 10 +- src/api/system/statistics.ts | 6 +- src/api/system/user.ts | 3 + src/components/NoticeDropdown/useNotice.ts | 2 +- src/types/api/log.ts | 44 +- src/views/login/index.vue | 4 +- src/views/profile/index.vue | 575 +++++++++++---------- src/views/system/log/index.vue | 100 +++- 8 files changed, 425 insertions(+), 319 deletions(-) diff --git a/.env.development b/.env.development index 48cb0df2..b302af98 100644 --- a/.env.development +++ b/.env.development @@ -6,13 +6,9 @@ VITE_APP_TITLE=vue3-element-admin VITE_APP_BASE_API=/dev-api # 接口地址 -# VITE_APP_API_URL=https://api.youlai.tech # 线上 -# VITE_APP_API_URL=https://api.youlai.tech/v2 # 线上(多租户) -VITE_APP_API_URL=http://localhost:8000 # 本地 - -# SSE 端点(默认 /api/v1/sse/connect) -# VITE_APP_SSE_ENDPOINT=/api/v1/sse/connect - +VITE_APP_API_URL=https://api.youlai.tech # 线上 +# VITE_APP_API_URL=https://api.youlai.tech/v2 # 线上(多租户) +# VITE_APP_API_URL=http://localhost:8000 # 本地 # 启用 Mock 服务(true:开启 false:关闭) VITE_MOCK_DEV_SERVER=false diff --git a/src/api/system/statistics.ts b/src/api/system/statistics.ts index 5e8357e6..901abf84 100644 --- a/src/api/system/statistics.ts +++ b/src/api/system/statistics.ts @@ -1,13 +1,13 @@ import request from "@/utils/request"; import type { VisitTrendQueryParams, VisitTrendDetail, VisitStatsDetail } from "@/types/api"; -const STATISTICS_BASE_URL = "/api/v1/statistics"; +const STATISTICS_BASE_URL = "/api/v1/logs"; const StatisticsAPI = { /** 获取访问趋势统计 */ getVisitTrend(queryParams: VisitTrendQueryParams) { return request({ - url: `${STATISTICS_BASE_URL}/visits/trend`, + url: `${STATISTICS_BASE_URL}/views/trend`, method: "get", params: queryParams, }); @@ -15,7 +15,7 @@ const StatisticsAPI = { /** 获取访问概览统计 */ getVisitOverview() { return request({ - url: `${STATISTICS_BASE_URL}/visits/overview`, + url: `${STATISTICS_BASE_URL}/views`, method: "get", }); }, diff --git a/src/api/system/user.ts b/src/api/system/user.ts index 10858b37..b4eaf605 100644 --- a/src/api/system/user.ts +++ b/src/api/system/user.ts @@ -11,6 +11,9 @@ import type { MobileUpdateForm, EmailUpdateForm, OptionItem, + UserEventQueryParams, + UserEventItem, + LoginDeviceItem, } from "@/types/api"; const USER_BASE_URL = "/api/v1/users"; diff --git a/src/components/NoticeDropdown/useNotice.ts b/src/components/NoticeDropdown/useNotice.ts index 6f1681e9..3b2a3fe2 100644 --- a/src/components/NoticeDropdown/useNotice.ts +++ b/src/components/NoticeDropdown/useNotice.ts @@ -67,7 +67,7 @@ export function useNotice() { // ============================================ function setupSubscription() { - if (unsubscribe || !isConnected.value) return; + if (unsubscribe) return; // 订阅新通知事件 unsubscribe = on(NOTICE_EVENT, (data: any) => { diff --git a/src/types/api/log.ts b/src/types/api/log.ts index fb502d10..7d74c7ae 100644 --- a/src/types/api/log.ts +++ b/src/types/api/log.ts @@ -6,7 +6,7 @@ import type { BaseQueryParams } from "./common"; /** 日志分页查询参数 */ export interface LogQueryParams extends BaseQueryParams { - /** 搜索关键字 */ + /** 搜索关键字(IP/操作人) */ keywords?: string; /** 操作时间 */ createTime?: [string, string]; @@ -15,29 +15,39 @@ export interface LogQueryParams extends BaseQueryParams { /** 日志分页对象 */ export interface LogItem { /** 日志ID */ - id: string; - /** 日志模块 */ - module: string; - /** 日志内容 */ - content: string; + id: number; + /** 模块 */ + module?: string; + /** 操作类型 */ + actionType?: string; + /** 操作标题 */ + title?: string; + /** 自定义日志内容 */ + content?: string; + /** 操作人ID */ + operatorId?: number; + /** 操作人名称 */ + operatorName?: string; /** 请求路径 */ requestUri?: string; /** 请求方法 */ - method?: string; + requestMethod?: string; /** IP地址 */ - ip: string; + ip?: string; /** 地区 */ - region: string; + region?: string; + /** 设备 */ + device?: string; /** 浏览器 */ - browser: string; - /** 终端系统 */ - os: string; + browser?: string; + /** 操作系统 */ + os?: string; + /** 状态:0失败 1成功 */ + status?: number; /** 执行时间(毫秒) */ - executionTime: number; - /** 创建人ID */ - createBy?: string; + executionTime?: number; + /** 错误信息 */ + errorMsg?: string; /** 操作时间 */ createTime?: string; - /** 操作人 */ - operator: string; } diff --git a/src/views/login/index.vue b/src/views/login/index.vue index e462834a..31149bcc 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -106,10 +106,10 @@ const formComponents = { display: flex; flex-direction: column; width: 100%; - height: auto; min-height: 100vh; padding: clamp(1rem, 3vw, 2rem); - overflow: hidden; + overflow-x: hidden; + overflow-y: auto; background-color: #f5f7ff; &::before { diff --git a/src/views/profile/index.vue b/src/views/profile/index.vue index 738ad3e6..d8126581 100644 --- a/src/views/profile/index.vue +++ b/src/views/profile/index.vue @@ -1,163 +1,195 @@  @@ -69,7 +118,18 @@ defineOptions({ import LogAPI from "@/api/system/log"; import type { LogItem, LogQueryParams } from "@/types/api"; -import type { FormInstance } from "element-plus"; +import type { FormInstance, TagProps } from "element-plus"; + +function getMethodTagType(method: string): TagProps["type"] { + const map: Record = { + GET: undefined, + POST: "success", + PUT: "warning", + DELETE: "danger", + PATCH: "info", + }; + return map[method?.toUpperCase()] ?? "info"; +} // 表单引用 const queryFormRef = ref(); @@ -87,9 +147,10 @@ const pageData = ref(); const total = ref(0); const loading = ref(false); -/** - * 加载日志列表数据 - */ +// 详情弹窗 +const detailVisible = ref(false); +const detailData = ref>({}); + function fetchData(): void { loading.value = true; LogAPI.getPage(queryParams) @@ -102,17 +163,11 @@ function fetchData(): void { }); } -/** - * 查询按钮点击事件 - */ function handleQuery(): void { queryParams.pageNum = 1; fetchData(); } -/** - * 重置查询 - */ function handleResetQuery(): void { queryFormRef.value?.resetFields(); queryParams.pageNum = 1; @@ -120,6 +175,11 @@ function handleResetQuery(): void { fetchData(); } +function handleDetail(row: LogItem): void { + detailData.value = row; + detailVisible.value = true; +} + onMounted(() => { handleQuery(); });