@yysports/tools 2.2.1 → 2.2.3

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.
@@ -11,7 +11,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
11
11
  */
12
12
  export var fetchCurrentUserFromAuthCenter = /*#__PURE__*/function () {
13
13
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fetchUserInfo, fetchMenuBuild, fetchZoneScope) {
14
- var _yield$Promise$all, _yield$Promise$all2, userInfo, menuBuild, zoneScope, currentUser, _userInfo$user, user, _userInfo$roles, roles, _user$roles, dataScopeRoles, isAdmin, accessPage, authLogMap, traverseMenu;
14
+ var _yield$Promise$all, _yield$Promise$all2, userInfo, menuBuild, zoneScope, currentUser, _userInfo$user, user, _userInfo$roles, roles, _user$roles, dataScopeRoles, isAdmin, _zoneScope$list, dataScopeZonePermissions, accessPage, authLogMap, traverseMenu;
15
15
  return _regeneratorRuntime().wrap(function _callee$(_context) {
16
16
  while (1) switch (_context.prev = _context.next) {
17
17
  case 0:
@@ -29,7 +29,9 @@ export var fetchCurrentUserFromAuthCenter = /*#__PURE__*/function () {
29
29
  _user$roles = user.roles, dataScopeRoles = _user$roles === void 0 ? [] : _user$roles;
30
30
  isAdmin = roles.includes('admin');
31
31
  Object.assign(currentUser, _objectSpread(_objectSpread({}, user), {}, {
32
- dataScopeRoles: dataScopeRoles,
32
+ dataScopeRoles: dataScopeRoles.map(function (v) {
33
+ return v.name;
34
+ }),
33
35
  // 用户拥有的数据权限角色
34
36
  roles: roles,
35
37
  // 用户拥有的页面、功能权限列表
@@ -37,8 +39,15 @@ export var fetchCurrentUserFromAuthCenter = /*#__PURE__*/function () {
37
39
  }));
38
40
  }
39
41
  if (zoneScope) {
42
+ dataScopeZonePermissions = [];
43
+ zoneScope === null || zoneScope === void 0 || (_zoneScope$list = zoneScope.list) === null || _zoneScope$list === void 0 || _zoneScope$list.forEach(function (region) {
44
+ var _region$list;
45
+ return region === null || region === void 0 || (_region$list = region.list) === null || _region$list === void 0 ? void 0 : _region$list.forEach(function (zone) {
46
+ return dataScopeZonePermissions.push(zone.zoneId);
47
+ });
48
+ });
40
49
  Object.assign(currentUser, {
41
- dataScopeZonePermissions: zoneScope // 用户拥有的数据权限区域列表
50
+ dataScopeZonePermissions: dataScopeZonePermissions // 用户拥有的数据权限区域列表
42
51
  });
43
52
  }
44
53
  if (Array.isArray(menuBuild)) {
@@ -25,20 +25,8 @@ export interface AuthCenterUserProfile {
25
25
  accessPage?: string[];
26
26
  orgCode: string;
27
27
  orgTitle: string;
28
- dataScopeRoles?: {
29
- id: string;
30
- name: string;
31
- }[];
32
- dataScopeZonePermissions?: {
33
- list: {
34
- regionId: string;
35
- regionName: string;
36
- list: {
37
- zoneId: string;
38
- zoneName: string;
39
- }[];
40
- }[];
41
- };
28
+ dataScopeRoles?: string[];
29
+ dataScopeZonePermissions?: string[];
42
30
  authLogMap?: Record<string, string>;
43
31
  }
44
32
  export interface SystemProfile {
package/lib/Utils/auth.js CHANGED
@@ -23,6 +23,7 @@ __export(auth_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(auth_exports);
25
25
  var fetchCurrentUserFromAuthCenter = async (fetchUserInfo, fetchMenuBuild, fetchZoneScope) => {
26
+ var _a;
26
27
  const [userInfo, menuBuild, zoneScope] = await Promise.all([
27
28
  fetchUserInfo == null ? void 0 : fetchUserInfo(),
28
29
  fetchMenuBuild == null ? void 0 : fetchMenuBuild(),
@@ -35,7 +36,7 @@ var fetchCurrentUserFromAuthCenter = async (fetchUserInfo, fetchMenuBuild, fetch
35
36
  const isAdmin = roles.includes("admin");
36
37
  Object.assign(currentUser, {
37
38
  ...user,
38
- dataScopeRoles,
39
+ dataScopeRoles: dataScopeRoles.map((v) => v.name),
39
40
  // 用户拥有的数据权限角色
40
41
  roles,
41
42
  // 用户拥有的页面、功能权限列表
@@ -44,8 +45,17 @@ var fetchCurrentUserFromAuthCenter = async (fetchUserInfo, fetchMenuBuild, fetch
44
45
  });
45
46
  }
46
47
  if (zoneScope) {
48
+ const dataScopeZonePermissions = [];
49
+ (_a = zoneScope == null ? void 0 : zoneScope.list) == null ? void 0 : _a.forEach(
50
+ (region) => {
51
+ var _a2;
52
+ return (_a2 = region == null ? void 0 : region.list) == null ? void 0 : _a2.forEach(
53
+ (zone) => dataScopeZonePermissions.push(zone.zoneId)
54
+ );
55
+ }
56
+ );
47
57
  Object.assign(currentUser, {
48
- dataScopeZonePermissions: zoneScope
58
+ dataScopeZonePermissions
49
59
  // 用户拥有的数据权限区域列表
50
60
  });
51
61
  }
@@ -54,8 +64,8 @@ var fetchCurrentUserFromAuthCenter = async (fetchUserInfo, fetchMenuBuild, fetch
54
64
  const authLogMap = {};
55
65
  const traverseMenu = (menus) => {
56
66
  menus.forEach(({ permission, logAction, children }) => {
57
- var _a;
58
- if (permission && (currentUser.isAdmin || ((_a = currentUser.roles) == null ? void 0 : _a.includes(permission)))) {
67
+ var _a2;
68
+ if (permission && (currentUser.isAdmin || ((_a2 = currentUser.roles) == null ? void 0 : _a2.includes(permission)))) {
59
69
  accessPage.push(permission);
60
70
  if (logAction) {
61
71
  authLogMap[permission] = logAction;
@@ -25,20 +25,8 @@ export interface AuthCenterUserProfile {
25
25
  accessPage?: string[];
26
26
  orgCode: string;
27
27
  orgTitle: string;
28
- dataScopeRoles?: {
29
- id: string;
30
- name: string;
31
- }[];
32
- dataScopeZonePermissions?: {
33
- list: {
34
- regionId: string;
35
- regionName: string;
36
- list: {
37
- zoneId: string;
38
- zoneName: string;
39
- }[];
40
- }[];
41
- };
28
+ dataScopeRoles?: string[];
29
+ dataScopeZonePermissions?: string[];
42
30
  authLogMap?: Record<string, string>;
43
31
  }
44
32
  export interface SystemProfile {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yysports/tools",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "常用工具函数库",
5
5
  "homepage": "https://git.pousheng.com/sport-service-department/pousheng-guard/yysports_tools#readme",
6
6
  "bugs": {