@yysports/tools 3.3.0 → 3.4.0
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 +1 -3
- package/dist/Track/Beacon.d.ts +0 -18
- package/dist/Track/Beacon.js +3 -31
- package/dist/Track/Config.d.ts +0 -15
- package/dist/Track/Config.js +1 -11
- package/dist/Track/Device.d.ts +0 -8
- package/dist/Track/Device.js +4 -38
- package/dist/Track/Listener.d.ts +0 -11
- package/dist/Track/Listener.js +1 -26
- package/dist/Track/Log.d.ts +0 -23
- package/dist/Track/Log.js +18 -60
- package/dist/Track/System.d.ts +0 -1
- package/dist/Track/System.js +2 -3
- package/dist/Track/User.js +1 -1
- package/dist/Track/envelope.d.ts +0 -18
- package/dist/Track/envelope.js +0 -26
- package/dist/Track/index.js +1 -17
- package/dist/Utils/auth.d.ts +0 -7
- package/dist/Utils/auth.js +6 -17
- package/dist/Utils/common.d.ts +0 -16
- package/dist/Utils/common.js +0 -20
- package/dist/Utils/file.d.ts +0 -10
- package/dist/Utils/file.js +0 -14
- package/dist/Utils/route.d.ts +0 -6
- package/dist/Utils/route.js +0 -19
- package/dist/interfaces/protocol.d.ts +0 -67
- package/dist/interfaces/protocol.js +1 -64
- package/dist/interfaces/track.interface.js +1 -9
- package/lib/Track/Beacon.d.ts +0 -18
- package/lib/Track/Beacon.js +36 -79
- package/lib/Track/Config.d.ts +0 -15
- package/lib/Track/Config.js +20 -51
- package/lib/Track/Device.d.ts +0 -8
- package/lib/Track/Device.js +26 -51
- package/lib/Track/Listener.d.ts +0 -11
- package/lib/Track/Listener.js +31 -73
- package/lib/Track/Log.d.ts +0 -23
- package/lib/Track/Log.js +50 -114
- package/lib/Track/System.d.ts +0 -1
- package/lib/Track/System.js +13 -31
- package/lib/Track/User.js +12 -30
- package/lib/Track/envelope.d.ts +0 -18
- package/lib/Track/envelope.js +38 -82
- package/lib/Track/index.js +31 -65
- package/lib/Utils/auth.d.ts +0 -7
- package/lib/Utils/auth.js +24 -53
- package/lib/Utils/common.d.ts +0 -16
- package/lib/Utils/common.js +15 -40
- package/lib/Utils/file.d.ts +0 -10
- package/lib/Utils/file.js +21 -42
- package/lib/Utils/index.js +69 -31
- package/lib/Utils/route.d.ts +0 -6
- package/lib/Utils/route.js +25 -43
- package/lib/Utils/url.js +8 -29
- package/lib/Utils/wx.js +18 -35
- package/lib/index.js +41 -43
- package/lib/interfaces/protocol.d.ts +0 -67
- package/lib/interfaces/protocol.js +14 -56
- package/lib/interfaces/track.interface.js +15 -28
- package/package.json +3 -6
- package/dist/Track/Replay.d.ts +0 -93
- package/dist/Track/Replay.js +0 -447
- package/lib/Track/Replay.d.ts +0 -93
- package/lib/Track/Replay.js +0 -330
package/lib/Utils/auth.js
CHANGED
|
@@ -1,71 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(auth_exports, {
|
|
22
|
-
fetchCurrentUserFromAuthCenter: () => fetchCurrentUserFromAuthCenter
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const [userInfo, menuBuild, zoneScope] = await Promise.all([
|
|
28
|
-
fetchUserInfo == null ? void 0 : fetchUserInfo(),
|
|
29
|
-
fetchMenuBuild == null ? void 0 : fetchMenuBuild(),
|
|
30
|
-
fetchZoneScope == null ? void 0 : fetchZoneScope()
|
|
31
|
-
]);
|
|
6
|
+
exports.fetchCurrentUserFromAuthCenter = void 0;
|
|
7
|
+
const fetchCurrentUserFromAuthCenter = async (fetchUserInfo, fetchMenuBuild, fetchZoneScope) => {
|
|
8
|
+
const [userInfo, menuBuild, zoneScope] = await Promise.all([fetchUserInfo?.(), fetchMenuBuild?.(), fetchZoneScope?.()]);
|
|
32
9
|
const currentUser = {};
|
|
33
10
|
if (userInfo) {
|
|
34
|
-
const {
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
const {
|
|
12
|
+
user = {},
|
|
13
|
+
roles = []
|
|
14
|
+
} = userInfo;
|
|
15
|
+
const {
|
|
16
|
+
roles: dataScopeRoles = []
|
|
17
|
+
} = user;
|
|
18
|
+
const isAdmin = roles.includes('admin');
|
|
37
19
|
Object.assign(currentUser, {
|
|
38
20
|
...user,
|
|
39
|
-
dataScopeRoles: dataScopeRoles.map(
|
|
40
|
-
// 用户拥有的数据权限角色
|
|
21
|
+
dataScopeRoles: dataScopeRoles.map(v => v.name),
|
|
41
22
|
roles,
|
|
42
|
-
// 用户拥有的页面、功能权限列表
|
|
43
23
|
isAdmin
|
|
44
|
-
// 是否为管理员
|
|
45
24
|
});
|
|
46
25
|
}
|
|
47
26
|
if (zoneScope) {
|
|
48
27
|
const dataScopeZonePermissions = [];
|
|
49
|
-
(
|
|
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
|
-
);
|
|
28
|
+
zoneScope?.list?.forEach(region => region?.list?.forEach(zone => dataScopeZonePermissions.push(zone.zoneId)));
|
|
57
29
|
Object.assign(currentUser, {
|
|
58
30
|
dataScopeZonePermissions
|
|
59
|
-
// 用户拥有的数据权限区域列表
|
|
60
31
|
});
|
|
61
32
|
}
|
|
62
33
|
if (Array.isArray(menuBuild)) {
|
|
63
34
|
const accessPage = [];
|
|
64
35
|
const authLogMap = {};
|
|
65
|
-
const traverseMenu =
|
|
66
|
-
menus.forEach(({
|
|
67
|
-
|
|
68
|
-
|
|
36
|
+
const traverseMenu = menus => {
|
|
37
|
+
menus.forEach(({
|
|
38
|
+
permission,
|
|
39
|
+
logAction,
|
|
40
|
+
children
|
|
41
|
+
}) => {
|
|
42
|
+
if (permission && (currentUser.isAdmin || currentUser.roles?.includes(permission))) {
|
|
69
43
|
accessPage.push(permission);
|
|
70
44
|
if (logAction) {
|
|
71
45
|
authLogMap[permission] = logAction;
|
|
@@ -84,7 +58,4 @@ var fetchCurrentUserFromAuthCenter = async (fetchUserInfo, fetchMenuBuild, fetch
|
|
|
84
58
|
}
|
|
85
59
|
return currentUser;
|
|
86
60
|
};
|
|
87
|
-
|
|
88
|
-
0 && (module.exports = {
|
|
89
|
-
fetchCurrentUserFromAuthCenter
|
|
90
|
-
});
|
|
61
|
+
exports.fetchCurrentUserFromAuthCenter = fetchCurrentUserFromAuthCenter;
|
package/lib/Utils/common.d.ts
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
export declare const promisify: (fn: (...params: any[]) => void, ...args: any[]) => Promise<unknown>;
|
|
2
|
-
/**
|
|
3
|
-
* 将数组内某个字段的值转换为对象组
|
|
4
|
-
* @param array
|
|
5
|
-
* @param key
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
2
|
export declare function arrayToObj(array: any[], key: string): any;
|
|
9
|
-
/**
|
|
10
|
-
* 检测当前浏览器内核版本是否大于等于指定的Chrome内核版本
|
|
11
|
-
* @param minVersion 指定的Chrome内核版本
|
|
12
|
-
* @returns 是否大于等于指定版本
|
|
13
|
-
*/
|
|
14
3
|
export declare function checkChromeVersion(minVersion: number): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* 生成随机字符串
|
|
17
|
-
* @param length 字符串长度
|
|
18
|
-
* @returns 随机字符串
|
|
19
|
-
*/
|
|
20
4
|
export declare function generateRandomString(length: number): string;
|
package/lib/Utils/common.js
CHANGED
|
@@ -1,32 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(common_exports, {
|
|
22
|
-
arrayToObj: () => arrayToObj,
|
|
23
|
-
checkChromeVersion: () => checkChromeVersion,
|
|
24
|
-
generateRandomString: () => generateRandomString,
|
|
25
|
-
promisify: () => promisify
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
26
5
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
6
|
+
exports.arrayToObj = arrayToObj;
|
|
7
|
+
exports.checkChromeVersion = checkChromeVersion;
|
|
8
|
+
exports.generateRandomString = generateRandomString;
|
|
9
|
+
exports.promisify = void 0;
|
|
10
|
+
const promisify = (fn, ...args) => {
|
|
11
|
+
return new Promise(resolve => {
|
|
30
12
|
if (args.length > 0) {
|
|
31
13
|
fn(...args, resolve);
|
|
32
14
|
} else {
|
|
@@ -34,6 +16,7 @@ var promisify = (fn, ...args) => {
|
|
|
34
16
|
}
|
|
35
17
|
});
|
|
36
18
|
};
|
|
19
|
+
exports.promisify = promisify;
|
|
37
20
|
function arrayToObj(array, key) {
|
|
38
21
|
return array.reduce((obj, item) => {
|
|
39
22
|
obj[item[key]] = item;
|
|
@@ -49,16 +32,8 @@ function checkChromeVersion(minVersion) {
|
|
|
49
32
|
return false;
|
|
50
33
|
}
|
|
51
34
|
function generateRandomString(length) {
|
|
52
|
-
const characters =
|
|
53
|
-
return Array.from(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
-
0 && (module.exports = {
|
|
60
|
-
arrayToObj,
|
|
61
|
-
checkChromeVersion,
|
|
62
|
-
generateRandomString,
|
|
63
|
-
promisify
|
|
64
|
-
});
|
|
35
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
36
|
+
return Array.from({
|
|
37
|
+
length
|
|
38
|
+
}, () => characters.charAt(Math.floor(Math.random() * characters.length))).join('');
|
|
39
|
+
}
|
package/lib/Utils/file.d.ts
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import type { compressAccuratelyConfig } from 'image-conversion';
|
|
2
2
|
export declare const downloadFile: (href: string, fileName?: string, target?: '_blank' | '_self' | '_parent' | '_top') => void;
|
|
3
3
|
export declare const compressImg: (file: Blob, config?: number | compressAccuratelyConfig | undefined) => Promise<Blob>;
|
|
4
|
-
/**
|
|
5
|
-
* 检查文件类型
|
|
6
|
-
* @param file File 文件对象
|
|
7
|
-
* @param accept string 文件类型,使用“,”分割,如:image/png,image/jpeg
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
4
|
export declare const checkFileType: (file: File, accept: string) => boolean;
|
|
11
|
-
/**
|
|
12
|
-
* 获取图片分辨率
|
|
13
|
-
* @param file File 图片文件对象
|
|
14
|
-
*/
|
|
15
5
|
export declare const getImageResolution: (file: File) => Promise<{
|
|
16
6
|
width: number;
|
|
17
7
|
height: number;
|
package/lib/Utils/file.js
CHANGED
|
@@ -1,67 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(file_exports, {
|
|
22
|
-
checkFileType: () => checkFileType,
|
|
23
|
-
compressImg: () => compressImg,
|
|
24
|
-
downloadFile: () => downloadFile,
|
|
25
|
-
getImageResolution: () => getImageResolution
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
26
5
|
});
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
const aEle = document.createElement(
|
|
6
|
+
exports.getImageResolution = exports.downloadFile = exports.compressImg = exports.checkFileType = void 0;
|
|
7
|
+
var _imageConversion = require("image-conversion");
|
|
8
|
+
const downloadFile = (href, fileName, target = '_blank') => {
|
|
9
|
+
const aEle = document.createElement('a');
|
|
31
10
|
aEle.target = target;
|
|
32
11
|
aEle.href = href;
|
|
33
|
-
aEle.download = fileName ||
|
|
12
|
+
aEle.download = fileName || '';
|
|
34
13
|
aEle.click();
|
|
35
14
|
aEle.remove();
|
|
36
15
|
};
|
|
37
|
-
|
|
38
|
-
|
|
16
|
+
exports.downloadFile = downloadFile;
|
|
17
|
+
const compressImg = (file, config) => (0, _imageConversion.compressAccurately)(file, config);
|
|
18
|
+
exports.compressImg = compressImg;
|
|
19
|
+
const checkFileType = (file, accept) => {
|
|
39
20
|
if (accept) {
|
|
40
|
-
const acceptList = accept.split(
|
|
21
|
+
const acceptList = accept.split(',').map(item => item.trim().toLowerCase());
|
|
41
22
|
const fileType = file.type.toLowerCase();
|
|
42
23
|
return acceptList.includes(fileType);
|
|
43
24
|
}
|
|
44
25
|
return true;
|
|
45
26
|
};
|
|
46
|
-
|
|
27
|
+
exports.checkFileType = checkFileType;
|
|
28
|
+
const getImageResolution = file => {
|
|
47
29
|
return new Promise((resolve, reject) => {
|
|
48
30
|
const img = new Image();
|
|
49
31
|
const url = URL.createObjectURL(file);
|
|
50
32
|
img.onload = () => {
|
|
51
33
|
URL.revokeObjectURL(url);
|
|
52
|
-
resolve({
|
|
34
|
+
resolve({
|
|
35
|
+
width: img.width,
|
|
36
|
+
height: img.height
|
|
37
|
+
});
|
|
53
38
|
};
|
|
54
39
|
img.onerror = () => {
|
|
55
40
|
URL.revokeObjectURL(url);
|
|
56
|
-
reject(new Error(
|
|
41
|
+
reject(new Error('getImageResolution: 图片加载失败'));
|
|
57
42
|
};
|
|
58
43
|
img.src = url;
|
|
59
44
|
});
|
|
60
45
|
};
|
|
61
|
-
|
|
62
|
-
0 && (module.exports = {
|
|
63
|
-
checkFileType,
|
|
64
|
-
compressImg,
|
|
65
|
-
downloadFile,
|
|
66
|
-
getImageResolution
|
|
67
|
-
});
|
|
46
|
+
exports.getImageResolution = getImageResolution;
|
package/lib/Utils/index.js
CHANGED
|
@@ -1,33 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
15
2
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
module.exports = __toCommonJS(Utils_exports);
|
|
19
|
-
__reExport(Utils_exports, require("./auth"), module.exports);
|
|
20
|
-
__reExport(Utils_exports, require("./common"), module.exports);
|
|
21
|
-
__reExport(Utils_exports, require("./file"), module.exports);
|
|
22
|
-
__reExport(Utils_exports, require("./route"), module.exports);
|
|
23
|
-
__reExport(Utils_exports, require("./url"), module.exports);
|
|
24
|
-
__reExport(Utils_exports, require("./wx"), module.exports);
|
|
25
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
-
0 && (module.exports = {
|
|
27
|
-
...require("./auth"),
|
|
28
|
-
...require("./common"),
|
|
29
|
-
...require("./file"),
|
|
30
|
-
...require("./route"),
|
|
31
|
-
...require("./url"),
|
|
32
|
-
...require("./wx")
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
33
5
|
});
|
|
6
|
+
var _auth = require("./auth");
|
|
7
|
+
Object.keys(_auth).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _auth[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _auth[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _common = require("./common");
|
|
18
|
+
Object.keys(_common).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _common[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _common[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _file = require("./file");
|
|
29
|
+
Object.keys(_file).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _file[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _file[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _route = require("./route");
|
|
40
|
+
Object.keys(_route).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _route[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _route[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _url = require("./url");
|
|
51
|
+
Object.keys(_url).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _url[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _url[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _wx = require("./wx");
|
|
62
|
+
Object.keys(_wx).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _wx[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _wx[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
package/lib/Utils/route.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 适用于 Umi 框架的路由模块名称获取
|
|
3
|
-
* @param onRouteChangeArgs onRouteChange的参数
|
|
4
|
-
* @param menuNameMap 国际化菜单名称映射表
|
|
5
|
-
* @returns {undefined | string} 模块名称,格式如 "菜单1-子菜单A-子菜单a1",如果无法获取则返回 undefined
|
|
6
|
-
*/
|
|
7
1
|
export declare const getModuleNameByUmi: (onRouteChangeArgs: {
|
|
8
2
|
location: any;
|
|
9
3
|
routes: any;
|
package/lib/Utils/route.js
CHANGED
|
@@ -1,46 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(route_exports, {
|
|
22
|
-
getModuleNameByUmi: () => getModuleNameByUmi
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
6
|
+
exports.getModuleNameByUmi = void 0;
|
|
7
|
+
const getModuleNameByUmi = (onRouteChangeArgs, menuNameMap) => {
|
|
8
|
+
const {
|
|
9
|
+
location,
|
|
10
|
+
routes,
|
|
11
|
+
basename
|
|
12
|
+
} = onRouteChangeArgs;
|
|
13
|
+
const {
|
|
14
|
+
pathname
|
|
15
|
+
} = location;
|
|
16
|
+
const basePath = basename.replace(/\/+$/, '');
|
|
17
|
+
const isUnderBase = basePath !== '' && basePath !== '/' && (pathname === basePath || pathname.startsWith(`${basePath}/`));
|
|
18
|
+
const routePath = isUnderBase ? pathname.slice(basePath.length) || '/' : pathname;
|
|
19
|
+
const currentRouteKey = Object.keys(routes).find(v => routes[v].path === routePath);
|
|
34
20
|
if (!currentRouteKey || routes[currentRouteKey].redirect) {
|
|
35
21
|
return;
|
|
36
22
|
}
|
|
37
|
-
const menuHierarchyKeys = [
|
|
38
|
-
const buildMenuHierarchy =
|
|
23
|
+
const menuHierarchyKeys = ['menu'];
|
|
24
|
+
const buildMenuHierarchy = routeId => {
|
|
39
25
|
const route = routes[routeId];
|
|
40
|
-
if (route
|
|
26
|
+
if (route?.name) {
|
|
41
27
|
menuHierarchyKeys.splice(1, 0, route.name);
|
|
42
28
|
}
|
|
43
|
-
if (route
|
|
29
|
+
if (route?.parentId) {
|
|
44
30
|
buildMenuHierarchy(route.parentId);
|
|
45
31
|
}
|
|
46
32
|
};
|
|
@@ -51,15 +37,11 @@ var getModuleNameByUmi = (onRouteChangeArgs, menuNameMap) => {
|
|
|
51
37
|
const nameMap = menuNameMap ?? {};
|
|
52
38
|
const menuDisplayNames = [];
|
|
53
39
|
for (let i = 1; i < menuHierarchyKeys.length; i++) {
|
|
54
|
-
const menuKey = menuHierarchyKeys.slice(0, i + 1).join(
|
|
40
|
+
const menuKey = menuHierarchyKeys.slice(0, i + 1).join('.');
|
|
55
41
|
const displayName = nameMap[menuKey];
|
|
56
|
-
if (!displayName)
|
|
57
|
-
return;
|
|
42
|
+
if (!displayName) return;
|
|
58
43
|
menuDisplayNames.push(displayName);
|
|
59
44
|
}
|
|
60
|
-
return menuDisplayNames.join(
|
|
45
|
+
return menuDisplayNames.join('-');
|
|
61
46
|
};
|
|
62
|
-
|
|
63
|
-
0 && (module.exports = {
|
|
64
|
-
getModuleNameByUmi
|
|
65
|
-
});
|
|
47
|
+
exports.getModuleNameByUmi = getModuleNameByUmi;
|
package/lib/Utils/url.js
CHANGED
|
@@ -1,31 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(url_exports, {
|
|
22
|
-
getUrlParams: () => getUrlParams
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
exports.getUrlParams = void 0;
|
|
7
|
+
const getUrlParams = str => {
|
|
26
8
|
let paramsStr = location.search;
|
|
27
|
-
if (typeof str ===
|
|
28
|
-
if (str.startsWith(
|
|
9
|
+
if (typeof str === 'string') {
|
|
10
|
+
if (str.startsWith('http')) {
|
|
29
11
|
const url = new URL(str);
|
|
30
12
|
paramsStr = url.search;
|
|
31
13
|
} else {
|
|
@@ -39,7 +21,4 @@ var getUrlParams = (str) => {
|
|
|
39
21
|
});
|
|
40
22
|
return params;
|
|
41
23
|
};
|
|
42
|
-
|
|
43
|
-
0 && (module.exports = {
|
|
44
|
-
getUrlParams
|
|
45
|
-
});
|
|
24
|
+
exports.getUrlParams = getUrlParams;
|
package/lib/Utils/wx.js
CHANGED
|
@@ -1,37 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(wx_exports, {
|
|
22
|
-
isWechat: () => isWechat,
|
|
23
|
-
wxSDK: () => wxSDK
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
24
5
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
exports.wxSDK = exports.isWechat = void 0;
|
|
7
|
+
const isWechat = exports.isWechat = navigator.userAgent.toLowerCase().includes('micromessenger');
|
|
8
|
+
const wxSDK = option => {
|
|
28
9
|
return new Promise((resolve, reject) => {
|
|
29
|
-
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
10
|
+
const {
|
|
11
|
+
...configOption
|
|
12
|
+
} = option;
|
|
13
|
+
wx.config({
|
|
14
|
+
...configOption
|
|
33
15
|
});
|
|
34
|
-
wx.
|
|
16
|
+
wx.ready(function () {
|
|
17
|
+
resolve({
|
|
18
|
+
success: true
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
wx.error(function (res) {
|
|
35
22
|
reject({
|
|
36
23
|
success: false,
|
|
37
24
|
message: res
|
|
@@ -39,8 +26,4 @@ var wxSDK = (option) => {
|
|
|
39
26
|
});
|
|
40
27
|
});
|
|
41
28
|
};
|
|
42
|
-
|
|
43
|
-
0 && (module.exports = {
|
|
44
|
-
isWechat,
|
|
45
|
-
wxSDK
|
|
46
|
-
});
|
|
29
|
+
exports.wxSDK = wxSDK;
|