befly 3.5.7 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/lib/addon.ts +77 -0
  2. package/lib/logger.ts +6 -15
  3. package/lifecycle/checker.ts +20 -49
  4. package/lifecycle/lifecycle.ts +7 -5
  5. package/lifecycle/loader.ts +5 -5
  6. package/main.ts +10 -1
  7. package/package.json +2 -9
  8. package/paths.ts +5 -54
  9. package/util.ts +1 -83
  10. package/apis/admin/del.ts +0 -35
  11. package/apis/admin/info.ts +0 -50
  12. package/apis/admin/ins.ts +0 -61
  13. package/apis/admin/list.ts +0 -20
  14. package/apis/admin/roleDetail.ts +0 -35
  15. package/apis/admin/roleSave.ts +0 -40
  16. package/apis/admin/upd.ts +0 -51
  17. package/apis/api/all.ts +0 -37
  18. package/apis/auth/login.ts +0 -78
  19. package/apis/auth/logout.ts +0 -23
  20. package/apis/auth/register.ts +0 -50
  21. package/apis/auth/sendSmsCode.ts +0 -36
  22. package/apis/cache/refresh.ts +0 -34
  23. package/apis/dashboard/addonList.ts +0 -47
  24. package/apis/dashboard/changelog.ts +0 -37
  25. package/apis/dashboard/configStatus.ts +0 -54
  26. package/apis/dashboard/environmentInfo.ts +0 -46
  27. package/apis/dashboard/performanceMetrics.ts +0 -23
  28. package/apis/dashboard/permissionStats.ts +0 -31
  29. package/apis/dashboard/serviceStatus.ts +0 -82
  30. package/apis/dashboard/systemInfo.ts +0 -26
  31. package/apis/dashboard/systemOverview.ts +0 -32
  32. package/apis/dashboard/systemResources.ts +0 -119
  33. package/apis/dict/all.ts +0 -25
  34. package/apis/dict/del.ts +0 -19
  35. package/apis/dict/detail.ts +0 -21
  36. package/apis/dict/ins.ts +0 -27
  37. package/apis/dict/list.ts +0 -18
  38. package/apis/dict/upd.ts +0 -31
  39. package/apis/menu/all.ts +0 -68
  40. package/apis/menu/del.ts +0 -37
  41. package/apis/menu/ins.ts +0 -20
  42. package/apis/menu/list.ts +0 -21
  43. package/apis/menu/upd.ts +0 -29
  44. package/apis/role/apiDetail.ts +0 -30
  45. package/apis/role/apiSave.ts +0 -41
  46. package/apis/role/del.ts +0 -44
  47. package/apis/role/detail.ts +0 -24
  48. package/apis/role/ins.ts +0 -39
  49. package/apis/role/list.ts +0 -14
  50. package/apis/role/menuDetail.ts +0 -30
  51. package/apis/role/menuSave.ts +0 -38
  52. package/apis/role/save.ts +0 -44
  53. package/apis/role/upd.ts +0 -40
  54. package/bin/index.ts +0 -34
  55. package/checks/conflict.ts +0 -351
  56. package/checks/table.ts +0 -250
  57. package/commands/index.ts +0 -73
  58. package/commands/sync.ts +0 -88
  59. package/commands/syncApi.ts +0 -316
  60. package/commands/syncDb/apply.ts +0 -171
  61. package/commands/syncDb/constants.ts +0 -77
  62. package/commands/syncDb/ddl.ts +0 -191
  63. package/commands/syncDb/helpers.ts +0 -173
  64. package/commands/syncDb/index.ts +0 -217
  65. package/commands/syncDb/schema.ts +0 -199
  66. package/commands/syncDb/sqlite.ts +0 -50
  67. package/commands/syncDb/state.ts +0 -112
  68. package/commands/syncDb/table.ts +0 -214
  69. package/commands/syncDb/tableCreate.ts +0 -149
  70. package/commands/syncDb/types.ts +0 -92
  71. package/commands/syncDb/version.ts +0 -73
  72. package/commands/syncDb.ts +0 -34
  73. package/commands/syncDev.ts +0 -237
  74. package/commands/syncMenu.ts +0 -349
  75. package/commands/util.ts +0 -58
  76. package/tables/admin.json +0 -14
  77. package/tables/api.json +0 -8
  78. package/tables/dict.json +0 -8
  79. package/tables/menu.json +0 -8
  80. package/tables/role.json +0 -8
