@yysports/tools 0.0.6 → 0.0.7

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.
@@ -9,7 +9,7 @@ declare class Track {
9
9
  static getSystemProfile(): SystemProfile;
10
10
  static getUserProfile(): UserProfile;
11
11
  static setUserProfile(userProfile: UserProfile): void;
12
- static init({ userProfile, ...restConfig }: TrackConfig): void;
12
+ static init({ userProfile, menuNameMap, routes, getAuth, menuBuild, ...restConfig }: TrackConfig): Promise<void>;
13
13
  static pushQueue({ type, log, }: {
14
14
  type: TrackType;
15
15
  log: ErrorProfile | CustomizeProfile;
@@ -1,4 +1,4 @@
1
- var _excluded = ["userProfile"];
1
+ var _excluded = ["userProfile", "menuNameMap", "routes", "getAuth", "menuBuild"];
2
2
  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
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
4
  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."); }
@@ -148,27 +148,50 @@ var Track = /*#__PURE__*/function () {
148
148
  // 挂载初始配置
149
149
  }, {
150
150
  key: "init",
151
- value: function init(_ref) {
152
- var _CurrentUser$profile;
153
- var userProfile = _ref.userProfile,
154
- restConfig = _objectWithoutProperties(_ref, _excluded);
155
- this.checkConfig(restConfig);
156
- this.config = restConfig;
157
-
158
- // 如果对接了权限中心,取权限中心的用户信息
159
- if ((_CurrentUser$profile = CurrentUser.profile) !== null && _CurrentUser$profile !== void 0 && _CurrentUser$profile.email) {
160
- this.setUserProfile({
161
- userId: CurrentUser.profile.userName,
162
- userName: CurrentUser.profile.nickName
163
- });
164
- }
165
- if (userProfile) {
166
- this.setUserProfile(userProfile);
151
+ value: function () {
152
+ var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
153
+ var _CurrentUser$profile;
154
+ var userProfile, menuNameMap, routes, getAuth, menuBuild, restConfig;
155
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
156
+ while (1) switch (_context2.prev = _context2.next) {
157
+ case 0:
158
+ userProfile = _ref.userProfile, menuNameMap = _ref.menuNameMap, routes = _ref.routes, getAuth = _ref.getAuth, menuBuild = _ref.menuBuild, restConfig = _objectWithoutProperties(_ref, _excluded);
159
+ this.checkConfig(restConfig);
160
+ this.config = restConfig;
161
+ if (!(routes && menuNameMap)) {
162
+ _context2.next = 6;
163
+ break;
164
+ }
165
+ _context2.next = 6;
166
+ return CurrentUser.init({
167
+ getAuth: getAuth,
168
+ menuBuild: menuBuild,
169
+ menuNameMap: menuNameMap,
170
+ routes: routes
171
+ });
172
+ case 6:
173
+ // 如果对接了权限中心,取权限中心的用户信息
174
+ if ((_CurrentUser$profile = CurrentUser.profile) !== null && _CurrentUser$profile !== void 0 && _CurrentUser$profile.email) {
175
+ this.setUserProfile({
176
+ userId: CurrentUser.profile.userName,
177
+ userName: CurrentUser.profile.nickName
178
+ });
179
+ }
180
+ if (userProfile) {
181
+ this.setUserProfile(userProfile);
182
+ }
183
+ this.mountAutoTask();
184
+ case 9:
185
+ case "end":
186
+ return _context2.stop();
187
+ }
188
+ }, _callee2, this);
189
+ }));
190
+ function init(_x) {
191
+ return _init.apply(this, arguments);
167
192
  }
168
- this.mountAutoTask();
169
- }
170
-
171
- // 推送埋点信息进入队列
193
+ return init;
194
+ }() // 推送埋点信息进入队列
172
195
  }, {
173
196
  key: "pushQueue",
174
197
  value: function pushQueue(_ref2) {
@@ -1,4 +1,5 @@
1
- export interface TrackConfig {
1
+ import { CurrentUserConfig } from './currentUser.interface';
2
+ export interface TrackConfig extends Partial<CurrentUserConfig> {
2
3
  appId: string;
3
4
  debug?: boolean;
4
5
  autoReportError?: boolean;
@@ -9,7 +9,7 @@ declare class Track {
9
9
  static getSystemProfile(): SystemProfile;
10
10
  static getUserProfile(): UserProfile;
11
11
  static setUserProfile(userProfile: UserProfile): void;
12
- static init({ userProfile, ...restConfig }: TrackConfig): void;
12
+ static init({ userProfile, menuNameMap, routes, getAuth, menuBuild, ...restConfig }: TrackConfig): Promise<void>;
13
13
  static pushQueue({ type, log, }: {
14
14
  type: TrackType;
15
15
  log: ErrorProfile | CustomizeProfile;
@@ -112,10 +112,25 @@ var Track = class {
112
112
  this.userProfile = userProfile;
113
113
  }
114
114
  // 挂载初始配置
115
- static init({ userProfile, ...restConfig }) {
115
+ static async init({
116
+ userProfile,
117
+ menuNameMap,
118
+ routes,
119
+ getAuth,
120
+ menuBuild,
121
+ ...restConfig
122
+ }) {
116
123
  var _a;
117
124
  this.checkConfig(restConfig);
118
125
  this.config = restConfig;
126
+ if (routes && menuNameMap) {
127
+ await import_CurrentUser.default.init({
128
+ getAuth,
129
+ menuBuild,
130
+ menuNameMap,
131
+ routes
132
+ });
133
+ }
119
134
  if ((_a = import_CurrentUser.default.profile) == null ? void 0 : _a.email) {
120
135
  this.setUserProfile({
121
136
  userId: import_CurrentUser.default.profile.userName,
@@ -1,4 +1,5 @@
1
- export interface TrackConfig {
1
+ import { CurrentUserConfig } from './currentUser.interface';
2
+ export interface TrackConfig extends Partial<CurrentUserConfig> {
2
3
  appId: string;
3
4
  debug?: boolean;
4
5
  autoReportError?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yysports/tools",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "常用工具函数库",
5
5
  "homepage": "https://git.pousheng.com/sport-service-department/pousheng-guard/yysports_tools#readme",
6
6
  "bugs": {