@yysports/tools 1.0.0-alpha.2 → 1.0.1

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.
package/README.md CHANGED
@@ -2,3 +2,12 @@
2
2
 
3
3
  [![NPM version](https://img.shields.io/npm/v/@yysports/tools.svg?style=flat)](https://npmjs.org/package/@yysports/tools)
4
4
  [![NPM downloads](http://img.shields.io/npm/dm/@yysports/tools.svg?style=flat)](https://npmjs.org/package/@yysports/tools)
5
+
6
+ ## 更新日志
7
+
8
+ ### 1.0.0
9
+
10
+ `2025-07-15`
11
+
12
+ - 🆕 用户信息增加人资组织编码 orgCode
13
+ - 🆕 用户信息增加权限中心配置的部门数据权限 dataScopeZonePermissions
@@ -1,13 +1,14 @@
1
- var _excluded = ["userProfile", "menuNameMap", "routes", "getAuth", "menuBuild", "getDataScopeZonePermissions"];
1
+ var _excluded = ["roles"],
2
+ _excluded2 = ["userProfile", "menuNameMap", "routes", "getAuth", "menuBuild", "getDataScopeZonePermissions"];
2
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
6
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
7
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
8
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
9
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
11
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
12
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
13
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
14
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -139,7 +140,7 @@ var Track = /*#__PURE__*/function () {
139
140
  key: "initAuthCenterData",
140
141
  value: function () {
141
142
  var _initAuthCenterData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
142
- var getAuth, menuBuild, getDataScopeZonePermissions, menuNameMap, routes, authCenterApi, _yield$Promise$all, _yield$Promise$all2, _yield$Promise$all2$, authInfo, _yield$Promise$all2$2, menuData, dataScopeZonePermissions, _ref2, _ref2$user, user, _ref2$roles, roles, isAdmin, accessPage, routesMap, authCenterUserProfile;
143
+ var getAuth, menuBuild, getDataScopeZonePermissions, menuNameMap, routes, authCenterApi, _yield$Promise$all, _yield$Promise$all2, _yield$Promise$all2$, authInfo, _yield$Promise$all2$2, menuData, dataScopeZonePermissions, _ref2, _ref2$user, user, _ref2$roles, roles, dataScopeRoles, restUser, isAdmin, accessPage, routesMap, authCenterUserProfile;
143
144
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
144
145
  while (1) switch (_context2.prev = _context2.next) {
145
146
  case 0:
@@ -175,6 +176,7 @@ var Track = /*#__PURE__*/function () {
175
176
  menuData = _yield$Promise$all2$2 === void 0 ? [] : _yield$Promise$all2$2;
176
177
  dataScopeZonePermissions = _yield$Promise$all2[2];
177
178
  _ref2 = authInfo || {}, _ref2$user = _ref2.user, user = _ref2$user === void 0 ? {} : _ref2$user, _ref2$roles = _ref2.roles, roles = _ref2$roles === void 0 ? [] : _ref2$roles;
179
+ dataScopeRoles = user.roles, restUser = _objectWithoutProperties(user, _excluded); // 权限中心的用户信息
178
180
  isAdmin = roles.includes('admin'); // 当前用户所拥有的所有页面权限
179
181
  accessPage = []; // 获取本地菜单信息映射
180
182
  if (routes) {
@@ -197,7 +199,8 @@ var Track = /*#__PURE__*/function () {
197
199
  this.routesMap = routesMap;
198
200
  }
199
201
  this.authMap = getAuthMapByAuthCenter(menuData);
200
- authCenterUserProfile = _objectSpread(_objectSpread({}, user), {}, {
202
+ authCenterUserProfile = _objectSpread(_objectSpread({}, restUser), {}, {
203
+ dataScopeRoles: dataScopeRoles,
201
204
  roles: roles,
202
205
  accessPage: accessPage
203
206
  });
@@ -208,7 +211,7 @@ var Track = /*#__PURE__*/function () {
208
211
  }
209
212
  this.authCenterUserProfile = authCenterUserProfile;
210
213
  return _context2.abrupt("return", authCenterUserProfile);
211
- case 23:
214
+ case 24:
212
215
  case "end":
213
216
  return _context2.stop();
214
217
  }
@@ -223,12 +226,12 @@ var Track = /*#__PURE__*/function () {
223
226
  key: "init",
224
227
  value: function () {
225
228
  var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref3) {
226
- var _this$authCenterUserP;
227
- var userProfile, menuNameMap, routes, getAuth, menuBuild, getDataScopeZonePermissions, restConfig, currentUserProfile;
229
+ var _this$authCenterUserP2;
230
+ var userProfile, menuNameMap, routes, getAuth, menuBuild, getDataScopeZonePermissions, restConfig, currentUserProfile, _this$authCenterUserP;
228
231
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
229
232
  while (1) switch (_context3.prev = _context3.next) {
230
233
  case 0:
231
- userProfile = _ref3.userProfile, menuNameMap = _ref3.menuNameMap, routes = _ref3.routes, getAuth = _ref3.getAuth, menuBuild = _ref3.menuBuild, getDataScopeZonePermissions = _ref3.getDataScopeZonePermissions, restConfig = _objectWithoutProperties(_ref3, _excluded);
234
+ userProfile = _ref3.userProfile, menuNameMap = _ref3.menuNameMap, routes = _ref3.routes, getAuth = _ref3.getAuth, menuBuild = _ref3.menuBuild, getDataScopeZonePermissions = _ref3.getDataScopeZonePermissions, restConfig = _objectWithoutProperties(_ref3, _excluded2);
232
235
  this.checkConfig(restConfig);
233
236
  this.config = restConfig;
234
237
  _context3.next = 5;
@@ -245,12 +248,16 @@ var Track = /*#__PURE__*/function () {
245
248
  Object.assign(currentUserProfile, {
246
249
  userId: this.authCenterUserProfile.userName,
247
250
  userName: this.authCenterUserProfile.nickName,
248
- orgCode: this.authCenterUserProfile.orgCode
251
+ orgCode: this.authCenterUserProfile.orgCode,
252
+ orgTitle: this.authCenterUserProfile.orgTitle,
253
+ dataScopeRoles: (_this$authCenterUserP = this.authCenterUserProfile.dataScopeRoles) === null || _this$authCenterUserP === void 0 ? void 0 : _this$authCenterUserP.map(function (role) {
254
+ return role.name;
255
+ }).join(',')
249
256
  });
250
257
  }
251
258
 
252
259
  // 传入区部数据权限接口时,设置区部权限数据
253
- if (this.authCenterUserProfile.dataScopeZonePermissions && ((_this$authCenterUserP = this.authCenterUserProfile.dataScopeZonePermissions) === null || _this$authCenterUserP === void 0 || (_this$authCenterUserP = _this$authCenterUserP.list) === null || _this$authCenterUserP === void 0 ? void 0 : _this$authCenterUserP.length) > 0) {
260
+ if (this.authCenterUserProfile.dataScopeZonePermissions && ((_this$authCenterUserP2 = this.authCenterUserProfile.dataScopeZonePermissions) === null || _this$authCenterUserP2 === void 0 || (_this$authCenterUserP2 = _this$authCenterUserP2.list) === null || _this$authCenterUserP2 === void 0 ? void 0 : _this$authCenterUserP2.length) > 0) {
254
261
  // 提取出所有 zoneId
255
262
  Object.assign(currentUserProfile, {
256
263
  dataScopeZonePermissions: this.authCenterUserProfile.dataScopeZonePermissions.list.map(function (item) {
@@ -45,7 +45,9 @@ export interface UserProfile {
45
45
  userId: string;
46
46
  userName: string;
47
47
  orgCode?: string;
48
+ orgTitle?: string;
48
49
  dataScopeZonePermissions?: string;
50
+ dataScopeRoles?: string;
49
51
  }
50
52
  export interface AuthCenterUserProfile {
51
53
  userName: string;
@@ -58,6 +60,11 @@ export interface AuthCenterUserProfile {
58
60
  roles?: string[];
59
61
  accessPage?: string[];
60
62
  orgCode: string;
63
+ orgTitle: string;
64
+ dataScopeRoles?: {
65
+ id: string;
66
+ name: string;
67
+ }[];
61
68
  dataScopeZonePermissions?: {
62
69
  list: {
63
70
  regionId: string;
@@ -135,6 +135,7 @@ var Track = class {
135
135
  })
136
136
  );
137
137
  const { user = {}, roles = [] } = authInfo || {};
138
+ const { roles: dataScopeRoles, ...restUser } = user;
138
139
  const isAdmin = roles.includes("admin");
139
140
  const accessPage = [];
140
141
  if (routes) {
@@ -157,7 +158,12 @@ var Track = class {
157
158
  this.routesMap = routesMap;
158
159
  }
159
160
  this.authMap = (0, import_Utils.getAuthMapByAuthCenter)(menuData);
160
- const authCenterUserProfile = { ...user, roles, accessPage };
161
+ const authCenterUserProfile = {
162
+ ...restUser,
163
+ dataScopeRoles,
164
+ roles,
165
+ accessPage
166
+ };
161
167
  if (dataScopeZonePermissions) {
162
168
  Object.assign(authCenterUserProfile, { dataScopeZonePermissions });
163
169
  }
@@ -174,7 +180,7 @@ var Track = class {
174
180
  getDataScopeZonePermissions,
175
181
  ...restConfig
176
182
  }) {
177
- var _a, _b;
183
+ var _a, _b, _c;
178
184
  this.checkConfig(restConfig);
179
185
  this.config = restConfig;
180
186
  await this.initAuthCenterData({
@@ -189,10 +195,12 @@ var Track = class {
189
195
  Object.assign(currentUserProfile, {
190
196
  userId: this.authCenterUserProfile.userName,
191
197
  userName: this.authCenterUserProfile.nickName,
192
- orgCode: this.authCenterUserProfile.orgCode
198
+ orgCode: this.authCenterUserProfile.orgCode,
199
+ orgTitle: this.authCenterUserProfile.orgTitle,
200
+ dataScopeRoles: (_a = this.authCenterUserProfile.dataScopeRoles) == null ? void 0 : _a.map((role) => role.name).join(",")
193
201
  });
194
202
  }
195
- if (this.authCenterUserProfile.dataScopeZonePermissions && ((_b = (_a = this.authCenterUserProfile.dataScopeZonePermissions) == null ? void 0 : _a.list) == null ? void 0 : _b.length) > 0) {
203
+ if (this.authCenterUserProfile.dataScopeZonePermissions && ((_c = (_b = this.authCenterUserProfile.dataScopeZonePermissions) == null ? void 0 : _b.list) == null ? void 0 : _c.length) > 0) {
196
204
  Object.assign(currentUserProfile, {
197
205
  dataScopeZonePermissions: this.authCenterUserProfile.dataScopeZonePermissions.list.map((item) => item.list.map((zone) => zone.zoneId).join(",")).join(",")
198
206
  });
@@ -45,7 +45,9 @@ export interface UserProfile {
45
45
  userId: string;
46
46
  userName: string;
47
47
  orgCode?: string;
48
+ orgTitle?: string;
48
49
  dataScopeZonePermissions?: string;
50
+ dataScopeRoles?: string;
49
51
  }
50
52
  export interface AuthCenterUserProfile {
51
53
  userName: string;
@@ -58,6 +60,11 @@ export interface AuthCenterUserProfile {
58
60
  roles?: string[];
59
61
  accessPage?: string[];
60
62
  orgCode: string;
63
+ orgTitle: string;
64
+ dataScopeRoles?: {
65
+ id: string;
66
+ name: string;
67
+ }[];
61
68
  dataScopeZonePermissions?: {
62
69
  list: {
63
70
  regionId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yysports/tools",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.1",
4
4
  "description": "常用工具函数库",
5
5
  "homepage": "https://git.pousheng.com/sport-service-department/pousheng-guard/yysports_tools#readme",
6
6
  "bugs": {
@@ -71,10 +71,10 @@
71
71
  "@types/react": "^18.3.23",
72
72
  "@types/react-dom": "^18.3.7",
73
73
  "@umijs/lint": "^4.4.11",
74
- "antd": "^5.26.4",
74
+ "antd": "^5.26.5",
75
75
  "dumi": "^2.4.21",
76
- "eslint": "^9.30.1",
77
- "father": "^4.5.6",
76
+ "eslint": "^9.31.0",
77
+ "father": "^4.6.1",
78
78
  "husky": "^9.1.7",
79
79
  "lint-staged": "^16.1.2",
80
80
  "prettier": "^3.6.2",