From a5885d07104edae800596a93d0c48f197a500264 Mon Sep 17 00:00:00 2001 From: "Ray.Hao" <1490493387@qq.com> Date: Fri, 9 Jan 2026 00:07:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0API=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=B8=8E=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=EF=BC=8C?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=88=86=E9=A1=B5=E8=BF=94=E5=9B=9E=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/ai.mock.ts | 100 ++--- mock/dept.mock.ts | 12 +- mock/dict.mock.ts | 130 +++--- mock/log.mock.ts | 310 +++++++-------- mock/notice.mock.ts | 374 +++++++++--------- mock/role.mock.ts | 192 ++++----- mock/user.mock.ts | 60 +-- src/api/ai.ts | 8 +- src/api/codegen.ts | 10 +- src/api/system/config.ts | 8 +- src/api/system/dept.ts | 12 +- src/api/system/dict.ts | 117 +++++- src/api/system/log.ts | 8 +- src/api/system/menu.ts | 14 +- src/api/system/notice.ts | 14 +- src/api/system/role.ts | 10 +- src/api/system/statistics.ts | 8 +- src/api/system/tenant.ts | 16 +- src/api/system/user.ts | 19 +- src/components/CURD/PageContent.vue | 10 +- src/components/CURD/types.ts | 15 +- src/components/NoticeDropdown/useNotice.ts | 20 +- src/components/TableSelect/index.vue | 6 +- src/enums/codegen.ts | 4 +- src/layouts/components/LayoutSettings.vue | 5 +- src/store/modules/permission.ts | 4 +- src/types/api/ai.ts | 8 +- src/types/api/codegen.ts | 8 +- src/types/api/common.ts | 35 +- src/types/api/config.ts | 6 +- src/types/api/dept.ts | 6 +- src/types/api/dict.ts | 12 +- src/types/api/log.ts | 6 +- src/types/api/menu.ts | 10 +- src/types/api/notice.ts | 8 +- src/types/api/role.ts | 6 +- src/types/api/statistics.ts | 6 +- src/types/api/tenant.ts | 8 +- src/types/api/user.ts | 8 +- src/types/components.d.ts | 2 +- src/types/global.d.ts | 4 +- src/utils/request.ts | 20 + src/views/ai/index.vue | 18 +- src/views/codegen/index.vue | 20 +- src/views/dashboard/index.vue | 6 +- src/views/demo/curd-single.vue | 22 +- src/views/demo/curd/config/content.ts | 14 +- src/views/demo/curd/config/options.ts | 10 +- src/views/demo/curd/config2/content.ts | 96 +++-- src/views/login/components/Login.vue | 5 +- src/views/login/index.vue | 3 +- src/views/profile/index.vue | 4 +- src/views/profile/notice/index.vue | 14 +- src/views/system/config/index.vue | 12 +- src/views/system/dept/index.vue | 8 +- src/views/system/dict/dict-item.vue | 14 +- src/views/system/dict/index.vue | 18 +- src/views/system/log/index.vue | 12 +- src/views/system/menu/index.vue | 10 +- src/views/system/notice/index.vue | 16 +- src/views/system/role/index.vue | 18 +- src/views/system/tenant/index.vue | 12 +- .../system/user/components/UserDeptTree.vue | 2 +- src/views/system/user/index.vue | 22 +- 64 files changed, 1085 insertions(+), 910 deletions(-) diff --git a/mock/ai.mock.ts b/mock/ai.mock.ts index b9142cbe..8f54b83f 100644 --- a/mock/ai.mock.ts +++ b/mock/ai.mock.ts @@ -47,55 +47,57 @@ export default defineMock([ return { code: "00000", - data: { - list: [ - { - id: "10001", - userId: 1, - username: "admin", - originalCommand: "跳转到用户管理", - aiProvider: "qwen", - aiModel: "qwen-plus", - parseStatus: 1, - functionCalls: JSON.stringify( - [ - { - name: "navigate", - arguments: { path: "/system/user" }, - }, - ], - null, - 0 - ), - explanation: "Mock: 识别到跳转用户管理", - confidence: 0.92, - parseDurationMs: 128, - functionName: "navigate", - functionArguments: JSON.stringify({ path: "/system/user" }), - executeStatus: 1, - ipAddress: "127.0.0.1", - createTime: "2025-12-17 15:00:00", - updateTime: "2025-12-17 15:00:00", - }, - { - id: "10002", - userId: 1, - username: "admin", - originalCommand: "获取姓名为张三的用户信息", - aiProvider: "qwen", - aiModel: "qwen-plus", - parseStatus: 0, - functionCalls: "[]", - explanation: "Mock: 解析失败示例", - confidence: 0.2, - parseErrorMessage: "Mock: 无法匹配函数", - parseDurationMs: 256, - executeStatus: 0, - ipAddress: "127.0.0.1", - createTime: "2025-12-17 15:01:00", - updateTime: "2025-12-17 15:01:00", - }, - ].slice((pageNum - 1) * pageSize, pageNum * pageSize), + data: [ + { + id: "10001", + userId: 1, + username: "admin", + originalCommand: "跳转到用户管理", + aiProvider: "qwen", + aiModel: "qwen-plus", + parseStatus: 1, + functionCalls: JSON.stringify( + [ + { + name: "navigate", + arguments: { path: "/system/user" }, + }, + ], + null, + 0 + ), + explanation: "Mock: 识别到跳转用户管理", + confidence: 0.92, + parseDurationMs: 128, + functionName: "navigate", + functionArguments: JSON.stringify({ path: "/system/user" }), + executeStatus: 1, + ipAddress: "127.0.0.1", + createTime: "2025-12-17 15:00:00", + updateTime: "2025-12-17 15:00:00", + }, + { + id: "10002", + userId: 1, + username: "admin", + originalCommand: "获取姓名为张三的用户信息", + aiProvider: "qwen", + aiModel: "qwen-plus", + parseStatus: 0, + functionCalls: "[]", + explanation: "Mock: 解析失败示例", + confidence: 0.2, + parseErrorMessage: "Mock: 无法匹配函数", + parseDurationMs: 256, + executeStatus: 0, + ipAddress: "127.0.0.1", + createTime: "2025-12-17 15:01:00", + updateTime: "2025-12-17 15:01:00", + }, + ].slice((pageNum - 1) * pageSize, pageNum * pageSize), + page: { + pageNum, + pageSize, total, }, msg: "一切ok", diff --git a/mock/dept.mock.ts b/mock/dept.mock.ts index e9b6d1bb..542a6c1d 100644 --- a/mock/dept.mock.ts +++ b/mock/dept.mock.ts @@ -2,7 +2,7 @@ import { defineMock } from "./base"; export default defineMock([ { - url: "dept/options", + url: "depts/options", method: ["GET"], body: { code: "00000", @@ -27,7 +27,7 @@ export default defineMock([ }, { - url: "dept", + url: "depts", method: ["GET"], body: { code: "00000", @@ -73,7 +73,7 @@ export default defineMock([ // 新增部门 { - url: "dept", + url: "depts", method: ["POST"], body({ body }) { return { @@ -86,7 +86,7 @@ export default defineMock([ // 获取部门表单数据 { - url: "dept/:id/form", + url: "depts/:id/form", method: ["GET"], body: ({ params }) => { return { @@ -99,7 +99,7 @@ export default defineMock([ // 修改部门 { - url: "dept/:id", + url: "depts/:id", method: ["PUT"], body({ body }) { return { @@ -112,7 +112,7 @@ export default defineMock([ // 删除部门 { - url: "dept/:id", + url: "depts/:id", method: ["DELETE"], body({ params }) { return { diff --git a/mock/dict.mock.ts b/mock/dict.mock.ts index c108bb55..17ec1325 100644 --- a/mock/dict.mock.ts +++ b/mock/dict.mock.ts @@ -2,19 +2,21 @@ import { defineMock } from "./base"; export default defineMock([ { - url: "dicts/page", + url: "dicts", method: ["GET"], body: { code: "00000", - data: { - list: [ - { - id: 1, - name: "性别", - dictCode: "gender", - status: 1, - }, - ], + data: [ + { + id: 1, + name: "性别", + dictCode: "gender", + status: 1, + }, + ], + page: { + pageNum: 1, + pageSize: 10, total: 1, }, msg: "一切ok", @@ -25,19 +27,16 @@ export default defineMock([ * 字典列表 */ { - url: "dicts", + url: "dicts/options", method: ["GET"], body: { code: "00000", - data: { - list: [ - { - value: "gender", - label: "性别", - }, - ], - total: 1, - }, + data: [ + { + value: "gender", + label: "性别", + }, + ], msg: "一切ok", }, }, @@ -100,37 +99,42 @@ export default defineMock([ // 字典项分页列表 { - url: "dicts/:dictCode/items/page", + url: "dicts/:dictCode/items", method: ["GET"], body: { code: "00000", - data: { - list: [ - { - id: 1, - dictCode: "gender", - label: "男", - value: "1", - sort: 1, - status: 1, - }, - { - id: 2, - dictCode: "gender", - label: "女", - value: "2", - sort: 2, - status: 1, - }, - { - id: 3, - dictCode: "gender", - label: "保密", - value: "0", - sort: 3, - status: 1, - }, - ], + data: [ + { + id: 1, + dictCode: "gender", + label: "男", + value: "1", + sort: 1, + status: 1, + tagType: "P", + }, + { + id: 2, + dictCode: "gender", + label: "女", + value: "2", + sort: 2, + status: 1, + tagType: "D", + }, + { + id: 3, + dictCode: "gender", + label: "保密", + value: "0", + sort: 3, + status: 1, + tagType: "I", + }, + ], + page: { + pageNum: 1, + pageSize: 10, total: 3, }, msg: "一切ok", @@ -138,7 +142,7 @@ export default defineMock([ }, // 字典项列表 { - url: "dicts/:dictCode/items", + url: "dicts/:dictCode/items/options", method: ["GET"], body: ({ params }) => { const dictCode = params.dictCode; @@ -165,17 +169,17 @@ export default defineMock([ { value: "L", label: "低", - tag: "info", + tagType: "I", }, { value: "M", label: "中", - tag: "warning", + tagType: "W", }, { value: "H", label: "高", - tag: "danger", + tagType: "D", }, ]; } else if (dictCode == "notice_type") { @@ -183,32 +187,32 @@ export default defineMock([ { value: "1", label: "系统升级", - tag: "success", + tagType: "S", }, { value: "2", label: "系统维护", - tag: "primary", + tagType: "P", }, { value: "3", label: "安全警告", - tag: "danger", + tagType: "D", }, { value: "4", label: "假期通知", - tag: "success", + tagType: "S", }, { value: "5", label: "公司新闻", - tag: "primary", + tagType: "P", }, { value: "99", label: "其他", - tag: "info", + tagType: "I", }, ]; } @@ -228,7 +232,7 @@ export default defineMock([ return { code: "00000", data: null, - msg: "新增字典" + body.name + "成功", + msg: "新增字典项" + body.label + "成功", }; }, }, @@ -254,7 +258,7 @@ export default defineMock([ return { code: "00000", data: null, - msg: "修改字典项" + body.name + "成功", + msg: "修改字典项" + body.label + "成功", }; }, }, @@ -291,7 +295,7 @@ const dictItemMap: Record = { label: "男", sort: 1, status: 1, - tagType: "primary", + tagType: "P", }, 2: { id: 2, @@ -299,7 +303,7 @@ const dictItemMap: Record = { label: "女", sort: 2, status: 1, - tagType: "danger", + tagType: "D", }, 3: { id: 3, @@ -307,6 +311,6 @@ const dictItemMap: Record = { label: "保密", sort: 3, status: 1, - tagType: "info", + tagType: "I", }, }; diff --git a/mock/log.mock.ts b/mock/log.mock.ts index d76f9f9b..2583e8dd 100644 --- a/mock/log.mock.ts +++ b/mock/log.mock.ts @@ -2,163 +2,165 @@ import { defineMock } from "./base"; export default defineMock([ { - url: "logs/page", + url: "logs", method: ["GET"], body: { code: "00000", - data: { - list: [ - { - id: 36192, - module: "菜单", - content: "菜单列表", - requestUri: "/api/v1/menus", - method: null, - ip: "183.156.148.241", - region: "浙江省 杭州市", - browser: "Chrome 109.0.0.0", - os: "OSX", - executionTime: 5, - createBy: null, - createTime: "2024-07-07 20:38:47", - operator: "系统管理员", - }, - { - id: 36190, - module: "字典", - content: "字典分页列表", - requestUri: "/api/v1/dict/page", - method: null, - ip: "183.156.148.241", - region: "浙江省 杭州市", - browser: "Chrome 109.0.0.0", - os: "OSX", - executionTime: 9, - createBy: null, - createTime: "2024-07-07 20:38:45", - operator: "系统管理员", - }, - { - id: 36193, - module: "部门", - content: "部门列表", - requestUri: "/api/v1/dept", - method: null, - ip: "192.168.31.134", - region: "0 内网IP", - browser: "Chrome 125.0.0.0", - os: "Windows 10 or Windows Server 2016", - executionTime: 27, - createBy: null, - createTime: "2024-07-07 20:38:45", - operator: "系统管理员", - }, - { - id: 36191, - module: "菜单", - content: "菜单列表", - requestUri: "/api/v1/menus", - method: null, - ip: "192.168.31.134", - region: "0 内网IP", - browser: "Chrome 125.0.0.0", - os: "Windows 10 or Windows Server 2016", - executionTime: 39, - createBy: null, - createTime: "2024-07-07 20:38:44", - operator: "系统管理员", - }, - { - id: 36189, - module: "角色", - content: "角色分页列表", - requestUri: "/api/v1/roles/page", - method: null, - ip: "192.168.31.134", - region: "0 内网IP", - browser: "Chrome 125.0.0.0", - os: "Windows 10 or Windows Server 2016", - executionTime: 55, - createBy: null, - createTime: "2024-07-07 20:38:43", - operator: "系统管理员", - }, - { - id: 36188, - module: "用户", - content: "用户分页列表", - requestUri: "/api/v1/users/page", - method: null, - ip: "192.168.31.134", - region: "0 内网IP", - browser: "Chrome 125.0.0.0", - os: "Windows 10 or Windows Server 2016", - executionTime: 92, - createBy: null, - createTime: "2024-07-07 20:38:42", - operator: "系统管理员", - }, - { - id: 36187, - module: "登录", - content: "登录", - requestUri: "/api/v1/auth/login", - method: null, - ip: "192.168.31.134", - region: "0 内网IP", - browser: "Chrome 125.0.0.0", - os: "Windows 10 or Windows Server 2016", - executionTime: 19340, - createBy: null, - createTime: "2024-07-07 20:38:09", - operator: "系统管理员", - }, - { - id: 36186, - module: "登录", - content: "登录", - requestUri: "/api/v1/auth/login", - method: null, - ip: "192.168.31.134", - region: "0 内网IP", - browser: "Chrome 125.0.0.0", - os: "Windows 10 or Windows Server 2016", - executionTime: 19869, - createBy: null, - createTime: "2024-07-07 20:37:59", - operator: "系统管理员", - }, - { - id: 36185, - module: "登录", - content: "登录", - requestUri: "/api/v1/auth/login", - method: null, - ip: "112.103.111.59", - region: "黑龙江省 哈尔滨市", - browser: "Chrome 97.0.4692.98", - os: "Android", - executionTime: 96, - createBy: null, - createTime: "2024-07-07 20:37:21", - operator: "系统管理员", - }, - { - id: 36184, - module: "登录", - content: "登录", - requestUri: "/api/v1/auth/login", - method: null, - ip: "114.86.204.190", - region: "上海 上海市", - browser: "Chrome 125.0.0.0", - os: "Windows 10 or Windows Server 2016", - executionTime: 89, - createBy: null, - createTime: "2024-07-07 20:29:37", - operator: "系统管理员", - }, - ], + data: [ + { + id: 36192, + module: "菜单", + content: "菜单列表", + requestUri: "/api/v1/menus", + method: null, + ip: "183.156.148.241", + region: "浙江省 杭州市", + browser: "Chrome 109.0.0.0", + os: "OSX", + executionTime: 5, + createBy: null, + createTime: "2024-07-07 20:38:47", + operator: "系统管理员", + }, + { + id: 36190, + module: "字典", + content: "字典分页列表", + requestUri: "/api/v1/dicts", + method: null, + ip: "183.156.148.241", + region: "浙江省 杭州市", + browser: "Chrome 109.0.0.0", + os: "OSX", + executionTime: 9, + createBy: null, + createTime: "2024-07-07 20:38:45", + operator: "系统管理员", + }, + { + id: 36193, + module: "部门", + content: "部门列表", + requestUri: "/api/v1/depts", + method: null, + ip: "192.168.31.134", + region: "0 内网IP", + browser: "Chrome 125.0.0.0", + os: "Windows 10 or Windows Server 2016", + executionTime: 27, + createBy: null, + createTime: "2024-07-07 20:38:45", + operator: "系统管理员", + }, + { + id: 36191, + module: "菜单", + content: "菜单列表", + requestUri: "/api/v1/menus", + method: null, + ip: "192.168.31.134", + region: "0 内网IP", + browser: "Chrome 125.0.0.0", + os: "Windows 10 or Windows Server 2016", + executionTime: 39, + createBy: null, + createTime: "2024-07-07 20:38:44", + operator: "系统管理员", + }, + { + id: 36189, + module: "角色", + content: "角色分页列表", + requestUri: "/api/v1/roles", + method: null, + ip: "192.168.31.134", + region: "0 内网IP", + browser: "Chrome 125.0.0.0", + os: "Windows 10 or Windows Server 2016", + executionTime: 55, + createBy: null, + createTime: "2024-07-07 20:38:43", + operator: "系统管理员", + }, + { + id: 36188, + module: "用户", + content: "用户分页列表", + requestUri: "/api/v1/users", + method: null, + ip: "192.168.31.134", + region: "0 内网IP", + browser: "Chrome 125.0.0.0", + os: "Windows 10 or Windows Server 2016", + executionTime: 92, + createBy: null, + createTime: "2024-07-07 20:38:42", + operator: "系统管理员", + }, + { + id: 36187, + module: "登录", + content: "登录", + requestUri: "/api/v1/auth/login", + method: null, + ip: "192.168.31.134", + region: "0 内网IP", + browser: "Chrome 125.0.0.0", + os: "Windows 10 or Windows Server 2016", + executionTime: 19340, + createBy: null, + createTime: "2024-07-07 20:38:09", + operator: "系统管理员", + }, + { + id: 36186, + module: "登录", + content: "登录", + requestUri: "/api/v1/auth/login", + method: null, + ip: "192.168.31.134", + region: "0 内网IP", + browser: "Chrome 125.0.0.0", + os: "Windows 10 or Windows Server 2016", + executionTime: 19869, + createBy: null, + createTime: "2024-07-07 20:37:59", + operator: "系统管理员", + }, + { + id: 36185, + module: "登录", + content: "登录", + requestUri: "/api/v1/auth/login", + method: null, + ip: "112.103.111.59", + region: "黑龙江省 哈尔滨市", + browser: "Chrome 97.0.4692.98", + os: "Android", + executionTime: 96, + createBy: null, + createTime: "2024-07-07 20:37:21", + operator: "系统管理员", + }, + { + id: 36184, + module: "登录", + content: "登录", + requestUri: "/api/v1/auth/login", + method: null, + ip: "114.86.204.190", + region: "上海 上海市", + browser: "Chrome 125.0.0.0", + os: "Windows 10 or Windows Server 2016", + executionTime: 89, + createBy: null, + createTime: "2024-07-07 20:29:37", + operator: "系统管理员", + }, + ], + page: { + pageNum: 1, + pageSize: 10, total: 36188, }, msg: "一切ok", diff --git a/mock/notice.mock.ts b/mock/notice.mock.ts index 840010bc..276c211e 100644 --- a/mock/notice.mock.ts +++ b/mock/notice.mock.ts @@ -2,143 +2,145 @@ import { defineMock } from "./base"; export default defineMock([ { - url: "notices/page", + url: "notices", method: ["GET"], body: { code: "00000", - data: { - list: [ - { - id: 1, - title: "v2.12.0 新增系统日志,访问趋势统计功能。", - publishStatus: 1, - type: 1, - publisherName: "系统管理员", - level: "L", - publishTime: "2024-09-30 17:21", - isRead: null, - targetType: 1, - createTime: "2024-09-28 11:21", - revokeTime: "2024-09-30 17:21", - }, - { - id: 2, - title: "v2.13.0 新增菜单搜索。", - publishStatus: 1, - type: 1, - publisherName: "系统管理员", - level: "L", - publishTime: "2024-09-30 17:22", - isRead: null, - targetType: 1, - createTime: "2024-09-28 11:21", - revokeTime: "2024-09-30 17:21", - }, - { - id: 3, - title: "\r\nv2.14.0 新增个人中心。", - publishStatus: 1, - type: 1, - publisherName: "系统管理员", - level: "L", - publishTime: "2024-09-30 17:23", - isRead: null, - targetType: 1, - createTime: "2024-09-28 11:21", - revokeTime: "2024-09-30 17:21", - }, - { - id: 4, - title: "v2.15.0 登录页面改造。", - publishStatus: 1, - type: 1, - publisherName: "系统管理员", - level: "L", - publishTime: "2024-09-30 17:24", - isRead: null, - targetType: 1, - createTime: "2024-09-28 11:21", - revokeTime: "2024-09-30 17:21", - }, - { - id: 5, - title: "v2.16.0 通知公告、字典翻译组件。", - publishStatus: 1, - type: 1, - publisherName: "系统管理员", - level: "L", - publishTime: "2024-09-30 17:25", - isRead: null, - targetType: 1, - createTime: "2024-09-28 11:21", - revokeTime: "2024-09-30 17:21", - }, - { - id: 6, - title: "系统将于本周六凌晨 2 点进行维护,预计维护时间为 2 小时。", - publishStatus: 1, - type: 2, - publisherName: "系统管理员", - level: "L", - publishTime: "2024-09-30 17:26", - isRead: null, - targetType: 1, - createTime: "2024-09-28 11:21", - revokeTime: "2024-09-30 17:21", - }, - { - id: 7, - title: "最近发现一些钓鱼邮件,请大家提高警惕,不要点击陌生链接。", - publishStatus: 1, - type: 3, - publisherName: "系统管理员", - level: "L", - publishTime: "2024-09-30 17:27", - isRead: null, - targetType: 1, - createTime: "2024-09-28 11:21", - revokeTime: "2024-09-30 17:21", - }, - { - id: 8, - title: "国庆假期从 10 月 1 日至 10 月 7 日放假,共 7 天。", - publishStatus: 1, - type: 4, - publisherName: "系统管理员", - level: "L", - publishTime: "2024-09-30 17:28", - isRead: null, - targetType: 1, - createTime: "2024-09-28 11:21", - revokeTime: "2024-09-30 17:21", - }, - { - id: 9, - title: "公司将在 10 月 15 日举办新产品发布会,敬请期待。", - publishStatus: 1, - type: 5, - publisherName: "系统管理员", - level: "L", - publishTime: "2024-09-30 17:29", - isRead: null, - targetType: 1, - createTime: "2024-09-28 11:21", - revokeTime: "2024-09-30 17:21", - }, - { - id: 10, - title: "v2.16.1 版本修复了 WebSocket 重复连接导致的后台线程阻塞问题,优化了通知公告。", - publishStatus: 1, - type: 1, - publisherName: "系统管理员", - level: "L", - publishTime: "2024-09-30 17:30", - isRead: null, - targetType: 1, - createTime: "2024-09-28 11:21", - revokeTime: "2024-09-30 17:21", - }, - ], + data: [ + { + id: 1, + title: "v2.12.0 新增系统日志,访问趋势统计功能。", + publishStatus: 1, + type: 1, + publisherName: "系统管理员", + level: "L", + publishTime: "2024-09-30 17:21", + isRead: null, + targetType: 1, + createTime: "2024-09-28 11:21", + revokeTime: "2024-09-30 17:21", + }, + { + id: 2, + title: "v2.13.0 新增菜单搜索。", + publishStatus: 1, + type: 1, + publisherName: "系统管理员", + level: "L", + publishTime: "2024-09-30 17:22", + isRead: null, + targetType: 1, + createTime: "2024-09-28 11:21", + revokeTime: "2024-09-30 17:21", + }, + { + id: 3, + title: "\r\nv2.14.0 新增个人中心。", + publishStatus: 1, + type: 1, + publisherName: "系统管理员", + level: "L", + publishTime: "2024-09-30 17:23", + isRead: null, + targetType: 1, + createTime: "2024-09-28 11:21", + revokeTime: "2024-09-30 17:21", + }, + { + id: 4, + title: "v2.15.0 登录页面改造。", + publishStatus: 1, + type: 1, + publisherName: "系统管理员", + level: "L", + publishTime: "2024-09-30 17:24", + isRead: null, + targetType: 1, + createTime: "2024-09-28 11:21", + revokeTime: "2024-09-30 17:21", + }, + { + id: 5, + title: "v2.16.0 通知公告、字典翻译组件。", + publishStatus: 1, + type: 1, + publisherName: "系统管理员", + level: "L", + publishTime: "2024-09-30 17:25", + isRead: null, + targetType: 1, + createTime: "2024-09-28 11:21", + revokeTime: "2024-09-30 17:21", + }, + { + id: 6, + title: "系统将于本周六凌晨 2 点进行维护,预计维护时间为 2 小时。", + publishStatus: 1, + type: 2, + publisherName: "系统管理员", + level: "L", + publishTime: "2024-09-30 17:26", + isRead: null, + targetType: 1, + createTime: "2024-09-28 11:21", + revokeTime: "2024-09-30 17:21", + }, + { + id: 7, + title: "最近发现一些钓鱼邮件,请大家提高警惕,不要点击陌生链接。", + publishStatus: 1, + type: 3, + publisherName: "系统管理员", + level: "L", + publishTime: "2024-09-30 17:27", + isRead: null, + targetType: 1, + createTime: "2024-09-28 11:21", + revokeTime: "2024-09-30 17:21", + }, + { + id: 8, + title: "国庆假期从 10 月 1 日至 10 月 7 日放假,共 7 天。", + publishStatus: 1, + type: 4, + publisherName: "系统管理员", + level: "L", + publishTime: "2024-09-30 17:28", + isRead: null, + targetType: 1, + createTime: "2024-09-28 11:21", + revokeTime: "2024-09-30 17:21", + }, + { + id: 9, + title: "公司将在 10 月 15 日举办新产品发布会,敬请期待。", + publishStatus: 1, + type: 5, + publisherName: "系统管理员", + level: "L", + publishTime: "2024-09-30 17:29", + isRead: null, + targetType: 1, + createTime: "2024-09-28 11:21", + revokeTime: "2024-09-30 17:21", + }, + { + id: 10, + title: "v2.16.1 版本修复了 WebSocket 重复连接导致的后台线程阻塞问题,优化了通知公告。", + publishStatus: 1, + type: 1, + publisherName: "系统管理员", + level: "L", + publishTime: "2024-09-30 17:30", + isRead: null, + targetType: 1, + createTime: "2024-09-28 11:21", + revokeTime: "2024-09-30 17:21", + }, + ], + page: { + pageNum: 1, + pageSize: 10, total: 10, }, msg: "一切ok", @@ -185,20 +187,20 @@ export default defineMock([ }, // 修改通知 { - url: "roles/:id", + url: "notices/:id", method: ["PUT"], body({ body }) { return { code: "00000", data: null, - msg: "修改通知" + body.name + "成功", + msg: "修改通知" + body.title + "成功", }; }, }, // 删除通知 { - url: "roles/:id", + url: "notices/:id", method: ["DELETE"], body({ params }) { return { @@ -215,54 +217,56 @@ export default defineMock([ method: ["GET"], body: { code: "00000", - data: { - list: [ - { - id: 10, - title: "v2.16.1 版本修复了 WebSocket 重复连接导致的后台线程阻塞问题,优化了通知公告。", - type: 1, - level: "L", - publisherName: "系统管理员", - publishTime: "2024-09-30 17:30", - isRead: 0, - }, - { - id: 9, - title: "公司将在 10 月 15 日举办新产品发布会,敬请期待。", - type: 5, - level: "L", - publisherName: "系统管理员", - publishTime: "2024-09-30 17:29", - isRead: 0, - }, - { - id: 8, - title: "国庆假期从 10 月 1 日至 10 月 7 日放假,共 7 天。", - type: 4, - level: "L", - publisherName: "系统管理员", - publishTime: "2024-09-30 17:28", - isRead: 0, - }, - { - id: 7, - title: "最近发现一些钓鱼邮件,请大家提高警惕,不要点击陌生链接。", - type: 3, - level: "L", - publisherName: "系统管理员", - publishTime: "2024-09-30 17:27", - isRead: 0, - }, - { - id: 6, - title: "系统将于本周六凌晨 2 点进行维护,预计维护时间为 2 小时。", - type: 2, - level: "L", - publisherName: "系统管理员", - publishTime: "2024-09-30 17:26", - isRead: 0, - }, - ], + data: [ + { + id: 10, + title: "v2.16.1 版本修复了 WebSocket 重复连接导致的后台线程阻塞问题,优化了通知公告。", + type: 1, + level: "L", + publisherName: "系统管理员", + publishTime: "2024-09-30 17:30", + isRead: 0, + }, + { + id: 9, + title: "公司将在 10 月 15 日举办新产品发布会,敬请期待。", + type: 5, + level: "L", + publisherName: "系统管理员", + publishTime: "2024-09-30 17:29", + isRead: 0, + }, + { + id: 8, + title: "国庆假期从 10 月 1 日至 10 月 7 日放假,共 7 天。", + type: 4, + level: "L", + publisherName: "系统管理员", + publishTime: "2024-09-30 17:28", + isRead: 0, + }, + { + id: 7, + title: "最近发现一些钓鱼邮件,请大家提高警惕,不要点击陌生链接。", + type: 3, + level: "L", + publisherName: "系统管理员", + publishTime: "2024-09-30 17:27", + isRead: 0, + }, + { + id: 6, + title: "系统将于本周六凌晨 2 点进行维护,预计维护时间为 2 小时。", + type: 2, + level: "L", + publisherName: "系统管理员", + publishTime: "2024-09-30 17:26", + isRead: 0, + }, + ], + page: { + pageNum: 1, + pageSize: 10, total: 10, }, msg: "一切ok", diff --git a/mock/role.mock.ts b/mock/role.mock.ts index ee856999..cad20852 100644 --- a/mock/role.mock.ts +++ b/mock/role.mock.ts @@ -57,103 +57,105 @@ export default defineMock([ }, { - url: "roles/page", + url: "roles", method: ["GET"], body: { code: "00000", - data: { - list: [ - { - id: 2, - name: "系统管理员", - code: "ADMIN", - status: 1, - sort: 2, - createTime: "2021-03-25 12:39:54", - updateTime: null, - }, - { - id: 3, - name: "访问游客", - code: "GUEST", - status: 1, - sort: 3, - createTime: "2021-05-26 15:49:05", - updateTime: "2019-05-05 16:00:00", - }, - { - id: 4, - name: "系统管理员1", - code: "ADMIN1", - status: 1, - sort: 2, - createTime: "2021-03-25 12:39:54", - updateTime: null, - }, - { - id: 5, - name: "系统管理员2", - code: "ADMIN2", - status: 1, - sort: 2, - createTime: "2021-03-25 12:39:54", - updateTime: null, - }, - { - id: 6, - name: "系统管理员3", - code: "ADMIN3", - status: 1, - sort: 2, - createTime: "2021-03-25 12:39:54", - updateTime: null, - }, - { - id: 7, - name: "系统管理员4", - code: "ADMIN4", - status: 1, - sort: 2, - createTime: "2021-03-25 12:39:54", - updateTime: null, - }, - { - id: 8, - name: "系统管理员5", - code: "ADMIN5", - status: 1, - sort: 2, - createTime: "2021-03-25 12:39:54", - updateTime: null, - }, - { - id: 9, - name: "系统管理员6", - code: "ADMIN6", - status: 1, - sort: 2, - createTime: "2021-03-25 12:39:54", - updateTime: "2023-12-04 11:43:15", - }, - { - id: 10, - name: "系统管理员7", - code: "ADMIN7", - status: 1, - sort: 2, - createTime: "2021-03-25 12:39:54", - updateTime: null, - }, - { - id: 11, - name: "系统管理员8", - code: "ADMIN8", - status: 1, - sort: 2, - createTime: "2021-03-25 12:39:54", - updateTime: null, - }, - ], + data: [ + { + id: 2, + name: "系统管理员", + code: "ADMIN", + status: 1, + sort: 2, + createTime: "2021-03-25 12:39:54", + updateTime: null, + }, + { + id: 3, + name: "访问游客", + code: "GUEST", + status: 1, + sort: 3, + createTime: "2021-05-26 15:49:05", + updateTime: "2019-05-05 16:00:00", + }, + { + id: 4, + name: "系统管理员1", + code: "ADMIN1", + status: 1, + sort: 2, + createTime: "2021-03-25 12:39:54", + updateTime: null, + }, + { + id: 5, + name: "系统管理员2", + code: "ADMIN2", + status: 1, + sort: 2, + createTime: "2021-03-25 12:39:54", + updateTime: null, + }, + { + id: 6, + name: "系统管理员3", + code: "ADMIN3", + status: 1, + sort: 2, + createTime: "2021-03-25 12:39:54", + updateTime: null, + }, + { + id: 7, + name: "系统管理员4", + code: "ADMIN4", + status: 1, + sort: 2, + createTime: "2021-03-25 12:39:54", + updateTime: null, + }, + { + id: 8, + name: "系统管理员5", + code: "ADMIN5", + status: 1, + sort: 2, + createTime: "2021-03-25 12:39:54", + updateTime: null, + }, + { + id: 9, + name: "系统管理员6", + code: "ADMIN6", + status: 1, + sort: 2, + createTime: "2021-03-25 12:39:54", + updateTime: "2023-12-04 11:43:15", + }, + { + id: 10, + name: "系统管理员7", + code: "ADMIN7", + status: 1, + sort: 2, + createTime: "2021-03-25 12:39:54", + updateTime: null, + }, + { + id: 11, + name: "系统管理员8", + code: "ADMIN8", + status: 1, + sort: 2, + createTime: "2021-03-25 12:39:54", + updateTime: null, + }, + ], + page: { + pageNum: 1, + pageSize: 10, total: 10, }, msg: "一切ok", @@ -214,7 +216,7 @@ export default defineMock([ { url: "roles/:id/menuIds", method: ["GET"], - body: ({}) => { + body: () => { return { code: "00000", data: [ diff --git a/mock/user.mock.ts b/mock/user.mock.ts index bf2fc988..3acbea90 100644 --- a/mock/user.mock.ts +++ b/mock/user.mock.ts @@ -66,37 +66,39 @@ export default defineMock([ }, { - url: "users/page", + url: "users", method: ["GET"], body: { code: "00000", - data: { - list: [ - { - id: 2, - username: "admin", - nickname: "系统管理员", - mobile: "17621210366", - gender: 1, - avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif", - email: "", - status: 1, - deptId: 1, - roleIds: [2], - }, - { - id: 3, - username: "test", - nickname: "测试小用户", - mobile: "17621210366", - gender: 1, - avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif", - email: "youlaitech@163.com", - status: 1, - deptId: 3, - roleIds: [3], - }, - ], + data: [ + { + id: 2, + username: "admin", + nickname: "系统管理员", + mobile: "17621210366", + gender: 1, + avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif", + email: "", + status: 1, + deptId: 1, + roleIds: [2], + }, + { + id: 3, + username: "test", + nickname: "测试小用户", + mobile: "17621210366", + gender: 1, + avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif", + email: "youlaitech@163.com", + status: 1, + deptId: 3, + roleIds: [3], + }, + ], + page: { + pageNum: 1, + pageSize: 10, total: 2, }, msg: "一切ok", @@ -149,7 +151,7 @@ export default defineMock([ return { code: "00000", data: null, - msg: "删除用户" + params.id + "成功", + msg: "删除用户" + params.userId + "成功", }; }, }, diff --git a/src/api/ai.ts b/src/api/ai.ts index de6dc6a7..a3aca2d5 100644 --- a/src/api/ai.ts +++ b/src/api/ai.ts @@ -4,8 +4,8 @@ import type { AiCommandResponse, AiExecuteRequest, AiExecuteResponse, - AiCommandRecordPageQuery, - AiCommandRecordVo, + AiAssistantRecordQueryParams, + AiAssistantRecordItem, } from "@/types/api"; const AI_BASE_URL = "/api/v1/ai/assistant"; @@ -48,8 +48,8 @@ const AiCommandApi = { * @param queryParams 查询参数 * @returns AI 命令记录分页列表 */ - getPage(queryParams: AiCommandRecordPageQuery) { - return request>({ + getPage(queryParams: AiAssistantRecordQueryParams) { + return request>({ url: `${AI_BASE_URL}/records`, method: "get", params: queryParams, diff --git a/src/api/codegen.ts b/src/api/codegen.ts index af973c05..8115b7fb 100644 --- a/src/api/codegen.ts +++ b/src/api/codegen.ts @@ -1,13 +1,13 @@ import request from "@/utils/request"; -import type { GeneratorPreviewVo, TablePageQuery, TablePageVo, GenConfigForm } from "@/types/api"; +import type { GeneratorPreviewItem, TableQueryParams, TableItem, GenConfigForm } from "@/types/api"; const GENERATOR_BASE_URL = "/api/v1/codegen"; const GeneratorAPI = { /** 获取数据表分页列表 */ - getTablePage(params: TablePageQuery) { - return request>({ - url: `${GENERATOR_BASE_URL}/table/page`, + getTablePage(params: TableQueryParams) { + return request>({ + url: `${GENERATOR_BASE_URL}/table`, method: "get", params, }); @@ -32,7 +32,7 @@ const GeneratorAPI = { /** 获取代码生成预览数据 */ getPreviewData(tableName: string, pageType?: "classic" | "curd") { - return request({ + return request({ url: `${GENERATOR_BASE_URL}/${tableName}/preview`, method: "get", params: pageType ? { pageType } : undefined, diff --git a/src/api/system/config.ts b/src/api/system/config.ts index 1ffe3c79..c08f3fcf 100644 --- a/src/api/system/config.ts +++ b/src/api/system/config.ts @@ -1,13 +1,13 @@ import request from "@/utils/request"; -import type { ConfigPageQuery, ConfigForm, ConfigPageVo } from "@/types/api"; +import type { ConfigQueryParams, ConfigForm, ConfigItem } from "@/types/api"; const CONFIG_BASE_URL = "/api/v1/configs"; const ConfigAPI = { /** 获取配置分页数据 */ - getPage(queryParams?: ConfigPageQuery) { - return request>({ - url: `${CONFIG_BASE_URL}/page`, + getPage(queryParams?: ConfigQueryParams) { + return request>({ + url: `${CONFIG_BASE_URL}`, method: "get", params: queryParams, }); diff --git a/src/api/system/dept.ts b/src/api/system/dept.ts index e3d24b7b..821b4532 100644 --- a/src/api/system/dept.ts +++ b/src/api/system/dept.ts @@ -1,16 +1,20 @@ import request from "@/utils/request"; -import type { DeptQuery, DeptVo, DeptForm } from "@/types/api"; +import type { DeptQueryParams, DeptItem, DeptForm, OptionItem } from "@/types/api"; const DEPT_BASE_URL = "/api/v1/depts"; const DeptAPI = { /** 获取部门树形列表 */ - getList(queryParams?: DeptQuery) { - return request({ url: `${DEPT_BASE_URL}`, method: "get", params: queryParams }); + getList(queryParams?: DeptQueryParams) { + return request({ + url: `${DEPT_BASE_URL}`, + method: "get", + params: queryParams, + }); }, /** 获取部门下拉数据源 */ getOptions() { - return request({ url: `${DEPT_BASE_URL}/options`, method: "get" }); + return request({ url: `${DEPT_BASE_URL}/options`, method: "get" }); }, /** 获取部门表单数据 */ getFormData(id: string) { diff --git a/src/api/system/dict.ts b/src/api/system/dict.ts index bf08e462..ae8803c4 100644 --- a/src/api/system/dict.ts +++ b/src/api/system/dict.ts @@ -1,39 +1,86 @@ import request from "@/utils/request"; import type { - DictPageQuery, - DictPageVo, - DictForm, - DictItemPageQuery, - DictItemPageVo, + DictTypeQueryParams, + DictTypeItem, + DictTypeForm, + DictItemQueryParams, + DictItem, DictItemForm, DictItemOption, + OptionItem, } from "@/types/api"; const DICT_BASE_URL = "/api/v1/dicts"; +type DictTagTypeCode = "N" | "P" | "S" | "W" | "I" | "D"; + +const decodeDictTagType = (code?: unknown): DictItemForm["tagType"] => { + const val = String(code ?? "") + .trim() + .toUpperCase(); + switch (val as DictTagTypeCode) { + case "P": + return "primary"; + case "S": + return "success"; + case "W": + return "warning"; + case "I": + return "info"; + case "D": + return "danger"; + case "N": + default: + return ""; + } +}; + +const encodeDictTagType = (tagType?: unknown): DictTagTypeCode => { + const val = String(tagType ?? "") + .trim() + .toLowerCase(); + switch (val) { + case "primary": + return "P"; + case "success": + return "S"; + case "warning": + return "W"; + case "info": + return "I"; + case "danger": + case "error": + return "D"; + case "default": + case "": + default: + return "N"; + } +}; + const DictAPI = { /** 字典分页列表 */ - getPage(queryParams: DictPageQuery) { - return request>({ - url: `${DICT_BASE_URL}/page`, + getPage(queryParams: DictTypeQueryParams) { + return request>({ + url: `${DICT_BASE_URL}`, method: "get", params: queryParams, }); }, /** 字典列表 */ getList() { - return request({ url: `${DICT_BASE_URL}`, method: "get" }); + return request({ url: `${DICT_BASE_URL}/options`, method: "get" }); }, /** 字典表单数据 */ getFormData(id: string) { - return request({ url: `${DICT_BASE_URL}/${id}/form`, method: "get" }); + return request({ url: `${DICT_BASE_URL}/${id}/form`, method: "get" }); }, /** 新增字典 */ - create(data: DictForm) { + create(data: DictTypeForm) { return request({ url: `${DICT_BASE_URL}`, method: "post", data }); }, /** 修改字典 */ - update(id: string, data: DictForm) { + update(id: string, data: DictTypeForm) { return request({ url: `${DICT_BASE_URL}/${id}`, method: "put", data }); }, /** 删除字典 */ @@ -42,34 +89,62 @@ const DictAPI = { }, /** 获取字典项分页列表 */ - getDictItemPage(dictCode: string, queryParams: DictItemPageQuery) { - return request>({ - url: `${DICT_BASE_URL}/${dictCode}/items/page`, + getDictItemPage(dictCode: string, queryParams: DictItemQueryParams) { + return request>({ + url: `${DICT_BASE_URL}/${dictCode}/items`, method: "get", params: queryParams, - }); + }).then((res) => ({ + ...res, + data: (res.data ?? []).map((item) => ({ + ...item, + tagType: decodeDictTagType((item as any).tagType), + })), + })); }, /** 获取字典项列表 */ getDictItems(dictCode: string) { return request({ - url: `${DICT_BASE_URL}/${dictCode}/items`, + url: `${DICT_BASE_URL}/${dictCode}/items/options`, method: "get", - }); + }).then((items) => + (items ?? []).map((item) => ({ + ...item, + tagType: decodeDictTagType((item as any).tagType), + })) + ); }, /** 新增字典项 */ createDictItem(dictCode: string, data: DictItemForm) { - return request({ url: `${DICT_BASE_URL}/${dictCode}/items`, method: "post", data }); + return request({ + url: `${DICT_BASE_URL}/${dictCode}/items`, + method: "post", + data: { + ...data, + tagType: encodeDictTagType((data as any).tagType), + }, + }); }, /** 获取字典项表单数据 */ getDictItemFormData(dictCode: string, id: string) { return request({ url: `${DICT_BASE_URL}/${dictCode}/items/${id}/form`, method: "get", - }); + }).then((form) => ({ + ...form, + tagType: decodeDictTagType((form as any).tagType), + })); }, /** 修改字典项 */ updateDictItem(dictCode: string, id: string, data: DictItemForm) { - return request({ url: `${DICT_BASE_URL}/${dictCode}/items/${id}`, method: "put", data }); + return request({ + url: `${DICT_BASE_URL}/${dictCode}/items/${id}`, + method: "put", + data: { + ...data, + tagType: encodeDictTagType((data as any).tagType), + }, + }); }, /** 删除字典项 */ deleteDictItems(dictCode: string, ids: string) { diff --git a/src/api/system/log.ts b/src/api/system/log.ts index 2f6c77aa..01908542 100644 --- a/src/api/system/log.ts +++ b/src/api/system/log.ts @@ -1,13 +1,13 @@ import request from "@/utils/request"; -import type { LogPageQuery, LogPageVo } from "@/types/api"; +import type { LogQueryParams, LogItem } from "@/types/api"; const LOG_BASE_URL = "/api/v1/logs"; const LogAPI = { /** 获取日志分页列表 */ - getPage(queryParams: LogPageQuery) { - return request>({ - url: `${LOG_BASE_URL}/page`, + getPage(queryParams: LogQueryParams) { + return request>({ + url: `${LOG_BASE_URL}`, method: "get", params: queryParams, }); diff --git a/src/api/system/menu.ts b/src/api/system/menu.ts index 5cd9b7e4..87e410ef 100644 --- a/src/api/system/menu.ts +++ b/src/api/system/menu.ts @@ -1,20 +1,24 @@ import request from "@/utils/request"; -import type { MenuQuery, MenuVo, MenuForm, RouteVo, OptionType } from "@/types/api"; +import type { MenuQueryParams, MenuItem, MenuForm, RouteItem, OptionItem } from "@/types/api"; const MENU_BASE_URL = "/api/v1/menus"; const MenuAPI = { /** 获取当前用户的路由列表 */ getRoutes() { - return request({ url: `${MENU_BASE_URL}/routes`, method: "get" }); + return request({ url: `${MENU_BASE_URL}/routes`, method: "get" }); }, /** 获取菜单树形列表 */ - getList(queryParams: MenuQuery) { - return request({ url: `${MENU_BASE_URL}`, method: "get", params: queryParams }); + getList(queryParams: MenuQueryParams) { + return request({ + url: `${MENU_BASE_URL}`, + method: "get", + params: queryParams, + }); }, /** 获取菜单下拉数据源 */ getOptions(onlyParent?: boolean) { - return request({ + return request({ url: `${MENU_BASE_URL}/options`, method: "get", params: { onlyParent }, diff --git a/src/api/system/notice.ts b/src/api/system/notice.ts index f0e1a9ad..5c198a35 100644 --- a/src/api/system/notice.ts +++ b/src/api/system/notice.ts @@ -1,13 +1,13 @@ import request from "@/utils/request"; -import type { NoticePageQuery, NoticeForm, NoticePageVo, NoticeDetailVo } from "@/types/api"; +import type { NoticeQueryParams, NoticeForm, NoticeItem, NoticeDetail } from "@/types/api"; const NOTICE_BASE_URL = "/api/v1/notices"; const NoticeAPI = { /** 获取通知公告分页数据 */ - getPage(queryParams?: NoticePageQuery) { - return request>({ - url: `${NOTICE_BASE_URL}/page`, + getPage(queryParams?: NoticeQueryParams) { + return request>({ + url: `${NOTICE_BASE_URL}`, method: "get", params: queryParams, }); @@ -38,15 +38,15 @@ const NoticeAPI = { }, /** 查看通知 */ getDetail(id: string) { - return request({ url: `${NOTICE_BASE_URL}/${id}/detail`, method: "get" }); + return request({ url: `${NOTICE_BASE_URL}/${id}/detail`, method: "get" }); }, /** 全部已读 */ readAll() { return request({ url: `${NOTICE_BASE_URL}/read-all`, method: "put" }); }, /** 获取我的通知分页列表 */ - getMyNoticePage(queryParams?: NoticePageQuery) { - return request>({ + getMyNoticePage(queryParams?: NoticeQueryParams) { + return request>({ url: `${NOTICE_BASE_URL}/my`, method: "get", params: queryParams, diff --git a/src/api/system/role.ts b/src/api/system/role.ts index 5dfc3276..c9e86d6c 100644 --- a/src/api/system/role.ts +++ b/src/api/system/role.ts @@ -1,20 +1,20 @@ import request from "@/utils/request"; -import type { RolePageQuery, RolePageVo, RoleForm } from "@/types/api"; +import type { RoleQueryParams, RoleItem, RoleForm, OptionItem } from "@/types/api"; const ROLE_BASE_URL = "/api/v1/roles"; const RoleAPI = { /** 获取角色分页数据 */ - getPage(queryParams?: RolePageQuery) { - return request>({ - url: `${ROLE_BASE_URL}/page`, + getPage(queryParams?: RoleQueryParams) { + return request>({ + url: `${ROLE_BASE_URL}`, method: "get", params: queryParams, }); }, /** 获取角色下拉数据源 */ getOptions() { - return request({ url: `${ROLE_BASE_URL}/options`, method: "get" }); + return request({ url: `${ROLE_BASE_URL}/options`, method: "get" }); }, /** 获取角色的菜单ID集合 */ getRoleMenuIds(roleId: string) { diff --git a/src/api/system/statistics.ts b/src/api/system/statistics.ts index 4bcedf35..5e8357e6 100644 --- a/src/api/system/statistics.ts +++ b/src/api/system/statistics.ts @@ -1,12 +1,12 @@ import request from "@/utils/request"; -import type { VisitTrendQuery, VisitTrendVo, VisitStatsVo } from "@/types/api"; +import type { VisitTrendQueryParams, VisitTrendDetail, VisitStatsDetail } from "@/types/api"; const STATISTICS_BASE_URL = "/api/v1/statistics"; const StatisticsAPI = { /** 获取访问趋势统计 */ - getVisitTrend(queryParams: VisitTrendQuery) { - return request({ + getVisitTrend(queryParams: VisitTrendQueryParams) { + return request({ url: `${STATISTICS_BASE_URL}/visits/trend`, method: "get", params: queryParams, @@ -14,7 +14,7 @@ const StatisticsAPI = { }, /** 获取访问概览统计 */ getVisitOverview() { - return request({ + return request({ url: `${STATISTICS_BASE_URL}/visits/overview`, method: "get", }); diff --git a/src/api/system/tenant.ts b/src/api/system/tenant.ts index b650ec2d..57091210 100644 --- a/src/api/system/tenant.ts +++ b/src/api/system/tenant.ts @@ -1,11 +1,11 @@ import request from "@/utils/request"; import type { TenantCreateForm, - TenantCreateResultVo, TenantForm, TenantInfo, - TenantPageQuery, - TenantPageVo, + TenantCreateResult, + TenantQueryParams, + TenantItem, } from "@/types/api"; const TENANT_BASE_URL = "/api/v1/tenants"; @@ -20,7 +20,7 @@ const TenantAPI = { */ getTenantList() { return request({ - url: `${TENANT_BASE_URL}`, + url: `${TENANT_BASE_URL}/options`, method: "get", }); }, @@ -48,9 +48,9 @@ const TenantAPI = { }, /** 获取租户分页数据(平台租户管理) */ - getPage(queryParams?: TenantPageQuery) { - return request>({ - url: `${TENANT_BASE_URL}/page`, + getPage(queryParams?: TenantQueryParams) { + return request>({ + url: `${TENANT_BASE_URL}`, method: "get", params: queryParams, }); @@ -66,7 +66,7 @@ const TenantAPI = { /** 新增租户并初始化默认数据 */ create(data: TenantCreateForm) { - return request({ + return request({ url: `${TENANT_BASE_URL}`, method: "post", data, diff --git a/src/api/system/user.ts b/src/api/system/user.ts index 59a7cbca..ea51e035 100644 --- a/src/api/system/user.ts +++ b/src/api/system/user.ts @@ -1,14 +1,15 @@ import request from "@/utils/request"; import type { UserInfo, - UserPageQuery, - UserPageVo, UserForm, - UserProfileVo, + UserQueryParams, + UserItem, + UserProfileDetail, UserProfileForm, PasswordChangeForm, MobileUpdateForm, EmailUpdateForm, + OptionItem, } from "@/types/api"; const USER_BASE_URL = "/api/v1/users"; @@ -31,9 +32,9 @@ const UserAPI = { * * @param queryParams 查询参数 */ - getPage(queryParams: UserPageQuery) { - return request>({ - url: `${USER_BASE_URL}/page`, + getPage(queryParams: UserQueryParams) { + return request>({ + url: `${USER_BASE_URL}`, method: "get", params: queryParams, }); @@ -119,7 +120,7 @@ const UserAPI = { * * @param queryParams 查询参数 */ - export(queryParams: UserPageQuery) { + export(queryParams: UserQueryParams) { return request({ url: `${USER_BASE_URL}/export`, method: "get", @@ -150,7 +151,7 @@ const UserAPI = { /** 获取个人中心用户信息 */ getProfile() { - return request({ + return request({ url: `${USER_BASE_URL}/profile`, method: "get", }); @@ -214,7 +215,7 @@ const UserAPI = { * 获取用户下拉列表 */ getOptions() { - return request({ + return request({ url: `${USER_BASE_URL}/options`, method: "get", }); diff --git a/src/components/CURD/PageContent.vue b/src/components/CURD/PageContent.vue index b9d150e0..cbaef0d3 100644 --- a/src/components/CURD/PageContent.vue +++ b/src/components/CURD/PageContent.vue @@ -870,13 +870,11 @@ function fetchPageData(formData: IObject = {}, isRestart = false) { ) .then((data) => { if (showPagination) { - if (props.contentConfig.parseData) { - data = props.contentConfig.parseData(data); - } - pagination.total = data.total; - pageData.value = data.list; + const pageResult = Array.isArray(data) ? { data, page: null } : data; + pagination.total = pageResult.page?.total ?? 0; + pageData.value = pageResult.data ?? []; } else { - pageData.value = data; + pageData.value = Array.isArray(data) ? data : (data.data ?? []); } }) .finally(() => { diff --git a/src/components/CURD/types.ts b/src/components/CURD/types.ts index 95499311..152d89c8 100644 --- a/src/components/CURD/types.ts +++ b/src/components/CURD/types.ts @@ -55,7 +55,7 @@ export interface ISearchConfig { grid?: boolean | "left" | "right"; } -export interface IContentConfig { +export interface IContentConfig { // 权限前缀(如sys:user,用于组成权限标识),不提供则不进行权限校验 permPrefix?: string; // table组件属性 @@ -72,18 +72,13 @@ export interface IContentConfig { > >; // 列表的网络请求函数(需返回promise) - indexAction: (queryParams: T) => Promise; + indexAction: (queryParams: TQuery) => Promise | TItem[]>; // 默认的分页相关的请求参数 request?: { pageName: string; limitName: string; }; - // 数据格式解析的回调函数 - parseData?: (res: any) => { - total: number; - list: IObject[]; - [key: string]: any; - }; + // 分页接口统一返回 PageResult { data, page } // 修改属性的网络请求函数(需返回promise) modifyAction?: (data: { [key: string]: any; @@ -93,9 +88,9 @@ export interface IContentConfig { // 删除的网络请求函数(需返回promise) deleteAction?: (ids: string) => Promise; // 后端导出的网络请求函数(需返回promise) - exportAction?: (queryParams: T) => Promise; + exportAction?: (queryParams: TQuery) => Promise; // 前端全量导出的网络请求函数(需返回promise) - exportsAction?: (queryParams: T) => Promise; + exportsAction?: (queryParams: TQuery) => Promise; // 导入模板 importTemplate?: string | (() => Promise); // 后端导入的网络请求函数(需返回promise) diff --git a/src/components/NoticeDropdown/useNotice.ts b/src/components/NoticeDropdown/useNotice.ts index de46644c..4f573f13 100644 --- a/src/components/NoticeDropdown/useNotice.ts +++ b/src/components/NoticeDropdown/useNotice.ts @@ -2,7 +2,7 @@ * 通知中心逻辑 */ import { ref, onMounted, onBeforeUnmount } from "vue"; -import type { NoticePageVo, NoticeDetailVo, NoticePageQuery } from "@/types/api"; +import type { NoticeItem, NoticeDetail, NoticeQueryParams } from "@/types/api"; import NoticeAPI from "@/api/system/notice"; import { useStomp } from "@/composables"; import router from "@/router"; @@ -13,8 +13,8 @@ export function useNotice() { const { subscribe, unsubscribe, isConnected } = useStomp(); // 状态 - const list = ref([]); - const detail = ref(null); + const list = ref([]); + const detail = ref(null); const dialogVisible = ref(false); let subscribed = false; @@ -23,15 +23,15 @@ export function useNotice() { // 数据获取 // ============================================ - async function fetchList(params?: Partial) { - const query: NoticePageQuery = { + async function fetchList(params?: Partial) { + const query: NoticeQueryParams = { pageNum: 1, pageSize: PAGE_SIZE, isRead: 0, ...params, - } as NoticePageQuery; + }; const page = await NoticeAPI.getMyNoticePage(query); - list.value = page.list || []; + list.value = page.data || []; } async function read(id: string) { @@ -39,7 +39,7 @@ export function useNotice() { dialogVisible.value = true; // 从列表中移除已读项 - const idx = list.value.findIndex((item: NoticePageVo) => item.id === id); + const idx = list.value.findIndex((item: NoticeItem) => item.id === id); if (idx >= 0) list.value.splice(idx, 1); } @@ -65,14 +65,14 @@ export function useNotice() { if (!data.id) return; // 避免重复 - if (list.value.some((item: NoticePageVo) => item.id === data.id)) return; + if (list.value.some((item: NoticeItem) => item.id === data.id)) return; list.value.unshift({ id: data.id, title: data.title, type: data.type, publishTime: data.publishTime, - } as NoticePageVo); + } as NoticeItem); ElNotification({ title: "您收到一条新的通知消息!", diff --git a/src/components/TableSelect/index.vue b/src/components/TableSelect/index.vue index 3641669a..0b314d59 100644 --- a/src/components/TableSelect/index.vue +++ b/src/components/TableSelect/index.vue @@ -261,9 +261,9 @@ function fetchPageData(isRestart = false) { } props.selectConfig .indexAction(queryParams) - .then((data) => { - total.value = data.total; - pageData.value = data.list; + .then((res) => { + total.value = res.page?.total ?? 0; + pageData.value = res.data ?? []; }) .finally(() => { loading.value = false; diff --git a/src/enums/codegen.ts b/src/enums/codegen.ts index 5d74234b..6f49422a 100644 --- a/src/enums/codegen.ts +++ b/src/enums/codegen.ts @@ -8,7 +8,7 @@ /** * 表单类型枚举 */ -export const FormTypeEnum: Record = { +export const FormTypeEnum: Record = { INPUT: { value: 1, label: "输入框" }, SELECT: { value: 2, label: "下拉框" }, RADIO: { value: 3, label: "单选框" }, @@ -24,7 +24,7 @@ export const FormTypeEnum: Record = { /** * 查询类型枚举 */ -export const QueryTypeEnum: Record = { +export const QueryTypeEnum: Record = { /** 等于 */ EQ: { value: 1, label: "=" }, diff --git a/src/layouts/components/LayoutSettings.vue b/src/layouts/components/LayoutSettings.vue index e7fb6a90..3d6fab1b 100644 --- a/src/layouts/components/LayoutSettings.vue +++ b/src/layouts/components/LayoutSettings.vue @@ -332,6 +332,8 @@ const handleCloseDrawer = () => { .settings-drawer { :deep(.el-drawer__body) { position: relative; + display: flex; + flex-direction: column; height: 100%; padding: 0; overflow: hidden; @@ -340,7 +342,8 @@ const handleCloseDrawer = () => { /* 设置内容区域 */ .settings-content { - max-height: calc(100vh - 120px); + /* let drawer body control height with flex and make this area scrollable */ + flex: 1 1 auto; padding: 20px; overflow-y: auto; } diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 6a0787be..744d72d3 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -4,7 +4,7 @@ import { store } from "@/store"; import router from "@/router"; import MenuAPI from "@/api/system/menu"; -import { RouteVo } from "@/types"; +import { RouteItem } from "@/types"; const modules = import.meta.glob("../../views/**/**.vue"); const Layout = () => import("../../layouts/index.vue"); @@ -69,7 +69,7 @@ export const usePermissionStore = defineStore("permission", () => { * 转换后端路由数据为Vue Router配置 * 处理组件路径映射和Layout层级嵌套 */ -const transformRoutes = (routes: RouteVo[], isTopLevel: boolean = true): RouteRecordRaw[] => { +const transformRoutes = (routes: RouteItem[], isTopLevel: boolean = true): RouteRecordRaw[] => { return routes.map((route) => { const { component, children, ...args } = route; diff --git a/src/types/api/ai.ts b/src/types/api/ai.ts index 46f58ce3..f893e7a2 100644 --- a/src/types/api/ai.ts +++ b/src/types/api/ai.ts @@ -2,6 +2,8 @@ * AI 模块类型定义 */ +import type { BaseQueryParams } from "./common"; + /** AI命令请求参数 */ export interface AiCommandRequest { /** 用户输入的自然语言命令 */ @@ -81,10 +83,12 @@ export interface AiExecuteResponse { } /** AI命令记录分页查询参数 */ -export interface AiCommandRecordPageQuery extends PageQuery { +export interface AiAssistantRecordQueryParams extends BaseQueryParams { /** 搜索关键字 */ keywords?: string; /** 执行状态 */ + status?: string; + /** 执行状态(0:待执行;1:成功;-1:失败) */ executeStatus?: number; /** 解析状态 */ parseStatus?: number; @@ -101,7 +105,7 @@ export interface AiCommandRecordPageQuery extends PageQuery { } /** AI命令记录视图对象 */ -export interface AiCommandRecordVo { +export interface AiAssistantRecordItem { /** 记录ID */ id: string; /** 用户ID */ diff --git a/src/types/api/codegen.ts b/src/types/api/codegen.ts index d37d4eec..2686a681 100644 --- a/src/types/api/codegen.ts +++ b/src/types/api/codegen.ts @@ -2,8 +2,10 @@ * CodeGen 代码生成类型定义 */ +import type { BaseQueryParams } from "./common"; + /** 代码生成预览对象 */ -export interface GeneratorPreviewVo { +export interface GeneratorPreviewItem { /** 文件生成路径 */ path: string; /** 文件名称 */ @@ -13,13 +15,13 @@ export interface GeneratorPreviewVo { } /** 数据表分页查询参数 */ -export interface TablePageQuery extends PageQuery { +export interface TableQueryParams extends BaseQueryParams { /** 搜索关键字(表名) */ keywords?: string; } /** 数据表分页对象 */ -export interface TablePageVo { +export interface TableItem { /** 表名称 */ tableName: string; /** 表描述 */ diff --git a/src/types/api/common.ts b/src/types/api/common.ts index 412bd132..fff58239 100644 --- a/src/types/api/common.ts +++ b/src/types/api/common.ts @@ -10,32 +10,49 @@ export interface ApiResponse { data: T; /** 响应消息 */ msg: string; + + /** 分页信息(非列表接口通常不存在该字段) */ + page?: PageMeta | null; } -/** 分页查询参数 */ -export interface PageQuery { +/** 基础查询参数 */ +export interface BaseQueryParams { /** 页码 */ pageNum: number; /** 每页记录数 */ pageSize: number; + + /** 排序字段 */ + sortBy?: string; + + /** 排序方式(正序:ASC;反序:DESC) */ + order?: string; } -/** 分页响应结构 */ -export interface PageResult { - /** 数据列表 */ - list: T; - /** 总记录数 */ +/** 分页元信息 */ +export interface PageMeta { + pageNum: number; + pageSize: number; total: number; } +/** 列表响应结构(统一) */ +export interface PageResult { + /** 数据列表 */ + data: T[]; + + /** 分页信息,不分页时为 null */ + page: PageMeta | null; +} + /** 下拉选项 */ -export interface OptionType { +export interface OptionItem { /** 选项值 */ value: string | number; /** 选项标签 */ label: string; /** 子选项 */ - children?: OptionType[]; + children?: OptionItem[]; } /** Excel 导入结果 */ diff --git a/src/types/api/config.ts b/src/types/api/config.ts index 67f4d745..7f2c04b9 100644 --- a/src/types/api/config.ts +++ b/src/types/api/config.ts @@ -2,8 +2,10 @@ * Config 配置类型定义 */ +import type { BaseQueryParams } from "./common"; + /** 配置分页查询参数 */ -export interface ConfigPageQuery extends PageQuery { +export interface ConfigQueryParams extends BaseQueryParams { /** 搜索关键字 */ keywords?: string; } @@ -23,7 +25,7 @@ export interface ConfigForm { } /** 配置分页对象 */ -export interface ConfigPageVo { +export interface ConfigItem { /** 配置ID */ id?: string; /** 配置名称 */ diff --git a/src/types/api/dept.ts b/src/types/api/dept.ts index 0af6773b..1f0976c8 100644 --- a/src/types/api/dept.ts +++ b/src/types/api/dept.ts @@ -3,7 +3,7 @@ */ /** 部门查询参数 */ -export interface DeptQuery { +export interface DeptQueryParams { /** 搜索关键字 */ keywords?: string; /** 状态 */ @@ -11,9 +11,9 @@ export interface DeptQuery { } /** 部门视图对象 */ -export interface DeptVo { +export interface DeptItem { /** 子部门 */ - children?: DeptVo[]; + children?: DeptItem[]; /** 创建时间 */ createTime?: Date; /** 部门ID */ diff --git a/src/types/api/dict.ts b/src/types/api/dict.ts index 4c2ef1ba..e3b7b888 100644 --- a/src/types/api/dict.ts +++ b/src/types/api/dict.ts @@ -2,9 +2,11 @@ * Dict 字典类型定义 */ +import type { BaseQueryParams } from "./common"; + /** 字典分页查询参数 */ -export interface DictPageQuery extends PageQuery { +export interface DictTypeQueryParams extends BaseQueryParams { /** 搜索关键字 */ keywords?: string; /** 状态(1:启用;0:禁用) */ @@ -12,7 +14,7 @@ export interface DictPageQuery extends PageQuery { } /** 字典分页对象 */ -export interface DictPageVo { +export interface DictTypeItem { /** 字典ID */ id: string; /** 字典名称 */ @@ -24,7 +26,7 @@ export interface DictPageVo { } /** 字典表单对象 */ -export interface DictForm { +export interface DictTypeForm { /** 字典ID */ id?: string; /** 字典名称 */ @@ -38,7 +40,7 @@ export interface DictForm { } /** 字典项分页查询参数 */ -export interface DictItemPageQuery extends PageQuery { +export interface DictItemQueryParams extends BaseQueryParams { /** 搜索关键字 */ keywords?: string; /** 字典编码 */ @@ -46,7 +48,7 @@ export interface DictItemPageQuery extends PageQuery { } /** 字典项分页对象 */ -export interface DictItemPageVo { +export interface DictItem { /** 字典项ID */ id: string; /** 字典编码 */ diff --git a/src/types/api/log.ts b/src/types/api/log.ts index 545072cf..f275a131 100644 --- a/src/types/api/log.ts +++ b/src/types/api/log.ts @@ -2,8 +2,10 @@ * Log 日志类型定义 */ +import type { BaseQueryParams } from "./common"; + /** 日志分页查询参数 */ -export interface LogPageQuery extends PageQuery { +export interface LogQueryParams extends BaseQueryParams { /** 搜索关键字 */ keywords?: string; /** 操作时间 */ @@ -11,7 +13,7 @@ export interface LogPageQuery extends PageQuery { } /** 日志分页对象 */ -export interface LogPageVo { +export interface LogItem { /** 日志ID */ id: string; /** 日志模块 */ diff --git a/src/types/api/menu.ts b/src/types/api/menu.ts index 121a0dd4..9bc7fcc3 100644 --- a/src/types/api/menu.ts +++ b/src/types/api/menu.ts @@ -3,15 +3,15 @@ */ /** 菜单查询参数 */ -export interface MenuQuery { +export interface MenuQueryParams { /** 搜索关键字 */ keywords?: string; } /** 菜单视图对象 */ -export interface MenuVo { +export interface MenuItem { /** 子菜单 */ - children?: MenuVo[]; + children?: MenuItem[]; /** 组件路径 */ component?: string; /** ICON */ @@ -79,9 +79,9 @@ export interface MenuOption { } /** 路由对象 */ -export interface RouteVo { +export interface RouteItem { /** 子路由列表 */ - children: RouteVo[]; + children: RouteItem[]; /** 组件路径 */ component?: string; /** 路由名称 */ diff --git a/src/types/api/notice.ts b/src/types/api/notice.ts index 2b74907e..afa8e9a6 100644 --- a/src/types/api/notice.ts +++ b/src/types/api/notice.ts @@ -2,8 +2,10 @@ * Notice 通知类型定义 */ +import type { BaseQueryParams } from "./common"; + /** 通知分页查询参数 */ -export interface NoticePageQuery extends PageQuery { +export interface NoticeQueryParams extends BaseQueryParams { /** 通知标题 */ title?: string; /** 发布状态(0:草稿;1:已发布;2:已撤回) */ @@ -33,7 +35,7 @@ export interface NoticeForm { } /** 通知分页对象 */ -export interface NoticePageVo { +export interface NoticeItem { /** 通知ID */ id: string; /** 通知标题 */ @@ -55,7 +57,7 @@ export interface NoticePageVo { } /** 通知详情对象 */ -export interface NoticeDetailVo { +export interface NoticeDetail { /** 通知ID */ id?: string; /** 通知标题 */ diff --git a/src/types/api/role.ts b/src/types/api/role.ts index 17e224ac..7458b760 100644 --- a/src/types/api/role.ts +++ b/src/types/api/role.ts @@ -2,14 +2,16 @@ * Role 角色类型定义 */ +import type { BaseQueryParams } from "./common"; + /** 角色分页查询参数 */ -export interface RolePageQuery extends PageQuery { +export interface RoleQueryParams extends BaseQueryParams { /** 搜索关键字 */ keywords?: string; } /** 角色分页对象 */ -export interface RolePageVo { +export interface RoleItem { /** 角色ID */ id?: string; /** 角色编码 */ diff --git a/src/types/api/statistics.ts b/src/types/api/statistics.ts index 3b5a6f2a..8e8a1593 100644 --- a/src/types/api/statistics.ts +++ b/src/types/api/statistics.ts @@ -3,7 +3,7 @@ */ /** 访问趋势查询参数 */ -export interface VisitTrendQuery { +export interface VisitTrendQueryParams { /** 开始日期 */ startDate: string; /** 结束日期 */ @@ -11,7 +11,7 @@ export interface VisitTrendQuery { } /** 访问趋势视图对象 */ -export interface VisitTrendVo { +export interface VisitTrendDetail { /** 日期列表 */ dates: string[]; /** 浏览量(PV)列表 */ @@ -23,7 +23,7 @@ export interface VisitTrendVo { } /** 访问量统计视图对象 */ -export interface VisitStatsVo { +export interface VisitStatsDetail { /** 今日独立访客数(UV) */ todayUvCount: number; /** 累计独立访客数(UV) */ diff --git a/src/types/api/tenant.ts b/src/types/api/tenant.ts index d9c46bc2..75085b38 100644 --- a/src/types/api/tenant.ts +++ b/src/types/api/tenant.ts @@ -2,7 +2,7 @@ * Tenant 租户类型定义 */ -import type { PageQuery } from "./common"; +import type { BaseQueryParams } from "./common"; /** 租户信息 */ export interface TenantInfo { @@ -15,7 +15,7 @@ export interface TenantInfo { } /** 租户分页查询参数 */ -export interface TenantPageQuery extends PageQuery { +export interface TenantQueryParams extends BaseQueryParams { /** 关键字(租户名称/租户编码/域名) */ keywords?: string; /** 租户状态(1-正常 0-禁用) */ @@ -23,7 +23,7 @@ export interface TenantPageQuery extends PageQuery { } /** 租户分页对象 */ -export interface TenantPageVo { +export interface TenantItem { id?: string; name?: string; code?: string; @@ -69,7 +69,7 @@ export interface TenantCreateForm { } /** 新增租户结果 */ -export interface TenantCreateResultVo { +export interface TenantCreateResult { tenantId?: string; tenantCode?: string; tenantName?: string; diff --git a/src/types/api/user.ts b/src/types/api/user.ts index 83e78182..d5e65701 100644 --- a/src/types/api/user.ts +++ b/src/types/api/user.ts @@ -2,6 +2,8 @@ * User 用户类型定义 */ +import type { BaseQueryParams } from "./common"; + /** 登录用户信息 */ export interface UserInfo { /** 用户ID */ @@ -19,7 +21,7 @@ export interface UserInfo { } /** 用户分页查询参数 */ -export interface UserPageQuery extends PageQuery { +export interface UserQueryParams extends BaseQueryParams { /** 搜索关键字 */ keywords?: string; /** 用户状态 */ @@ -31,7 +33,7 @@ export interface UserPageQuery extends PageQuery { } /** 用户分页对象 */ -export interface UserPageVo { +export interface UserItem { /** 用户ID */ id: string; /** 用户头像地址 */ @@ -81,7 +83,7 @@ export interface UserForm { } /** 个人中心用户信息 */ -export interface UserProfileVo { +export interface UserProfileDetail { /** 用户ID */ id?: string; /** 用户名 */ diff --git a/src/types/components.d.ts b/src/types/components.d.ts index e0fe31d5..1d7b15de 100644 --- a/src/types/components.d.ts +++ b/src/types/components.d.ts @@ -6,7 +6,7 @@ // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 -export {}; +export {} /* prettier-ignore */ declare module 'vue' { diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 95fb2d5d..d97cfaf4 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -5,9 +5,9 @@ */ declare global { type ApiResponse = import("@/types/api").ApiResponse; - type PageQuery = import("@/types/api").PageQuery; + type BaseQueryParams = import("@/types/api").BaseQueryParams; type PageResult = import("@/types/api").PageResult; - type OptionType = import("@/types/api").OptionType; + type OptionItem = import("@/types/api").OptionItem; type ExcelResult = import("@/types/api").ExcelResult; type TagView = import("@/types/ui").TagView; type AppSettings = import("@/types/ui").AppSettings; diff --git a/src/utils/request.ts b/src/utils/request.ts index 90ad4a55..c2aa3df0 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -15,6 +15,21 @@ const http = axios.create({ paramsSerializer: (params) => qs.stringify(params), }); +type PageMeta = { pageNum: number; pageSize: number; total: number }; +type PagedApiResponse = ApiResponse & { page: PageMeta | null }; + +function isPagedApiResponse(payload: ApiResponse): payload is PagedApiResponse { + // Treat as paged response only when `page` is a non-null object (contains pagination meta). + // Some APIs return `page: null` for non-paged endpoints; checking for the presence + // of the `page` property alone causes unintended branching (e.g. captcha endpoint). + return ( + payload != null && + typeof payload === "object" && + payload.page != null && + typeof (payload as any).page === "object" + ); +} + // ============================================ // 请求拦截器 // ============================================ @@ -49,6 +64,11 @@ http.interceptors.response.use( const { code, data, msg } = response.data; if (code === ApiCodeEnum.SUCCESS) { + // 分页接口需要同时返回 data 与 page 元信息 + if (isPagedApiResponse(response.data)) { + const { page } = response.data; + return { data, page: page ?? null }; + } return data; } diff --git a/src/views/ai/index.vue b/src/views/ai/index.vue index 9a31fa8a..5cee8c39 100644 --- a/src/views/ai/index.vue +++ b/src/views/ai/index.vue @@ -259,12 +259,12 @@