@haluo/util 2.0.29 → 2.0.30
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 +350 -350
- package/dist/index.d.ts +39 -39
- package/dist/index.js +43 -43
- package/dist/modules/cookie/index.d.ts +27 -27
- package/dist/modules/cookie/index.js +49 -49
- package/dist/modules/date/index.d.ts +52 -52
- package/dist/modules/date/index.js +185 -185
- package/dist/modules/dom/index.d.ts +28 -28
- package/dist/modules/dom/index.js +55 -55
- package/dist/modules/filter/index.d.ts +24 -24
- package/dist/modules/filter/index.js +38 -38
- package/dist/modules/format/index.d.ts +15 -15
- package/dist/modules/format/index.js +16 -16
- package/dist/modules/match/index.d.ts +12 -12
- package/dist/modules/match/index.js +27 -27
- package/dist/modules/monitor/index.d.ts +3 -3
- package/dist/modules/monitor/index.js +10 -10
- package/dist/modules/monitor/lib/jsError.d.ts +1 -1
- package/dist/modules/monitor/lib/jsError.js +57 -57
- package/dist/modules/monitor/lib/timing.d.ts +1 -1
- package/dist/modules/monitor/lib/timing.js +65 -65
- package/dist/modules/monitor/lib/xhr.d.ts +1 -1
- package/dist/modules/monitor/lib/xhr.js +41 -41
- package/dist/modules/monitor/utils/onload.d.ts +1 -1
- package/dist/modules/monitor/utils/onload.js +8 -8
- package/dist/modules/monitor/utils/tracker.d.ts +7 -7
- package/dist/modules/monitor/utils/tracker.js +49 -49
- package/dist/modules/number/index.d.ts +47 -47
- package/dist/modules/number/index.js +114 -114
- package/dist/modules/open-app/index.d.ts +84 -84
- package/dist/modules/open-app/index.js +244 -244
- package/dist/modules/sentry/index.d.ts +15 -15
- package/dist/modules/sentry/index.js +73 -73
- package/dist/modules/tools/index.d.ts +166 -166
- package/dist/modules/tools/index.js +382 -382
- package/dist/modules/upload/aliOss.d.ts +291 -291
- package/dist/modules/upload/aliOss.js +629 -629
- package/dist/modules/upload/index.d.ts +38 -38
- package/dist/modules/upload/index.js +44 -44
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +1 -1
- package/package.json +88 -88
- package/dist/types/modules/cookie/index.d.ts +0 -27
- package/dist/types/modules/date/index.d.ts +0 -52
- package/dist/types/modules/dom/index.d.ts +0 -28
- package/dist/types/modules/filter/index.d.ts +0 -24
- package/dist/types/modules/format/index.d.ts +0 -15
- package/dist/types/modules/match/index.d.ts +0 -12
- package/dist/types/modules/monitor/index.d.ts +0 -3
- package/dist/types/modules/monitor/lib/jsError.d.ts +0 -1
- package/dist/types/modules/monitor/lib/timing.d.ts +0 -1
- package/dist/types/modules/monitor/lib/xhr.d.ts +0 -1
- package/dist/types/modules/monitor/utils/onload.d.ts +0 -1
- package/dist/types/modules/monitor/utils/tracker.d.ts +0 -7
- package/dist/types/modules/number/index.d.ts +0 -41
- package/dist/types/modules/sentry/index.d.ts +0 -15
- package/dist/types/modules/tools/index.d.ts +0 -166
- package/dist/types/types/index.d.ts +0 -3
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
// import Parser from 'ua-parser-js';
|
|
3
|
-
class SendTracker {
|
|
4
|
-
url;
|
|
5
|
-
constructor() {
|
|
6
|
-
this.url = '';
|
|
7
|
-
}
|
|
8
|
-
send(data = {}) {
|
|
9
|
-
const host = window.location.host;
|
|
10
|
-
if (host.indexOf('localhost') > -1)
|
|
11
|
-
return;
|
|
12
|
-
const reg = /((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/g;
|
|
13
|
-
if (reg.test(host))
|
|
14
|
-
return;
|
|
15
|
-
const log = { ...getExtraData(), ...data };
|
|
16
|
-
let formBody = [];
|
|
17
|
-
for (var property in log) {
|
|
18
|
-
var encodedKey = encodeURIComponent(property);
|
|
19
|
-
var encodedValue = encodeURIComponent(log[property]);
|
|
20
|
-
formBody.push(encodedKey + "=" + encodedValue);
|
|
21
|
-
}
|
|
22
|
-
formBody = formBody.join("&");
|
|
23
|
-
// fetch('https://apm-collect.58moto.com/app/collect/original/info/report/v2', {
|
|
24
|
-
// method: 'POST',
|
|
25
|
-
// headers: {
|
|
26
|
-
// "Content-Type":"application/x-www-form-urlencoded"
|
|
27
|
-
// },
|
|
28
|
-
// body: formBody,
|
|
29
|
-
// }).then(res => {
|
|
30
|
-
// // console.log(res)
|
|
31
|
-
// }).catch((e) => {
|
|
32
|
-
// console.log(e)
|
|
33
|
-
// })
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function getExtraData() {
|
|
37
|
-
return {
|
|
38
|
-
deviceId: uuidv4(),
|
|
39
|
-
platform: 3,
|
|
40
|
-
errorType: 3,
|
|
41
|
-
channel: 'h5',
|
|
42
|
-
bundle: 'com.jdd.motorfans',
|
|
43
|
-
title: '',
|
|
44
|
-
frontStatus: 3,
|
|
45
|
-
occurTimeStamp: Date.now(),
|
|
46
|
-
// userAgent: new Parser().getResult()
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export default new SendTracker();
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
// import Parser from 'ua-parser-js';
|
|
3
|
+
class SendTracker {
|
|
4
|
+
url;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.url = '';
|
|
7
|
+
}
|
|
8
|
+
send(data = {}) {
|
|
9
|
+
const host = window.location.host;
|
|
10
|
+
if (host.indexOf('localhost') > -1)
|
|
11
|
+
return;
|
|
12
|
+
const reg = /((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/g;
|
|
13
|
+
if (reg.test(host))
|
|
14
|
+
return;
|
|
15
|
+
const log = { ...getExtraData(), ...data };
|
|
16
|
+
let formBody = [];
|
|
17
|
+
for (var property in log) {
|
|
18
|
+
var encodedKey = encodeURIComponent(property);
|
|
19
|
+
var encodedValue = encodeURIComponent(log[property]);
|
|
20
|
+
formBody.push(encodedKey + "=" + encodedValue);
|
|
21
|
+
}
|
|
22
|
+
formBody = formBody.join("&");
|
|
23
|
+
// fetch('https://apm-collect.58moto.com/app/collect/original/info/report/v2', {
|
|
24
|
+
// method: 'POST',
|
|
25
|
+
// headers: {
|
|
26
|
+
// "Content-Type":"application/x-www-form-urlencoded"
|
|
27
|
+
// },
|
|
28
|
+
// body: formBody,
|
|
29
|
+
// }).then(res => {
|
|
30
|
+
// // console.log(res)
|
|
31
|
+
// }).catch((e) => {
|
|
32
|
+
// console.log(e)
|
|
33
|
+
// })
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function getExtraData() {
|
|
37
|
+
return {
|
|
38
|
+
deviceId: uuidv4(),
|
|
39
|
+
platform: 3,
|
|
40
|
+
errorType: 3,
|
|
41
|
+
channel: 'h5',
|
|
42
|
+
bundle: 'com.jdd.motorfans',
|
|
43
|
+
title: '',
|
|
44
|
+
frontStatus: 3,
|
|
45
|
+
occurTimeStamp: Date.now(),
|
|
46
|
+
// userAgent: new Parser().getResult()
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export default new SendTracker();
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
declare class NumberClass {
|
|
2
|
-
/**
|
|
3
|
-
* 个位数前面补0
|
|
4
|
-
* @param {Number} num 需要格式化的数字
|
|
5
|
-
* @return {String} '01'
|
|
6
|
-
*/
|
|
7
|
-
formatNumber(num: number): string;
|
|
8
|
-
/**
|
|
9
|
-
* 将手机号中间部分替换为星号
|
|
10
|
-
* @param {String} phone 手机号码
|
|
11
|
-
* @return {String} 131****1111
|
|
12
|
-
*/
|
|
13
|
-
formatPhone(phone: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* 格式化数字 万
|
|
16
|
-
* @param {Number} num
|
|
17
|
-
* @return {String} 12.3万
|
|
18
|
-
*/
|
|
19
|
-
convertToWan(num: number): string | number;
|
|
20
|
-
/**
|
|
21
|
-
* 格式化数字 k
|
|
22
|
-
* @param {Number} num
|
|
23
|
-
* @return {String} 1.2k
|
|
24
|
-
*/
|
|
25
|
-
convertToThousand(num: number): string | number;
|
|
26
|
-
/**
|
|
27
|
-
* 随机数,指定范围
|
|
28
|
-
* @param {Number} min 开始
|
|
29
|
-
* @param {Number} max 结束
|
|
30
|
-
* @return {Number|Object}
|
|
31
|
-
*/
|
|
32
|
-
random(min: number, max: number): number | null;
|
|
33
|
-
/**
|
|
34
|
-
* 格式化金额
|
|
35
|
-
* @param {Number} num
|
|
36
|
-
* @return {String} 123,456
|
|
37
|
-
*/
|
|
38
|
-
formatMoney(money: number | string, signal?: string): string;
|
|
39
|
-
/**
|
|
40
|
-
* 格式化手机号
|
|
41
|
-
* @param {string} number 手机号
|
|
42
|
-
* @returns {string} 格式化后的手机号 12345678901 -> 123 4567 8901
|
|
43
|
-
*/
|
|
44
|
-
formatPhoneNumber(number: string | number): string;
|
|
45
|
-
}
|
|
46
|
-
declare const _default: NumberClass;
|
|
47
|
-
export default _default;
|
|
1
|
+
declare class NumberClass {
|
|
2
|
+
/**
|
|
3
|
+
* 个位数前面补0
|
|
4
|
+
* @param {Number} num 需要格式化的数字
|
|
5
|
+
* @return {String} '01'
|
|
6
|
+
*/
|
|
7
|
+
formatNumber(num: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* 将手机号中间部分替换为星号
|
|
10
|
+
* @param {String} phone 手机号码
|
|
11
|
+
* @return {String} 131****1111
|
|
12
|
+
*/
|
|
13
|
+
formatPhone(phone: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* 格式化数字 万
|
|
16
|
+
* @param {Number} num
|
|
17
|
+
* @return {String} 12.3万
|
|
18
|
+
*/
|
|
19
|
+
convertToWan(num: number): string | number;
|
|
20
|
+
/**
|
|
21
|
+
* 格式化数字 k
|
|
22
|
+
* @param {Number} num
|
|
23
|
+
* @return {String} 1.2k
|
|
24
|
+
*/
|
|
25
|
+
convertToThousand(num: number): string | number;
|
|
26
|
+
/**
|
|
27
|
+
* 随机数,指定范围
|
|
28
|
+
* @param {Number} min 开始
|
|
29
|
+
* @param {Number} max 结束
|
|
30
|
+
* @return {Number|Object}
|
|
31
|
+
*/
|
|
32
|
+
random(min: number, max: number): number | null;
|
|
33
|
+
/**
|
|
34
|
+
* 格式化金额
|
|
35
|
+
* @param {Number} num
|
|
36
|
+
* @return {String} 123,456
|
|
37
|
+
*/
|
|
38
|
+
formatMoney(money: number | string, signal?: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* 格式化手机号
|
|
41
|
+
* @param {string} number 手机号
|
|
42
|
+
* @returns {string} 格式化后的手机号 12345678901 -> 123 4567 8901
|
|
43
|
+
*/
|
|
44
|
+
formatPhoneNumber(number: string | number): string;
|
|
45
|
+
}
|
|
46
|
+
declare const _default: NumberClass;
|
|
47
|
+
export default _default;
|
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file number 格式化
|
|
3
|
-
* @Author: wanghui
|
|
4
|
-
* @createBy: @2020.05.26
|
|
5
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
class NumberClass {
|
|
8
|
-
/**
|
|
9
|
-
* 个位数前面补0
|
|
10
|
-
* @param {Number} num 需要格式化的数字
|
|
11
|
-
* @return {String} '01'
|
|
12
|
-
*/
|
|
13
|
-
formatNumber(num) {
|
|
14
|
-
const res = num.toString();
|
|
15
|
-
return res[1] ? res : '0' + res;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 将手机号中间部分替换为星号
|
|
19
|
-
* @param {String} phone 手机号码
|
|
20
|
-
* @return {String} 131****1111
|
|
21
|
-
*/
|
|
22
|
-
formatPhone(phone) {
|
|
23
|
-
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 格式化数字 万
|
|
27
|
-
* @param {Number} num
|
|
28
|
-
* @return {String} 12.3万
|
|
29
|
-
*/
|
|
30
|
-
convertToWan(num) {
|
|
31
|
-
let result = '';
|
|
32
|
-
if (num < 10000) {
|
|
33
|
-
result = num;
|
|
34
|
-
}
|
|
35
|
-
if (num >= 10000) {
|
|
36
|
-
result = (num / 10000).toFixed(1) + '万';
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* 格式化数字 k
|
|
42
|
-
* @param {Number} num
|
|
43
|
-
* @return {String} 1.2k
|
|
44
|
-
*/
|
|
45
|
-
convertToThousand(num) {
|
|
46
|
-
let result = '';
|
|
47
|
-
if (num < 1000) {
|
|
48
|
-
result = num;
|
|
49
|
-
}
|
|
50
|
-
if (num >= 1000) {
|
|
51
|
-
result = (num / 1000).toFixed(1) + 'k';
|
|
52
|
-
}
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* 随机数,指定范围
|
|
57
|
-
* @param {Number} min 开始
|
|
58
|
-
* @param {Number} max 结束
|
|
59
|
-
* @return {Number|Object}
|
|
60
|
-
*/
|
|
61
|
-
random(min, max) {
|
|
62
|
-
if (arguments.length === 2) {
|
|
63
|
-
return Math.floor(min + Math.random() * ((max + 1) - min));
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* 格式化金额
|
|
71
|
-
* @param {Number} num
|
|
72
|
-
* @return {String} 123,456
|
|
73
|
-
*/
|
|
74
|
-
formatMoney(money, signal) {
|
|
75
|
-
let result = '';
|
|
76
|
-
if (money === '') {
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
money = String(money).replace('.00', '');
|
|
80
|
-
money = money.substring(money.length - 2) === '.0' ? money.replace('.0', '') : money;
|
|
81
|
-
// 小于3位数,直接返回
|
|
82
|
-
if (Number(money) < 1000) {
|
|
83
|
-
return result = money;
|
|
84
|
-
}
|
|
85
|
-
if (money.split('.')[0].length < 3) {
|
|
86
|
-
return result = money;
|
|
87
|
-
}
|
|
88
|
-
signal = signal === '' ? '' : ',';
|
|
89
|
-
let price = money.split('.')[0] + '';
|
|
90
|
-
const pricePoint = money.split('.')[1];
|
|
91
|
-
result = price.length > 6 ?
|
|
92
|
-
`${price.substring(0, price.length - 6)}${signal}${price.substring(price.length - 6, price.length - 3)},${price.substring(price.length - 3, price.length)}`
|
|
93
|
-
:
|
|
94
|
-
`${price.substring(0, price.length - 3)}${signal}${price.substring(price.length - 3, price.length)}`;
|
|
95
|
-
result = pricePoint ? `${result}${signal}${pricePoint}` : result;
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* 格式化手机号
|
|
100
|
-
* @param {string} number 手机号
|
|
101
|
-
* @returns {string} 格式化后的手机号 12345678901 -> 123 4567 8901
|
|
102
|
-
*/
|
|
103
|
-
formatPhoneNumber(number) {
|
|
104
|
-
const numStr = String(number).replace(/\s/g, '');
|
|
105
|
-
if (numStr.length < 11) {
|
|
106
|
-
return numStr;
|
|
107
|
-
}
|
|
108
|
-
const firstPart = numStr.slice(0, 3);
|
|
109
|
-
const secondPart = numStr.slice(3, 7);
|
|
110
|
-
const thirdPart = numStr.slice(7, 11);
|
|
111
|
-
return `${firstPart} ${secondPart} ${thirdPart}`;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
export default new NumberClass();
|
|
1
|
+
/**
|
|
2
|
+
* @file number 格式化
|
|
3
|
+
* @Author: wanghui
|
|
4
|
+
* @createBy: @2020.05.26
|
|
5
|
+
*/
|
|
6
|
+
'use strict';
|
|
7
|
+
class NumberClass {
|
|
8
|
+
/**
|
|
9
|
+
* 个位数前面补0
|
|
10
|
+
* @param {Number} num 需要格式化的数字
|
|
11
|
+
* @return {String} '01'
|
|
12
|
+
*/
|
|
13
|
+
formatNumber(num) {
|
|
14
|
+
const res = num.toString();
|
|
15
|
+
return res[1] ? res : '0' + res;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 将手机号中间部分替换为星号
|
|
19
|
+
* @param {String} phone 手机号码
|
|
20
|
+
* @return {String} 131****1111
|
|
21
|
+
*/
|
|
22
|
+
formatPhone(phone) {
|
|
23
|
+
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 格式化数字 万
|
|
27
|
+
* @param {Number} num
|
|
28
|
+
* @return {String} 12.3万
|
|
29
|
+
*/
|
|
30
|
+
convertToWan(num) {
|
|
31
|
+
let result = '';
|
|
32
|
+
if (num < 10000) {
|
|
33
|
+
result = num;
|
|
34
|
+
}
|
|
35
|
+
if (num >= 10000) {
|
|
36
|
+
result = (num / 10000).toFixed(1) + '万';
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 格式化数字 k
|
|
42
|
+
* @param {Number} num
|
|
43
|
+
* @return {String} 1.2k
|
|
44
|
+
*/
|
|
45
|
+
convertToThousand(num) {
|
|
46
|
+
let result = '';
|
|
47
|
+
if (num < 1000) {
|
|
48
|
+
result = num;
|
|
49
|
+
}
|
|
50
|
+
if (num >= 1000) {
|
|
51
|
+
result = (num / 1000).toFixed(1) + 'k';
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 随机数,指定范围
|
|
57
|
+
* @param {Number} min 开始
|
|
58
|
+
* @param {Number} max 结束
|
|
59
|
+
* @return {Number|Object}
|
|
60
|
+
*/
|
|
61
|
+
random(min, max) {
|
|
62
|
+
if (arguments.length === 2) {
|
|
63
|
+
return Math.floor(min + Math.random() * ((max + 1) - min));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 格式化金额
|
|
71
|
+
* @param {Number} num
|
|
72
|
+
* @return {String} 123,456
|
|
73
|
+
*/
|
|
74
|
+
formatMoney(money, signal) {
|
|
75
|
+
let result = '';
|
|
76
|
+
if (money === '') {
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
money = String(money).replace('.00', '');
|
|
80
|
+
money = money.substring(money.length - 2) === '.0' ? money.replace('.0', '') : money;
|
|
81
|
+
// 小于3位数,直接返回
|
|
82
|
+
if (Number(money) < 1000) {
|
|
83
|
+
return result = money;
|
|
84
|
+
}
|
|
85
|
+
if (money.split('.')[0].length < 3) {
|
|
86
|
+
return result = money;
|
|
87
|
+
}
|
|
88
|
+
signal = signal === '' ? '' : ',';
|
|
89
|
+
let price = money.split('.')[0] + '';
|
|
90
|
+
const pricePoint = money.split('.')[1];
|
|
91
|
+
result = price.length > 6 ?
|
|
92
|
+
`${price.substring(0, price.length - 6)}${signal}${price.substring(price.length - 6, price.length - 3)},${price.substring(price.length - 3, price.length)}`
|
|
93
|
+
:
|
|
94
|
+
`${price.substring(0, price.length - 3)}${signal}${price.substring(price.length - 3, price.length)}`;
|
|
95
|
+
result = pricePoint ? `${result}${signal}${pricePoint}` : result;
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 格式化手机号
|
|
100
|
+
* @param {string} number 手机号
|
|
101
|
+
* @returns {string} 格式化后的手机号 12345678901 -> 123 4567 8901
|
|
102
|
+
*/
|
|
103
|
+
formatPhoneNumber(number) {
|
|
104
|
+
const numStr = String(number).replace(/\s/g, '');
|
|
105
|
+
if (numStr.length < 11) {
|
|
106
|
+
return numStr;
|
|
107
|
+
}
|
|
108
|
+
const firstPart = numStr.slice(0, 3);
|
|
109
|
+
const secondPart = numStr.slice(3, 7);
|
|
110
|
+
const thirdPart = numStr.slice(7, 11);
|
|
111
|
+
return `${firstPart} ${secondPart} ${thirdPart}`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export default new NumberClass();
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
interface Window {
|
|
3
|
-
AppCall?: {
|
|
4
|
-
has: (method: string) => boolean;
|
|
5
|
-
openOtherAppUrlRouter: (params: {
|
|
6
|
-
appUrlRouter: string;
|
|
7
|
-
}) => void;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
interface EnvConfig {
|
|
12
|
-
motoAndroidScheme?: string;
|
|
13
|
-
motoIOSScheme?: string;
|
|
14
|
-
APPLINK?: string;
|
|
15
|
-
APPLINKIOS?: string;
|
|
16
|
-
emotofineAndroidScheme?: string;
|
|
17
|
-
emotofineIOSScheme?: string;
|
|
18
|
-
EMOTOFINEAPPLINK?: string;
|
|
19
|
-
EMOTOFINEAPPLINKIOS?: string;
|
|
20
|
-
biaofineAndroidScheme?: string;
|
|
21
|
-
biaofineIOSScheme?: string;
|
|
22
|
-
BIAOFINEAPPLINK?: string;
|
|
23
|
-
BIAOFINEAPPLINKIOS?: string;
|
|
24
|
-
APPLINKPRICE?: string;
|
|
25
|
-
APPLINKPRICEIOS?: string;
|
|
26
|
-
}
|
|
27
|
-
interface OpenAppState {
|
|
28
|
-
state?: {
|
|
29
|
-
openApps?: {
|
|
30
|
-
type?: string;
|
|
31
|
-
href?: string;
|
|
32
|
-
id?: number | string;
|
|
33
|
-
title?: string;
|
|
34
|
-
url?: string;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
declare class OpenAppClass {
|
|
39
|
-
private env;
|
|
40
|
-
private postJddTrack;
|
|
41
|
-
private trackId;
|
|
42
|
-
private openAppState?;
|
|
43
|
-
private ua;
|
|
44
|
-
private _wx;
|
|
45
|
-
private _android;
|
|
46
|
-
private _isHarmonyos;
|
|
47
|
-
private _ios;
|
|
48
|
-
private _isPrice;
|
|
49
|
-
private currentEnv;
|
|
50
|
-
private appUrl?;
|
|
51
|
-
private appStoreUrl?;
|
|
52
|
-
private underway;
|
|
53
|
-
/**
|
|
54
|
-
* @param {Object} env - 环境配置,必须
|
|
55
|
-
* @param {Function} postJddTrack - 埋点方法,必须
|
|
56
|
-
* @param {String} trackId - 埋点id,可选
|
|
57
|
-
* @param {Object} openAppState - 打开app状态,可选
|
|
58
|
-
*/
|
|
59
|
-
constructor(env: EnvConfig, postJddTrack: (trackId: string, data: {
|
|
60
|
-
tag: string;
|
|
61
|
-
}) => void, trackId?: string, openAppState?: OpenAppState);
|
|
62
|
-
/**
|
|
63
|
-
* 根据域名动态获取配置,保证多项目代码一样
|
|
64
|
-
*/
|
|
65
|
-
getCurrentEnv(): void;
|
|
66
|
-
/**
|
|
67
|
-
* 打开APP主流程
|
|
68
|
-
*/
|
|
69
|
-
invoke(): void;
|
|
70
|
-
getUrl(): string | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* 获取打开 app sechma url
|
|
73
|
-
* @returns {string | undefined} 打开app的schema或跳转链接
|
|
74
|
-
* params:params={"type":"","id":0,"name":"","travelId":0}
|
|
75
|
-
* type:原生页面key(必须);id:页面id(可选);subject 短话题、版块名称 或 页面标题(可选);travelId 游记id(可选)
|
|
76
|
-
*/
|
|
77
|
-
getSechmaUrl(): string | undefined;
|
|
78
|
-
/**
|
|
79
|
-
* 方法一(推荐):打开APP
|
|
80
|
-
* http://www.cnblogs.com/shadajin/p/5724117.html
|
|
81
|
-
*/
|
|
82
|
-
open(openUrl: string | undefined): string | Promise<unknown> | undefined;
|
|
83
|
-
}
|
|
84
|
-
export default OpenAppClass;
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
AppCall?: {
|
|
4
|
+
has: (method: string) => boolean;
|
|
5
|
+
openOtherAppUrlRouter: (params: {
|
|
6
|
+
appUrlRouter: string;
|
|
7
|
+
}) => void;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
interface EnvConfig {
|
|
12
|
+
motoAndroidScheme?: string;
|
|
13
|
+
motoIOSScheme?: string;
|
|
14
|
+
APPLINK?: string;
|
|
15
|
+
APPLINKIOS?: string;
|
|
16
|
+
emotofineAndroidScheme?: string;
|
|
17
|
+
emotofineIOSScheme?: string;
|
|
18
|
+
EMOTOFINEAPPLINK?: string;
|
|
19
|
+
EMOTOFINEAPPLINKIOS?: string;
|
|
20
|
+
biaofineAndroidScheme?: string;
|
|
21
|
+
biaofineIOSScheme?: string;
|
|
22
|
+
BIAOFINEAPPLINK?: string;
|
|
23
|
+
BIAOFINEAPPLINKIOS?: string;
|
|
24
|
+
APPLINKPRICE?: string;
|
|
25
|
+
APPLINKPRICEIOS?: string;
|
|
26
|
+
}
|
|
27
|
+
interface OpenAppState {
|
|
28
|
+
state?: {
|
|
29
|
+
openApps?: {
|
|
30
|
+
type?: string;
|
|
31
|
+
href?: string;
|
|
32
|
+
id?: number | string;
|
|
33
|
+
title?: string;
|
|
34
|
+
url?: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
declare class OpenAppClass {
|
|
39
|
+
private env;
|
|
40
|
+
private postJddTrack;
|
|
41
|
+
private trackId;
|
|
42
|
+
private openAppState?;
|
|
43
|
+
private ua;
|
|
44
|
+
private _wx;
|
|
45
|
+
private _android;
|
|
46
|
+
private _isHarmonyos;
|
|
47
|
+
private _ios;
|
|
48
|
+
private _isPrice;
|
|
49
|
+
private currentEnv;
|
|
50
|
+
private appUrl?;
|
|
51
|
+
private appStoreUrl?;
|
|
52
|
+
private underway;
|
|
53
|
+
/**
|
|
54
|
+
* @param {Object} env - 环境配置,必须
|
|
55
|
+
* @param {Function} postJddTrack - 埋点方法,必须
|
|
56
|
+
* @param {String} trackId - 埋点id,可选
|
|
57
|
+
* @param {Object} openAppState - 打开app状态,可选
|
|
58
|
+
*/
|
|
59
|
+
constructor(env: EnvConfig, postJddTrack: (trackId: string, data: {
|
|
60
|
+
tag: string;
|
|
61
|
+
}) => void, trackId?: string, openAppState?: OpenAppState);
|
|
62
|
+
/**
|
|
63
|
+
* 根据域名动态获取配置,保证多项目代码一样
|
|
64
|
+
*/
|
|
65
|
+
getCurrentEnv(): void;
|
|
66
|
+
/**
|
|
67
|
+
* 打开APP主流程
|
|
68
|
+
*/
|
|
69
|
+
invoke(): void;
|
|
70
|
+
getUrl(): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* 获取打开 app sechma url
|
|
73
|
+
* @returns {string | undefined} 打开app的schema或跳转链接
|
|
74
|
+
* params:params={"type":"","id":0,"name":"","travelId":0}
|
|
75
|
+
* type:原生页面key(必须);id:页面id(可选);subject 短话题、版块名称 或 页面标题(可选);travelId 游记id(可选)
|
|
76
|
+
*/
|
|
77
|
+
getSechmaUrl(): string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* 方法一(推荐):打开APP
|
|
80
|
+
* http://www.cnblogs.com/shadajin/p/5724117.html
|
|
81
|
+
*/
|
|
82
|
+
open(openUrl: string | undefined): string | Promise<unknown> | undefined;
|
|
83
|
+
}
|
|
84
|
+
export default OpenAppClass;
|