@yysports/tools 0.1.3 → 0.1.5

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.
@@ -1,5 +1,4 @@
1
- import { RouteMapValueType } from '../Utils';
2
- import { AuthCenterUserProfile, CustomizeProfile, ErrorProfile, SystemProfile, TrackConfig, TrackType, UserProfile } from '../interfaces/track.interface';
1
+ import { AuthCenterUserProfile, CustomizeProfile, ErrorProfile, RouteMapValueType, SystemProfile, TrackConfig, TrackType, UserProfile } from '../interfaces/track.interface';
3
2
  declare class Track {
4
3
  static config: TrackConfig;
5
4
  static userProfile: UserProfile;
@@ -267,6 +267,9 @@ var Track = /*#__PURE__*/function () {
267
267
  key: "getPageModuleName",
268
268
  value: function getPageModuleName() {
269
269
  var routeInfo = this.routesMap.get(this.getFormatBasePath());
270
+ if (routeInfo !== null && routeInfo !== void 0 && routeInfo.redirect) {
271
+ throw new Error('重定向路径不记录埋点');
272
+ }
270
273
  return (routeInfo === null || routeInfo === void 0 ? void 0 : routeInfo.module) || [];
271
274
  }
272
275
 
@@ -312,21 +315,23 @@ var Track = /*#__PURE__*/function () {
312
315
  }, {
313
316
  key: "visitLog",
314
317
  value: function visitLog(_visitLog) {
315
- if (_visitLog === undefined) {
316
- _visitLog = {
317
- module: '',
318
- content: ''
319
- };
320
- var routeNames = this.getPageModuleName();
321
- Object.assign(_visitLog, {
322
- module: routeNames.join('-'),
323
- content: "\u8BBF\u95EE\u9875\u9762: ".concat(_toConsumableArray(routeNames).pop())
318
+ try {
319
+ if (_visitLog === undefined) {
320
+ _visitLog = {
321
+ module: '',
322
+ content: ''
323
+ };
324
+ var routeNames = this.getPageModuleName();
325
+ Object.assign(_visitLog, {
326
+ module: routeNames.join('-'),
327
+ content: "\u8BBF\u95EE\u9875\u9762: ".concat(_toConsumableArray(routeNames).pop())
328
+ });
329
+ }
330
+ this.pushQueue({
331
+ log: _visitLog,
332
+ type: 'visit'
324
333
  });
325
- }
326
- this.pushQueue({
327
- log: _visitLog,
328
- type: 'visit'
329
- });
334
+ } catch (e) {}
330
335
  }
331
336
 
332
337
  // 推送接口访问日志
@@ -1,10 +1,2 @@
1
- export type AuthDataType = {
2
- children: AuthDataType[];
3
- name?: string;
4
- logAction?: string;
5
- permission?: string;
6
- meta?: {
7
- title: string;
8
- };
9
- };
1
+ import { AuthDataType } from '../interfaces/track.interface';
10
2
  export declare const getAuthMapByAuthCenter: (authData: AuthDataType[]) => Map<string, string>;
@@ -1,15 +1,4 @@
1
- export type RouteType = {
2
- path: string;
3
- redirect?: string;
4
- name?: string;
5
- access?: string;
6
- routes?: RouteType[];
7
- };
8
- export type RouteMapValueType = {
9
- access?: string;
10
- name?: string[];
11
- module?: string[];
12
- };
1
+ import { RouteMapValueType, RouteType } from '../interfaces/track.interface';
13
2
  export declare const getRoutesMap: (routes: RouteType[], menuNameMap?: {
14
3
  [key: string]: string;
15
4
  } | undefined) => Map<string, RouteMapValueType>;
@@ -5,7 +5,6 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
5
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
6
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
7
  // 根据本地路由配置文件、路由地址名称映射、当前用户权限,生成路由映射关系表
8
-
9
8
  export var getRoutesMap = function getRoutesMap(routes, menuNameMap) {
10
9
  var routesMap = new Map();
11
10
  var ergodicLocalMenu = function ergodicLocalMenu(rs, parentMenu) {
@@ -27,7 +26,8 @@ export var getRoutesMap = function getRoutesMap(routes, menuNameMap) {
27
26
  var routeInfo = {
28
27
  access: access,
29
28
  name: nameArr,
30
- module: moduleArr
29
+ module: moduleArr,
30
+ redirect: !!redirect
31
31
  };
32
32
  if (path) {
33
33
  routesMap.set(path, routeInfo);
@@ -1,4 +1,3 @@
1
- import { RouteType } from '../Utils';
2
1
  export type LocalRouteItemType = {
3
2
  access?: string;
4
3
  name?: string;
@@ -72,3 +71,26 @@ export interface ErrorProfile {
72
71
  fileName: string;
73
72
  message: string;
74
73
  }
74
+ export type RouteType = {
75
+ path?: string;
76
+ redirect?: string;
77
+ name?: string;
78
+ access?: string;
79
+ routes?: RouteType[];
80
+ [key: string]: any;
81
+ };
82
+ export type RouteMapValueType = {
83
+ access?: string;
84
+ name?: string[];
85
+ module?: string[];
86
+ redirect?: boolean;
87
+ };
88
+ export type AuthDataType = {
89
+ children: AuthDataType[];
90
+ name?: string;
91
+ logAction?: string;
92
+ permission?: string;
93
+ meta?: {
94
+ title: string;
95
+ };
96
+ };
@@ -1,5 +1,4 @@
1
- import { RouteMapValueType } from '../Utils';
2
- import { AuthCenterUserProfile, CustomizeProfile, ErrorProfile, SystemProfile, TrackConfig, TrackType, UserProfile } from '../interfaces/track.interface';
1
+ import { AuthCenterUserProfile, CustomizeProfile, ErrorProfile, RouteMapValueType, SystemProfile, TrackConfig, TrackType, UserProfile } from '../interfaces/track.interface';
3
2
  declare class Track {
4
3
  static config: TrackConfig;
5
4
  static userProfile: UserProfile;
@@ -205,6 +205,9 @@ var Track = class {
205
205
  // 获取模块名称
206
206
  static getPageModuleName() {
207
207
  const routeInfo = this.routesMap.get(this.getFormatBasePath());
208
+ if (routeInfo == null ? void 0 : routeInfo.redirect) {
209
+ throw new Error("重定向路径不记录埋点");
210
+ }
208
211
  return (routeInfo == null ? void 0 : routeInfo.module) || [];
209
212
  }
210
213
  // 推送错误日志
@@ -241,18 +244,21 @@ var Track = class {
241
244
  }
242
245
  // 推送页面访问日志
243
246
  static visitLog(visitLog) {
244
- if (visitLog === void 0) {
245
- visitLog = { module: "", content: "" };
246
- const routeNames = this.getPageModuleName();
247
- Object.assign(visitLog, {
248
- module: routeNames.join("-"),
249
- content: `访问页面: ${[...routeNames].pop()}`
247
+ try {
248
+ if (visitLog === void 0) {
249
+ visitLog = { module: "", content: "" };
250
+ const routeNames = this.getPageModuleName();
251
+ Object.assign(visitLog, {
252
+ module: routeNames.join("-"),
253
+ content: `访问页面: ${[...routeNames].pop()}`
254
+ });
255
+ }
256
+ this.pushQueue({
257
+ log: visitLog,
258
+ type: "visit"
250
259
  });
260
+ } catch (e) {
251
261
  }
252
- this.pushQueue({
253
- log: visitLog,
254
- type: "visit"
255
- });
256
262
  }
257
263
  // 推送接口访问日志
258
264
  static apiLog(apiLog) {
@@ -1,10 +1,2 @@
1
- export type AuthDataType = {
2
- children: AuthDataType[];
3
- name?: string;
4
- logAction?: string;
5
- permission?: string;
6
- meta?: {
7
- title: string;
8
- };
9
- };
1
+ import { AuthDataType } from '../interfaces/track.interface';
10
2
  export declare const getAuthMapByAuthCenter: (authData: AuthDataType[]) => Map<string, string>;
@@ -1,15 +1,4 @@
1
- export type RouteType = {
2
- path: string;
3
- redirect?: string;
4
- name?: string;
5
- access?: string;
6
- routes?: RouteType[];
7
- };
8
- export type RouteMapValueType = {
9
- access?: string;
10
- name?: string[];
11
- module?: string[];
12
- };
1
+ import { RouteMapValueType, RouteType } from '../interfaces/track.interface';
13
2
  export declare const getRoutesMap: (routes: RouteType[], menuNameMap?: {
14
3
  [key: string]: string;
15
4
  } | undefined) => Map<string, RouteMapValueType>;
@@ -39,7 +39,8 @@ var getRoutesMap = (routes, menuNameMap) => {
39
39
  const routeInfo = {
40
40
  access,
41
41
  name: nameArr,
42
- module: moduleArr
42
+ module: moduleArr,
43
+ redirect: !!redirect
43
44
  };
44
45
  if (path) {
45
46
  routesMap.set(path, routeInfo);
@@ -1,4 +1,3 @@
1
- import { RouteType } from '../Utils';
2
1
  export type LocalRouteItemType = {
3
2
  access?: string;
4
3
  name?: string;
@@ -72,3 +71,26 @@ export interface ErrorProfile {
72
71
  fileName: string;
73
72
  message: string;
74
73
  }
74
+ export type RouteType = {
75
+ path?: string;
76
+ redirect?: string;
77
+ name?: string;
78
+ access?: string;
79
+ routes?: RouteType[];
80
+ [key: string]: any;
81
+ };
82
+ export type RouteMapValueType = {
83
+ access?: string;
84
+ name?: string[];
85
+ module?: string[];
86
+ redirect?: boolean;
87
+ };
88
+ export type AuthDataType = {
89
+ children: AuthDataType[];
90
+ name?: string;
91
+ logAction?: string;
92
+ permission?: string;
93
+ meta?: {
94
+ title: string;
95
+ };
96
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yysports/tools",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "常用工具函数库",
5
5
  "homepage": "https://git.pousheng.com/sport-service-department/pousheng-guard/yysports_tools#readme",
6
6
  "bugs": {