@befly-addon/admin 1.8.6 → 1.8.8

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 (34) hide show
  1. package/adminViews/config/dict/components/edit.vue +16 -8
  2. package/adminViews/config/dict/index.vue +3 -3
  3. package/adminViews/config/dictType/components/edit.vue +16 -8
  4. package/adminViews/config/dictType/index.vue +2 -1
  5. package/adminViews/config/system/components/edit.vue +17 -9
  6. package/adminViews/config/system/index.vue +2 -1
  7. package/adminViews/index/components/addonList.vue +10 -2
  8. package/adminViews/index/components/environmentInfo.vue +12 -2
  9. package/adminViews/index/components/operationLogs.vue +16 -2
  10. package/adminViews/index/components/performanceMetrics.vue +9 -3
  11. package/adminViews/index/components/serviceStatus.vue +11 -4
  12. package/adminViews/index/components/systemNotifications.vue +13 -2
  13. package/adminViews/index/components/systemOverview.vue +3 -2
  14. package/adminViews/index/components/systemResources.vue +10 -3
  15. package/adminViews/index/components/userInfo.vue +19 -5
  16. package/adminViews/log/email/index.vue +21 -12
  17. package/adminViews/log/login/index.vue +2 -1
  18. package/adminViews/log/operate/index.vue +2 -1
  19. package/adminViews/login_1/index.vue +11 -8
  20. package/adminViews/people/admin/components/edit.vue +17 -9
  21. package/adminViews/people/admin/index.vue +2 -1
  22. package/adminViews/permission/api/index.vue +3 -2
  23. package/adminViews/permission/menu/index.vue +3 -2
  24. package/adminViews/permission/role/components/api.vue +5 -5
  25. package/adminViews/permission/role/components/edit.vue +16 -8
  26. package/adminViews/permission/role/components/menu.vue +5 -5
  27. package/adminViews/permission/role/index.vue +2 -1
  28. package/apis/admin/cacheRefresh.ts +15 -3
  29. package/apis/api/all.ts +7 -14
  30. package/apis/menu/all.ts +21 -34
  31. package/apis/role/apis.ts +4 -12
  32. package/apis/role/menuSave.ts +10 -2
  33. package/apis/role/menus.ts +4 -11
  34. package/package.json +3 -3
package/apis/role/apis.ts CHANGED
@@ -8,20 +8,12 @@ const route: ApiRoute = {
8
8
  roleCode: adminRoleTable.code
9
9
  },
10
10
  handler: async (befly, ctx) => {
11
- // 查询角色信息
12
- const role = await befly.db.getOne({
13
- table: "addon_admin_role",
14
- where: { code: ctx.body.roleCode }
15
- });
16
-
17
- if (!role.data?.id) {
18
- return befly.tool.No("角色不存在");
11
+ const roleCode = typeof ctx.body.roleCode === "string" ? ctx.body.roleCode : "";
12
+ if (roleCode.length === 0) {
13
+ return befly.tool.No("参数不合法");
19
14
  }
20
15
 
21
- // 数据库自动将 array_text 转换为数组
22
- const rawApiPaths = Array.isArray(role.data.apis) ? role.data.apis : [];
23
- const apiPaths = rawApiPaths.map((p: unknown) => (typeof p === "string" ? p.trim() : "")).filter((p: string) => p.length > 0);
24
-
16
+ const apiPaths = await befly.cache.getRolePermissions(roleCode);
25
17
  return befly.tool.Yes("操作成功", { apiPaths: apiPaths });
26
18
  }
27
19
  };
@@ -10,6 +10,11 @@ const route: ApiRoute = {
10
10
  menuPaths: adminRoleTable.menus
11
11
  },
12
12
  handler: async (befly, ctx) => {
13
+ const roleCode = typeof ctx.body.roleCode === "string" ? ctx.body.roleCode : "";
14
+ if (roleCode.length === 0) {
15
+ return befly.tool.No("参数不合法");
16
+ }
17
+
13
18
  let menuPaths: string[] = [];
14
19
  try {
15
20
  menuPaths = normalizePathnameListInput(ctx.body.menuPaths, "menuPaths", false);
@@ -20,7 +25,7 @@ const route: ApiRoute = {
20
25
  // 查询角色是否存在
21
26
  const role = await befly.db.getOne({
22
27
  table: "addon_admin_role",
23
- where: { code: ctx.body.roleCode }
28
+ where: { code: roleCode }
24
29
  });
25
30
 
26
31
  if (!role.data?.id) {
@@ -30,12 +35,15 @@ const route: ApiRoute = {
30
35
  // 直接使用数组,数据库会自动处理存储
31
36
  await befly.db.updData({
32
37
  table: "addon_admin_role",
33
- where: { code: ctx.body.roleCode },
38
+ where: { code: roleCode },
34
39
  data: {
35
40
  menus: menuPaths
36
41
  }
37
42
  });
38
43
 
44
+ // 增量刷新 Redis 菜单权限缓存
45
+ await befly.cache.refreshRoleMenuPermissions(roleCode, menuPaths);
46
+
39
47
  return befly.tool.Yes("操作成功");
40
48
  }
41
49
  };
@@ -8,19 +8,12 @@ const route: ApiRoute = {
8
8
  roleCode: adminRoleTable.code
9
9
  },
10
10
  handler: async (befly, ctx) => {
11
- // 查询角色信息
12
- const role = await befly.db.getOne({
13
- table: "addon_admin_role",
14
- where: { code: ctx.body.roleCode }
15
- });
16
-
17
- if (!role.data?.id) {
18
- return befly.tool.No("角色不存在");
11
+ const roleCode = typeof ctx.body.roleCode === "string" ? ctx.body.roleCode : "";
12
+ if (roleCode.length === 0) {
13
+ return befly.tool.No("参数不合法");
19
14
  }
20
15
 
21
- // 数据库自动将 array_text 转换为数组
22
- const menuPaths = Array.isArray(role.data.menus) ? role.data.menus : [];
23
-
16
+ const menuPaths = await befly.cache.getRoleMenuPermissions(roleCode);
24
17
  return befly.tool.Yes("操作成功", menuPaths);
25
18
  }
26
19
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@befly-addon/admin",
3
- "version": "1.8.6",
4
- "gitHead": "3e615600f8069fb7b34939f2361df811129331a0",
3
+ "version": "1.8.8",
4
+ "gitHead": "8397629cd2bc2e37d91c3b15773af52ac8ff7681",
5
5
  "private": false,
6
6
  "description": "Befly - 管理后台功能组件",
7
7
  "keywords": [
@@ -54,7 +54,7 @@
54
54
  "ua-parser-js": "^2.0.8"
55
55
  },
56
56
  "devDependencies": {
57
- "befly": "^3.16.5"
57
+ "befly": "^3.16.6"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "befly": "^3.14.0"