@befly-addon/admin 1.1.13 → 1.1.15

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.
@@ -32,8 +32,8 @@ export default {
32
32
  orderBy: ['addonName#ASC', 'path#ASC']
33
33
  });
34
34
 
35
- await befly.redis.setObject(RedisKeys.apisAll(), apis);
36
- results.apis = { success: true, count: apis.length };
35
+ await befly.redis.setObject(RedisKeys.apisAll(), apis.lists);
36
+ results.apis = { success: true, count: apis.lists.length };
37
37
  } catch (error: any) {
38
38
  befly.logger.error({ err: error }, '刷新接口缓存失败');
39
39
  results.apis = { success: false, error: error.message };
@@ -47,14 +47,14 @@ export default {
47
47
  orderBy: ['sort#ASC', 'id#ASC']
48
48
  });
49
49
 
50
- await befly.redis.setObject(RedisKeys.menusAll(), menus);
50
+ await befly.redis.setObject(RedisKeys.menusAll(), menus.lists);
51
51
 
52
- const parentCount = menus.filter((m: any) => m.pid === 0).length;
53
- const childCount = menus.filter((m: any) => m.pid !== 0).length;
52
+ const parentCount = menus.lists.filter((m: any) => m.pid === 0).length;
53
+ const childCount = menus.lists.filter((m: any) => m.pid !== 0).length;
54
54
 
55
55
  results.menus = {
56
56
  success: true,
57
- count: menus.length,
57
+ count: menus.lists.length,
58
58
  parentCount: parentCount,
59
59
  childCount: childCount
60
60
  };