package/apis/admin/ins.ts DELETED
@@ -1,61 +0,0 @@
1
- /**
2
- * 添加管理员
3
- */
4
-
5
- import { Yes, No, Cipher } from '../../util.js';
6
- import { Cipher } from '../../lib/cipher.js';
7
- import adminTable from '../../tables/admin.json';
8
-
9
- export default {
10
- name: '添加管理员',
11
- fields: adminTable,
12
- required: ['username', 'email', 'password'],
13
- handler: async (befly, ctx) => {
14
- // 检查用户名是否已存在
15
- if (ctx.body.username) {
16
- const existingByUsername = await befly.db.getOne({
17
- table: 'core_admin',
18
- where: { username: ctx.body.username }
19
- });
20
-
21
- if (existingByUsername) {
22
- return No('用户名已被使用');
23
- }
24
- }
25
-
26
- // 检查邮箱是否已存在
27
- const existingByEmail = await befly.db.getOne({
28
- table: 'core_admin',
29
- where: { email: ctx.body.email }
30
- });
31
-
32
- if (existingByEmail) {
33
- return No('邮箱已被使用');
34
- }
35
-
36
- // 加密密码
37
- const hashedPassword = await Cipher.hashPassword(ctx.body.password);
38
-
39
- // 创建管理员
40
- const adminId = await befly.db.insData({
41
- table: 'core_admin',
42
- data: {
43
- username: ctx.body.username,
44
- email: ctx.body.email,
45
- password: hashedPassword,
46
- name: ctx.body.name,
47
- nickname: ctx.body.nickname,
48
- phone: ctx.body.phone,
49
- roleId: ctx.body.roleId || 0,
50
- roleCode: ctx.body.roleCode || '',
51
- roleType: ctx.body.roleType || 'user'
52
- }
53
- });
54
-
55
- return Yes('添加成功', {
56
- id: adminId,
57
- username: ctx.body.username,
58
- email: ctx.body.email
59
- });
60
- }
61
- };
@@ -1,20 +0,0 @@
1
- /**
2
- * 获取管理员列表
3
- */
4
-
5
- import { Yes } from '../../util.js';
6
-
7
- export default {
8
- name: '获取管理员列表',
9
- handler: async (befly, ctx) => {
10
- // 查询所有管理员(框架自动排除password字段,自动转换字段名为小驼峰)
11
- const result = await befly.db.getList({
12
- table: 'core_admin',
13
- page: ctx.body.page || 1,
14
- limit: ctx.body.limit || 10,
15
- orderBy: ['createdAt#DESC']
16
- });
17
-
18
- return Yes('获取成功', result);
19
- }
20
- };
@@ -1,35 +0,0 @@
1
- /**
2
- * 获取管理员的角色(单角色模式)
3
- */
4
-
5
- import { Yes, No } from '../../util.js';
6
-
7
- export default {
8
- name: '获取管理员角色',
9
- handler: async (befly, ctx) => {
10
- // 查询管理员信息(框架自动转换为小驼峰)
11
- const admin = await befly.db.getOne({
12
- table: 'core_admin',
13
- where: { id: ctx.body.adminId }
14
- });
15
-
16
- if (!admin) {
17
- return No('管理员不存在');
18
- }
19
-
20
- // 如果有角色编码,查询角色详细信息(使用 roleCode 而非 roleId)
21
- let roleInfo = null;
22
- if (admin.roleCode) {
23
- roleInfo = await befly.db.getOne({
24
- table: 'core_role',
25
- where: { code: admin.roleCode }
26
- });
27
- }
28
-
29
- return Yes('操作成功', {
30
- roleId: admin.roleId,
31
- roleCode: admin.roleCode,
32
- role: roleInfo
33
- });
34
- }
35
- };
@@ -1,40 +0,0 @@
1
- /**
2
- * 保存管理员的角色(单角色模式)
3
- */
4
-
5
- import { Yes, No } from '../../util.js';
6
-
7
- export default {
8
- name: '保存管理员角色',
9
- fields: {
10
- adminId: '@id',
11
- roleCode: '角色编码|string|2|50|null|1|^[a-zA-Z0-9_]+$'
12
- },
13
- handler: async (befly, ctx) => {
14
- // 查询角色是否存在(使用 roleCode 而非 roleId)
15
- const role = await befly.db.getOne({
16
- table: 'core_role',
17
- where: { code: ctx.body.roleCode }
18
- });
19
-
20
- if (!role) {
21
- return No('角色不存在');
22
- }
23
-
24
- // 根据角色编码判断角色类型(硬编码规则)
25
- const roleType = role.code === 'dev' || role.code === 'admin' ? 'admin' : 'user';
26
-
27
- // 更新管理员的角色ID、角色编码和角色类型
28
- await befly.db.updData({
29
- table: 'core_admin',
30
- where: { id: ctx.body.adminId },
31
- data: {
32
- roleId: role.id,
33
- roleCode: role.code,
34
- roleType: roleType
35
- }
36
- });
37
-
38
- return Yes('操作成功');
39
- }
40
- };
package/apis/admin/upd.ts DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * 更新管理员信息
3
- */
4
-
5
- import { Yes, No } from '../../util.js';
6
- import adminTable from '../../tables/admin.json';
7
-
8
- export default {
9
- name: '更新管理员',
10
- fields: {
11
- name: adminTable.name,
12
- nickname: adminTable.nickname,
13
- email: adminTable.email,
14
- phone: adminTable.phone
15
- },
16
- required: ['id'],
17
- handler: async (befly, ctx) => {
18
- const { id, ...updateData } = ctx.body;
19
-
20
- // 检查管理员是否存在
21
- const admin = await befly.db.getOne({
22
- table: 'core_admin',
23
- where: { id }
24
- });
25
-
26
- if (!admin) {
27
- return No('管理员不存在');
28
- }
29
-
30
- // 如果更新邮箱,检查是否重复
31
- if (updateData.email && updateData.email !== admin.email) {
32
- const existingAdmin = await befly.db.getOne({
33
- table: 'core_admin',
34
- where: { email: updateData.email }
35
- });
36
-
37
- if (existingAdmin) {
38
- return No('邮箱已被使用');
39
- }
40
- }
41
-
42
- // 更新管理员信息
43
- await befly.db.updData({
44
- table: 'core_admin',
45
- data: updateData,
46
- where: { id }
47
- });
48
-
49
- return Yes('更新成功');
50
- }
51
- };
package/apis/api/all.ts DELETED
@@ -1,37 +0,0 @@
1
- /**
2
- * 获取所有接口列表
3
- * 说明:用于角色权限配置,返回所有接口信息
4
- */
5
-
6
- import { Yes, No } from '../../util.js';
7
-
8
- export default {
9
- name: '获取所有接口',
10
- handler: async (befly, ctx) => {
11
- try {
12
- // 从 Redis 缓存读取所有接口
13
- let allApis = await befly.redis.getObject<any[]>('apis:all');
14
-
15
- // 如果缓存不存在,从数据库查询
16
- if (!allApis || allApis.length === 0) {
17
- befly.logger.info('接口缓存未命中,从数据库查询');
18
- allApis = await befly.db.getAll({
19
- table: 'core_api',
20
- fields: ['id', 'name', 'path', 'method', 'description', 'addonName', 'addonTitle'],
21
- orderBy: ['addonName#ASC', 'path#ASC']
22
- });
23
-
24
- // 回写缓存
25
- if (allApis.length > 0) {
26
- await befly.redis.setObject('apis:all', allApis);
27
- }
28
- return Yes('操作成功', { lists: allApis, from: '来自数据库' });
29
- } else {
30
- return Yes('操作成功', { lists: allApis, from: '来自缓存' });
31
- }
32
- } catch (error: any) {
33
- befly.logger.error('获取接口列表失败:', error);
34
- return No('获取接口列表失败');
35
- }
36
- }
37
- };
@@ -1,78 +0,0 @@
1
- /**
2
- * 管理员登录接口
3
- */
4
-
5
- import { Yes, No } from '../../util.js';
6
- import { Cipher } from '../../lib/cipher.js';
7
- import { Jwt } from '../../lib/jwt.js';
8
- import adminTable from '../../tables/admin.json';
9
-
10
- export default {
11
- name: '管理员登录',
12
- auth: false,
13
- fields: {
14
- account: '账号|string|3|100|null|1|null',
15
- password: adminTable.password
16
- },
17
- required: ['account', 'password'],
18
- handler: async (befly, ctx) => {
19
- // 查询管理员(account 匹配 username 或 email)
20
- const admin = await befly.db.getOne({
21
- table: 'core_admin',
22
- where: {
23
- $or: [{ username: ctx.body.account }, { email: ctx.body.account }]
24
- }
25
- });
26
-
27
- if (!admin) {
28
- return No('账号或密码错误1');
29
- }
30
-
31
- // 验证密码
32
- try {
33
- const isValid = await Cipher.verifyPassword(ctx.body.password, admin.password);
34
- if (!isValid) {
35
- return No('账号或密码错误2');
36
- }
37
- } catch (error) {
38
- befly.logger.error('密码验证失败', error);
39
- return No('密码格式错误,请重新设置密码');
40
- }
41
-
42
- // 检查账号状态(state=1 表示正常,state=2 表示禁用)
43
- if (admin.state === 2) {
44
- return No('账号已被禁用');
45
- }
46
-
47
- // 更新最后登录信息
48
- await befly.db.updData({
49
- table: 'core_admin',
50
- where: { id: admin.id },
51
- data: {
52
- lastLoginTime: Date.now(),
53
- lastLoginIp: ctx.ip || 'unknown'
54
- }
55
- });
56
-
57
- // 生成 JWT Token(包含核心身份信息)
58
- const token = await Jwt.sign(
59
- {
60
- id: admin.id,
61
- nickname: admin.nickname,
62
- roleCode: admin.roleCode,
63
- roleType: admin.roleType
64
- },
65
- {
66
- expiresIn: '7d'
67
- }
68
- );
69
-
70
- // 返回用户信息(不包含密码)
71
- const { password: _, ...userWithoutPassword } = admin;
72
-
73
- return Yes('登录成功', {
74
- token,
75
- userInfo: userWithoutPassword
76
- });
77
- }
78
- };
@@ -1,23 +0,0 @@
1
- /**
2
- * 退出登录接口
3
- */
4
-
5
- import { Yes } from '../../util.js';
6
-
7
- export default {
8
- name: '退出登录',
9
- handler: async (befly, ctx) => {
10
- // JWT token 是无状态的,前端删除 token 即可
11
- // 如果需要实现 token 黑名单,可以在这里将 token 加入 Redis 黑名单
12
-
13
- const token = ctx.headers.authorization?.replace('Bearer ', '');
14
-
15
- if (token && befly.redis) {
16
- // 将 token 加入黑名单,有效期设置为 token 的剩余有效期
17
- const key = `token_blacklist:${token}`;
18
- await befly.redis.set(key, '1', 'EX', 7 * 24 * 60 * 60); // 7天
19
- }
20
-
21
- return Yes('退出成功');
22
- }
23
- };
@@ -1,50 +0,0 @@
1
- /**
2
- * 管理员注册接口
3
- */
4
-
5
- import { Yes, No } from '../../util.js';
6
- import { Cipher } from '../../lib/cipher.js';
7
-
8
- import adminTable from '../../tables/admin.json';
9
-
10
- export default {
11
- name: '管理员注册',
12
- auth: false,
13
- fields: {
14
- name: adminTable.name,
15
- email: adminTable.email,
16
- password: adminTable.password
17
- },
18
- required: ['name', 'email', 'password'],
19
- handler: async (befly, ctx) => {
20
- // 检查邮箱是否已存在
21
- const existingAdmin = await befly.db.getOne({
22
- table: 'core_admin',
23
- where: { email: ctx.body.email }
24
- });
25
-
26
- if (existingAdmin) {
27
- return No('该邮箱已被注册');
28
- }
29
-
30
- // 加密密码
31
- const hashedPassword = await Cipher.hashPassword(ctx.body.password);
32
-
33
- // 创建管理员
34
- const adminId = await befly.db.insData({
35
- table: 'core_admin',
36
- data: {
37
- name: ctx.body.name,
38
- email: ctx.body.email,
39
- password: hashedPassword,
40
- role: 'user' // 默认为普通用户,state 由框架自动设置为 1
41
- }
42
- });
43
-
44
- return Yes('注册成功', {
45
- id: adminId,
46
- name: ctx.body.name,
47
- email: ctx.body.email
48
- });
49
- }
50
- };
@@ -1,36 +0,0 @@
1
- /**
2
- * 发送短信验证码接口
3
- */
4
-
5
- import { Yes } from '../../util.js';
6
- import { Env } from '../../env.js';
7
- import adminTable from '../../tables/admin.json';
8
-
9
- export default {
10
- name: '发送短信验证码',
11
- auth: false,
12
- fields: {
13
- phone: adminTable.phone
14
- },
15
- required: ['phone'],
16
- handler: async (befly, ctx) => {
17
- // 生成6位数验证码
18
- const code = Math.floor(100000 + Math.random() * 900000).toString();
19
-
20
- // TODO: 调用短信服务发送验证码
21
- // 这里需要集成实际的短信服务提供商(如阿里云、腾讯云等)
22
- // await smsService.send(phone, code);
23
-
24
- // 将验证码存储到 Redis 中,有效期5分钟
25
- // 如果项目没有 Redis,也可以存储到数据库中
26
- if (befly.redis) {
27
- const key = `sms_code:${ctx.body.phone}`;
28
- await befly.redis.set(key, code, 'EX', 300); // 5分钟过期
29
- }
30
-
31
- // 开发环境下返回验证码(生产环境应该删除)
32
- const isDev = Env.NODE_ENV === 'development';
33
-
34
- return Yes('验证码已发送', isDev ? { code } : null);
35
- }
36
- };
@@ -1,34 +0,0 @@
1
- /**
2
- * 刷新所有缓存到 Redis
3
- * 说明:手动触发缓存刷新,无需重启服务器
4
- */
5
-
6
- import type { ApiRoute } from 'befly/types/api';
7
- import { Yes, No, Field } from 'befly';
8
-
9
- export default {
10
- name: '刷新缓存',
11
- method: 'POST',
12
- auth: true,
13
- fields: {},
14
- required: [],
15
- handler: async (befly, ctx) => {
16
- try {
17
- // 检查权限(仅 dev 角色可执行)
18
- if (ctx.user?.role !== 'dev') {
19
- return No('无权限执行此操作');
20
- }
21
-
22
- // 执行缓存刷新
23
- await befly.cache.cacheAll(befly.apiRoutes, befly);
24
-
25
- return Yes('缓存刷新成功', {
26
- message: '已重新缓存接口、菜单和角色权限'
27
- });
28
- } catch (error: any) {
29
- return No('缓存刷新失败', {
30
- error: error.message
31
- });
32
- }
33
- }
34
- } as ApiRoute;
@@ -1,47 +0,0 @@
1
- /**
2
- * 获取插件列表
3
- */
4
-
5
- import { Yes, scanAddons, getAddonDir } from '../../util.js';
6
- import { readFileSync } from 'node:fs';
7
-
8
- export default {
9
- name: '获取插件列表',
10
- handler: async (befly, ctx) => {
11
- const addonList: Array<{ name: string; title: string; version: string; description: string; enabled: boolean }> = [];
12
-
13
- // 使用 scanAddons 扫描所有 addon
14
- const addonNames = scanAddons();
15
-
16
- for (const addonName of addonNames) {
17
- // addonName 格式: admin, demo 等
18
-
19
- // 读取插件配置文件
20
- const configPath = getAddonDir(addonName, 'addon.config.json');
21
-
22
- try {
23
- const configContent = readFileSync(configPath, 'utf-8');
24
- const config = JSON.parse(configContent);
25
-
26
- addonList.push({
27
- name: config.name || addonName,
28
- title: config.title || addonName,
29
- version: config.version || '1.0.0',
30
- description: config.description || '',
31
- enabled: true
32
- });
33
- } catch (error) {
34
- // 配置文件不存在或解析失败,使用默认值
35
- addonList.push({
36
- name: addonName,
37
- title: addonName,
38
- version: '1.0.0',
39
- description: '',
40
- enabled: true
41
- });
42
- }
43
- }
44
-
45
- return Yes('获取成功', addonList);
46
- }
47
- };
@@ -1,37 +0,0 @@
1
- /**
2
- * 获取更新日志
3
- */
4
-
5
- import { Yes } from '../../util.js';
6
-
7
- export default {
8
- name: '获取更新日志',
9
- handler: async (befly, ctx) => {
10
- // 更新日志数据(实际项目中可以从配置文件或数据库读取)
11
- const changelog = [
12
- {
13
- version: 'v1.0.0',
14
- date: '2025-10-25',
15
- changes: ['新增角色权限管理功能', '新增菜单权限分配功能', '新增接口权限管理功能', '优化菜单同步性能', '优化字段类型验证', '修复数组类型字段验证bug']
16
- },
17
- {
18
- version: 'v0.9.0',
19
- date: '2025-10-20',
20
- changes: ['初始版本发布', '完成基础框架搭建', '实现用户认证功能', '实现RBAC权限系统']
21
- },
22
- {
23
- version: 'v0.8.0',
24
- date: '2025-10-15',
25
- changes: ['完成数据库设计', '实现核心API', '添加字段验证器', '集成Redis缓存']
26
- }
27
- ];
28
-
29
- // 根据 limit 参数返回指定数量的日志
30
- const limit = ctx.body.limit || 5;
31
- const lists = changelog.slice(0, limit);
32
-
33
- return Yes('获取成功', {
34
- lists: lists
35
- });
36
- }
37
- };
@@ -1,54 +0,0 @@
1
- /**
2
- * 获取系统配置状态
3
- */
4
-
5
- import { Yes } from '../../util.js';
6
-
7
- export default {
8
- name: '获取配置状态',
9
- handler: async (befly, ctx) => {
10
- const status = {
11
- database: { status: 'ok', latency: 0 },
12
- redis: { status: 'ok', latency: 0 },
13
- fileSystem: { status: 'ok' },
14
- email: { status: 'warning', message: '未配置' },
15
- oss: { status: 'warning', message: '未配置' }
16
- };
17
-
18
- // 检查数据库连接
19
- try {
20
- const startTime = Date.now();
21
- await befly.db.query('SELECT 1');
22
- status.database.latency = Date.now() - startTime;
23
- status.database.status = 'ok';
24
- } catch (error) {
25
- status.database.status = 'error';
26
- status.database.message = '连接失败';
27
- }
28
-
29
- // 检查 Redis 连接
30
- try {
31
- const startTime = Date.now();
32
- await befly.redis.ping();
33
- status.redis.latency = Date.now() - startTime;
34
- status.redis.status = 'ok';
35
- } catch (error) {
36
- status.redis.status = 'error';
37
- status.redis.message = '连接失败';
38
- }
39
-
40
- // 检查邮件配置
41
- if (process.env.SMTP_HOST && process.env.SMTP_PORT) {
42
- status.email.status = 'ok';
43
- status.email.message = '已配置';
44
- }
45
-
46
- // 检查 OSS 配置
47
- if (process.env.OSS_ACCESS_KEY && process.env.OSS_SECRET_KEY) {
48
- status.oss.status = 'ok';
49
- status.oss.message = '已配置';
50
- }
51
-
52
- return Yes('获取成功', status);
53
- }
54
- };
@@ -1,46 +0,0 @@
1
- /**
2
- * 获取运行环境信息
3
- */
4
-
5
- import { Yes } from '../../util.js';
6
- import os from 'node:os';
7
-
8
- export default {
9
- name: '获取运行环境信息',
10
- handler: async (befly, ctx) => {
11
- // 获取数据库版本
12
- let databaseVersion = 'Unknown';
13
- try {
14
- const versionResult = await befly.db.query({
15
- sql: 'SELECT VERSION() as version',
16
- type: 'one'
17
- });
18
- databaseVersion = versionResult.version || 'Unknown';
19
- } catch (error) {
20
- // 忽略错误
21
- }
22
-
23
- // 获取 Redis 版本
24
- let redisVersion = '未配置';
25
- if (befly.redis) {
26
- try {
27
- const info = await befly.redis.info('server');
28
- const match = info.match(/redis_version:([^\r\n]+)/);
29
- if (match) {
30
- redisVersion = match[1];
31
- }
32
- } catch (error) {
33
- redisVersion = '未知';
34
- }
35
- }
36
-
37
- return Yes('获取成功', {
38
- os: `${os.type()} ${os.arch()}`,
39
- server: `${os.platform()} ${os.release()}`,
40
- nodeVersion: process.version,
41
- database: `MySQL ${databaseVersion}`,
42
- cache: `Redis ${redisVersion}`,
43
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
44
- });
45
- }
46
- };
@@ -1,23 +0,0 @@
1
- /**
2
- * 获取性能指标
3
- */
4
-
5
- import { Yes } from '../../util.js';
6
-
7
- export default {
8
- name: '获取性能指标',
9
- handler: async (befly, ctx) => {
10
- // 实际项目中,这些数据应该从监控系统或日志中获取
11
- // 这里提供示例数据结构
12
- return Yes('获取成功', {
13
- avgResponseTime: 125,
14
- qps: 856,
15
- errorRate: 0.8,
16
- activeConnections: 45,
17
- slowestApi: {
18
- path: '/addon/admin/menuList',
19
- time: 450
20
- }
21
- });
22
- }
23
- };