@@ -67,19 +67,18 @@ export default {
67
67
  try {
68
68
  const roles = await befly.db.getAll({
69
69
  table: 'addon_admin_role',
70
- fields: ['id', 'name', 'code', 'apis', 'menus'],
71
- orderBy: ['id#ASC']
70
+ fields: ['id', 'name', 'code', 'menus', 'apis']
72
71
  });
73
72
 
74
- // 使用 setBatch 批量缓存所有角色(利用 Bun Redis auto-pipeline)
75
- await befly.redis.setBatch(
76
- roles.map((role: any) => ({
73
+ // 使用 setBatch 批量缓存所有角色
74
+ const count = await befly.redis.setBatch(
75
+ roles.lists.map((role: any) => ({
77
76
  key: RedisKeys.roleInfo(role.code),
78
77
  value: role
79
78
  }))
80
79
  );
81
80
 
82
- results.roles = { success: true, count: roles.length };
81
+ results.roles = { success: true, count: count };
83
82
  } catch (error: any) {
84
83
  befly.logger.error({ err: error }, '刷新角色缓存失败');
85
84
  results.roles = { success: false, error: error.message };
package/apis/api/all.ts CHANGED
@@ -7,11 +7,12 @@
7
7
 
8
8
  // 如果缓存不存在,从数据库查询
9
9
  if (allApis.length === 0) {
10
- allApis = await befly.db.getAll({
10
+ const result = await befly.db.getAll({
11
11
  table: 'addon_admin_api',
12
12
  fields: ['id', 'name', 'path', 'method', 'description', 'addonName', 'addonTitle'],
13
13
  orderBy: ['addonName#ASC', 'path#ASC']
14
14
  });
15
+ allApis = result.lists;
15
16
  }
16
17
 
17
18
  return befly.tool.Yes('操作成功', { lists: allApis });
package/apis/dict/all.ts CHANGED
@@ -1,20 +1,12 @@
1
1
  export default {
2
2
  name: '获取所有字典',
3
- handler: async (befly, ctx) => {
4
- try {
5
- const dicts = await befly.db.getAll({
6
- table: 'addon_admin_dict',
7
- fields: ['id', 'name', 'code', 'value', 'sort', 'pid', 'description', 'state', 'created_at', 'updated_at'],
8
- orderBy: [
9
- { field: 'sort', direction: 'ASC' },
10
- { field: 'id', direction: 'ASC' }
11
- ]
12
- });
3
+ handler: async (befly) => {
4
+ const dicts = await befly.db.getAll({
5
+ table: 'addon_admin_dict',
6
+ fields: ['id', 'code', 'name', 'value'],
7
+ orderBy: ['id#ASC']
8
+ });
13
9
 
14
- return befly.tool.Yes('操作成功', dicts);
15
- } catch (error) {
16
- befly.logger.error({ err: error }, '获取所有字典失败');
17
- return befly.tool.No('操作失败');
18
- }
10
+ return befly.tool.Yes('操作成功', { lists: dicts.lists });
19
11
  }
20
12
  };
package/apis/menu/all.ts CHANGED
@@ -36,11 +36,12 @@ export default {
36
36
 
37
37
  // 如果缓存不存在,从数据库查询
38
38
  if (allMenus.length === 0) {
39
- allMenus = await befly.db.getAll({
39
+ const result = await befly.db.getAll({
40
40
  table: 'addon_admin_menu',
41
- fields: ['id', 'pid', 'name', 'path', 'icon', 'sort'],
41
+ fields: ['id', 'pid', 'name', 'path', 'sort'],
42
42
  orderBy: ['sort#ASC', 'id#ASC']
43
43
  });
44
+ allMenus = result.lists;
44
45
  }
45
46
 
46
47
  if (allMenus.length === 0) {
package/apis/menu/list.ts CHANGED
@@ -10,11 +10,11 @@
10
10
  try {
11
11
  const menus = await befly.db.getAll({
12
12
  table: 'addon_admin_menu',
13
- fields: ['id', 'name', 'path', 'icon', 'sort', 'pid', 'state', 'created_at', 'updated_at'],
13
+ fields: ['*'],
14
14
  orderBy: ['sort#ASC', 'id#ASC']
15
15
  });
16
16
 
17
- return befly.tool.Yes('操作成功', menus);
17
+ return befly.tool.Yes('操作成功', { lists: menus.lists });
18
18
  } catch (error) {
19
19
  befly.logger.error({ err: error }, '获取菜单列表失败');
20
20
  return befly.tool.No('操作失败');
package/apis/role/all.ts CHANGED
@@ -11,6 +11,6 @@
11
11
  orderBy: ['sort#ASC', 'id#ASC']
12
12
  });
13
13
 
14
- return befly.tool.Yes('操作成功', roles);
14
+ return befly.tool.Yes('操作成功', { lists: roles.lists, total: roles.total });
15
15
  }
16
16
  };
@@ -1,12 +1,12 @@
1
1
  export default {
2
- name: '获取全部系统配置',
2
+ name: '获取所有系统配置',
3
3
  handler: async (befly, ctx) => {
4
4
  const result = await befly.db.getAll({
5
5
  table: 'addon_admin_sys_config',
6
- fields: ['id', 'name', 'code', 'value', 'valueType', 'group', 'sort', 'isSystem', 'description'],
7
- orderBy: ['group#ASC', 'sort#ASC', 'id#ASC']
6
+ fields: ['*'],
7
+ orderBy: ['id#ASC']
8
8
  });
9
9
 
10
- return befly.tool.Yes('操作成功', result);
10
+ return befly.tool.Yes('操作成功', { lists: result.lists });
11
11
  }
12
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@befly-addon/admin",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "title": "管理后台",
5
5
  "description": "Befly - 管理后台功能组件",
6
6
  "type": "module",
@@ -44,9 +44,9 @@
44
44
  "url": "https://github.com/chenbimo/befly.git",
45
45
  "directory": "packages/addon-admin"
46
46
  },
47
- "gitHead": "b589687f38d5057f1dd06602e823be2afe59e433",
47
+ "gitHead": "1f449cb3921fc8536f7392f039a6655b1b07b5e5",
48
48
  "dependencies": {
49
- "befly": "^3.9.25",
49
+ "befly": "^3.9.27",
50
50
  "befly-shared": "^1.2.3",
51
51
  "nodemailer": "^7.0.11",
52
52
  "ua-parser-js": "^2.0.7"