gio-miniprogram-sdk 4.4.2 → 4.5.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 +13 -11
- package/dist/alipay.js +1 -1
- package/dist/baidu.js +1 -1
- package/dist/bytedance.js +1 -1
- package/dist/jingdong.js +1 -1
- package/dist/kuaishou.js +1 -1
- package/dist/mpx.js +1 -0
- package/dist/plugins/gioABTest.js +1 -1
- package/dist/plugins/gioCompress.js +1 -1
- package/dist/plugins/gioEventAutoTracking.js +1 -1
- package/dist/plugins/gioImpressionTracking.js +1 -1
- package/dist/plugins/gioMultipleInstances.js +1 -1
- package/dist/plugins/gioPerformance.js +1 -1
- package/dist/qq.js +1 -1
- package/dist/quickapp.js +1 -1
- package/dist/taobao.js +1 -1
- package/dist/taro.js +1 -1
- package/dist/uniapp.js +1 -1
- package/dist/wechat.js +1 -1
- package/dist/xiaohongshu.js +1 -1
- package/package.json +13 -2
- package/.eslintignore +0 -11
- package/.eslintrc.js +0 -120
- package/.github/workflows/greetings.yml +0 -13
- package/.github/workflows/publish.yml +0 -45
- package/.prettierignore +0 -19
- package/.prettierrc.js +0 -9
- package/babel.config.js +0 -6
- package/rollup.config.js +0 -100
- package/rollup.plugins.config.js +0 -84
- package/src/adapters/gioTaobaoAdapter.ts +0 -202
- package/src/adapters/gioTaroAdapter.ts +0 -467
- package/src/adapters/gioUniAppAdapter.ts +0 -431
- package/src/constants/config.ts +0 -170
- package/src/constants/emitMsg.ts +0 -24
- package/src/constants/regex.ts +0 -18
- package/src/core/dataStore/eventContextBuilder.ts +0 -95
- package/src/core/dataStore/eventHooks/appEffects.ts +0 -218
- package/src/core/dataStore/eventHooks/index.ts +0 -468
- package/src/core/dataStore/eventHooks/minipPage.ts +0 -221
- package/src/core/dataStore/eventHooks/pageEffects.ts +0 -189
- package/src/core/dataStore/index.ts +0 -661
- package/src/core/growingIO.ts +0 -637
- package/src/core/pluginsInstance/base.ts +0 -157
- package/src/core/pluginsInstance/taro.ts +0 -15
- package/src/core/pluginsInstance/tb.ts +0 -15
- package/src/core/pluginsInstance/uniapp.ts +0 -15
- package/src/core/uploader.ts +0 -272
- package/src/core/userStore.ts +0 -267
- package/src/index.ts +0 -77
- package/src/minipInstance/base.ts +0 -352
- package/src/minipInstance/framework.ts +0 -24
- package/src/minipInstance/jd.ts +0 -11
- package/src/minipInstance/ks.ts +0 -12
- package/src/minipInstance/my.ts +0 -131
- package/src/minipInstance/qq.ts +0 -12
- package/src/minipInstance/quickapp.ts +0 -233
- package/src/minipInstance/swan.ts +0 -20
- package/src/minipInstance/tb.ts +0 -58
- package/src/minipInstance/tt.ts +0 -12
- package/src/minipInstance/wx.ts +0 -27
- package/src/minipInstance/xhs.ts +0 -20
- package/src/platformConfig/base.ts +0 -82
- package/src/platformConfig/framework.ts +0 -31
- package/src/platformConfig/jd.ts +0 -11
- package/src/platformConfig/ks.ts +0 -11
- package/src/platformConfig/my.ts +0 -16
- package/src/platformConfig/qq.ts +0 -13
- package/src/platformConfig/quickapp.ts +0 -48
- package/src/platformConfig/swan.ts +0 -11
- package/src/platformConfig/tb.ts +0 -29
- package/src/platformConfig/tt.ts +0 -11
- package/src/platformConfig/wx.ts +0 -20
- package/src/platformConfig/xhs.ts +0 -27
- package/src/plugins/gioABTest.ts +0 -348
- package/src/plugins/gioCompress.ts +0 -253
- package/src/plugins/gioEventAutoTracking.ts +0 -310
- package/src/plugins/gioImpressionTracking.ts +0 -386
- package/src/plugins/gioMultipleInstances.ts +0 -189
- package/src/plugins/gioPerformance/exception.ts +0 -152
- package/src/plugins/gioPerformance/monitor.ts +0 -284
- package/src/plugins/gioPerformance/network.ts +0 -197
- package/src/plugins/gioPerformance.ts +0 -131
- package/src/types/base.ts +0 -167
- package/src/types/dataStore.ts +0 -62
- package/src/types/eventHooks.ts +0 -146
- package/src/types/gioCustomTracking.ts +0 -9
- package/src/types/gioEventTracking.ts +0 -10
- package/src/types/gioPerformance.ts +0 -8
- package/src/types/growingIO.ts +0 -137
- package/src/types/minipInstance.ts +0 -133
- package/src/types/platforms.ts +0 -64
- package/src/types/plugins.ts +0 -24
- package/src/types/uploader.ts +0 -30
- package/src/types/userStore.ts +0 -28
- package/src/utils/glodash.ts +0 -430
- package/src/utils/tools.ts +0 -511
- package/src/utils/verifiers.ts +0 -52
- package/tsconfig.json +0 -32
- package/typings/global.d.ts +0 -105
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { getPlainPlatform } from '@@/utils/tools';
|
|
2
|
-
|
|
3
|
-
import XiaoHongShu from './xhs';
|
|
4
|
-
import JingDong from './jd';
|
|
5
|
-
import KuaiShou from './ks';
|
|
6
|
-
import Alipay from './my';
|
|
7
|
-
import QQ from './qq';
|
|
8
|
-
import Baidu from './swan';
|
|
9
|
-
import Bytedance from './tt';
|
|
10
|
-
import Weixin from './wx';
|
|
11
|
-
|
|
12
|
-
const plainPlatform = getPlainPlatform();
|
|
13
|
-
const INST = {
|
|
14
|
-
wx: Weixin,
|
|
15
|
-
swan: Baidu,
|
|
16
|
-
my: Alipay,
|
|
17
|
-
qq: QQ,
|
|
18
|
-
tt: Bytedance,
|
|
19
|
-
ks: KuaiShou,
|
|
20
|
-
jd: JingDong,
|
|
21
|
-
xhs: XiaoHongShu
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default INST[plainPlatform];
|
package/src/minipInstance/jd.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { GrowingIOType } from '@@/types/growingIO';
|
|
2
|
-
import BaseImplements from './base';
|
|
3
|
-
|
|
4
|
-
class JingDong extends BaseImplements {
|
|
5
|
-
constructor(public growingIO: GrowingIOType) {
|
|
6
|
-
super(growingIO);
|
|
7
|
-
this.hookSetTitle();
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default JingDong;
|
package/src/minipInstance/ks.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { GrowingIOType } from '@@/types/growingIO';
|
|
2
|
-
|
|
3
|
-
import BaseImplements from './base';
|
|
4
|
-
|
|
5
|
-
class KuaiShou extends BaseImplements {
|
|
6
|
-
constructor(public growingIO: GrowingIOType) {
|
|
7
|
-
super(growingIO);
|
|
8
|
-
this.hookSetTitle();
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default KuaiShou;
|
package/src/minipInstance/my.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { compareVersion, consoleText } from '@@/utils/tools';
|
|
2
|
-
import { GrowingIOType } from '@@/types/growingIO';
|
|
3
|
-
import { isFunction } from '@@/utils/glodash';
|
|
4
|
-
import BaseImplements from './base';
|
|
5
|
-
|
|
6
|
-
class Alipay extends BaseImplements {
|
|
7
|
-
constructor(public growingIO: GrowingIOType) {
|
|
8
|
-
super(growingIO);
|
|
9
|
-
this.hookSetTitle();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
hookSetTitle = () => {
|
|
13
|
-
const originSetter = this.minip?.setNavigationBar;
|
|
14
|
-
const self = this;
|
|
15
|
-
if (originSetter) {
|
|
16
|
-
Object.defineProperty(this.minip, 'setNavigationBar', {
|
|
17
|
-
writable: true,
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
value: function () {
|
|
21
|
-
if (self.growingIO.gioSDKInitialized) {
|
|
22
|
-
// 这个currentPath一般认为是在onLoad中获取的当前小程序页面的path,此时SDK还没有parse,保存的还是上一个页面的信息
|
|
23
|
-
const currentPath = self.getCurrentPath();
|
|
24
|
-
const { title } = arguments[0] || {};
|
|
25
|
-
self.growingIO.dataStore.eventHooks.currentPage.configuredTitle[
|
|
26
|
-
currentPath
|
|
27
|
-
] = title;
|
|
28
|
-
}
|
|
29
|
-
return originSetter.apply(this, arguments);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// 采集曝光事件
|
|
36
|
-
initImpression = (collectPage: any) => {
|
|
37
|
-
this.growingIO.plugins?.gioImpressionTracking?.main(
|
|
38
|
-
collectPage,
|
|
39
|
-
'selectAll'
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// 同步获取存储数据(支付宝小程序返回值与其他平台不同)
|
|
44
|
-
getStorageSync = (key: string) => {
|
|
45
|
-
const { data } = my.getStorageSync({ key });
|
|
46
|
-
return data;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// 同步存储数据(支付宝小程序参数与其他平台不同)
|
|
50
|
-
setStorageSync = (key: string, value: any) => {
|
|
51
|
-
this.minip?.setStorageSync({ key, data: value });
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// 同步移除指定数据
|
|
55
|
-
removeStorageSync = (key: string) => {
|
|
56
|
-
this.minip?.removeStorageSync({ key });
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// 支付宝和mpass单独处理
|
|
60
|
-
request = ({
|
|
61
|
-
url,
|
|
62
|
-
data,
|
|
63
|
-
header,
|
|
64
|
-
timeout,
|
|
65
|
-
method,
|
|
66
|
-
success,
|
|
67
|
-
fail,
|
|
68
|
-
complete
|
|
69
|
-
}) => {
|
|
70
|
-
const requestTask = this.minip?.request({
|
|
71
|
-
url,
|
|
72
|
-
data,
|
|
73
|
-
// 支付宝小程序里叫headers
|
|
74
|
-
headers: header,
|
|
75
|
-
timeout,
|
|
76
|
-
method,
|
|
77
|
-
success,
|
|
78
|
-
fail,
|
|
79
|
-
complete
|
|
80
|
-
});
|
|
81
|
-
const myVersion = this.minip.SDKVersion;
|
|
82
|
-
// 支付宝小程序2.0.0版本及以上才超时中断请求
|
|
83
|
-
// https://github.com/growingio/growingio-sdk-miniprogram-autotracker/issues/3
|
|
84
|
-
if (compareVersion(myVersion, '2.0.0') >= 0) {
|
|
85
|
-
// 设置超时中断请求
|
|
86
|
-
let t = setTimeout(() => {
|
|
87
|
-
if (requestTask?.abort && isFunction(requestTask?.abort)) {
|
|
88
|
-
requestTask?.abort();
|
|
89
|
-
}
|
|
90
|
-
clearTimeout(t);
|
|
91
|
-
t = null;
|
|
92
|
-
}, (timeout || 10000) + 10);
|
|
93
|
-
}
|
|
94
|
-
return requestTask;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// 执行支付宝特有的promise分享
|
|
98
|
-
handleSharePromise = (originResult, handlePromiseResult) => {
|
|
99
|
-
// 创建监听_result变化的Promise
|
|
100
|
-
const alipayPromise = new Promise((resolve) => {
|
|
101
|
-
// 如果已有_result直接返回
|
|
102
|
-
if (originResult._result) {
|
|
103
|
-
resolve(originResult._result);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
// 监听_result属性变化
|
|
107
|
-
Object.defineProperty(originResult, '_result', {
|
|
108
|
-
set(value) {
|
|
109
|
-
this.__result = value;
|
|
110
|
-
resolve(value);
|
|
111
|
-
},
|
|
112
|
-
get() {
|
|
113
|
-
return this.__result;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
// 如果三秒内不resolve结果,分享会使用原默认参数
|
|
118
|
-
Promise.race([
|
|
119
|
-
alipayPromise,
|
|
120
|
-
new Promise((resolve) => {
|
|
121
|
-
setTimeout(() => {
|
|
122
|
-
resolve(originResult._result || {});
|
|
123
|
-
}, 3000);
|
|
124
|
-
})
|
|
125
|
-
])
|
|
126
|
-
.then(handlePromiseResult)
|
|
127
|
-
.catch((error) => consoleText(error, 'error'));
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export default Alipay;
|
package/src/minipInstance/qq.ts
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import { GrowingIOType } from '@@/types/growingIO';
|
|
2
|
-
import { isString, last } from '@@/utils/glodash';
|
|
3
|
-
import { limitString, niceTry } from '@@/utils/tools';
|
|
4
|
-
import { SystemInfo } from '@@/types/minipInstance';
|
|
5
|
-
import app from '@system.app';
|
|
6
|
-
import BaseImplements from './base';
|
|
7
|
-
import device from '@system.device';
|
|
8
|
-
import EMIT_MSG from '@@/constants/emitMsg';
|
|
9
|
-
import fetch from '@system.fetch';
|
|
10
|
-
import image from '@system.image';
|
|
11
|
-
import network from '@system.network';
|
|
12
|
-
import router from '@system.router';
|
|
13
|
-
import share from '@system.share';
|
|
14
|
-
import storage from '@system.storage';
|
|
15
|
-
|
|
16
|
-
class QuickApp extends BaseImplements {
|
|
17
|
-
constructor(public growingIO: GrowingIOType) {
|
|
18
|
-
super(growingIO);
|
|
19
|
-
this.growingIO.emitter.on(EMIT_MSG.MINIP_LIFECYCLE, ({ event }) => {
|
|
20
|
-
switch (event) {
|
|
21
|
-
case 'App onCreate':
|
|
22
|
-
{
|
|
23
|
-
this.getNetworkType().then(() =>
|
|
24
|
-
this.growingIO.dataStore?.eventReleaseInspector()
|
|
25
|
-
);
|
|
26
|
-
this.getSystemInfo().then(() =>
|
|
27
|
-
this.growingIO.dataStore?.eventReleaseInspector()
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
break;
|
|
31
|
-
case 'App onCreateEnd':
|
|
32
|
-
{
|
|
33
|
-
this.setStorage = (key: string, value: string) => {
|
|
34
|
-
storage?.set({ key, value });
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
break;
|
|
38
|
-
default:
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 业务相关
|
|
46
|
-
*/
|
|
47
|
-
// 获取应用来源
|
|
48
|
-
getAppSource = () => {
|
|
49
|
-
const { source } = app.getInfo();
|
|
50
|
-
this.appSource = source || {};
|
|
51
|
-
return this.appSource;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// 保留当前页面,跳转到应用内的某个页面(重写为空)
|
|
55
|
-
navigateTo = () => {}; // eslint-disable-line
|
|
56
|
-
|
|
57
|
-
// 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面(重写为空)
|
|
58
|
-
switchTab = () => {}; // eslint-disable-line
|
|
59
|
-
|
|
60
|
-
// 打开另一个小程序(重写为空)
|
|
61
|
-
navigateToMiniProgram = () => {}; // eslint-disable-line
|
|
62
|
-
|
|
63
|
-
// 监听小程序切前台事件(重写为空)
|
|
64
|
-
onAppShow = () => {}; // eslint-disable-line
|
|
65
|
-
|
|
66
|
-
// 监听小程序切后台事件(重写为空)
|
|
67
|
-
onAppHide = () => {}; // eslint-disable-line
|
|
68
|
-
|
|
69
|
-
// 获取图片信息
|
|
70
|
-
getImageInfo = ({ src, success, fail, complete }: any) => {
|
|
71
|
-
return image?.getImageInfo({ uri: src, success, fail, complete });
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// 采集曝光事件
|
|
75
|
-
initImpression = () => {}; // eslint-disable-line
|
|
76
|
-
|
|
77
|
-
// 初始化分享
|
|
78
|
-
initShareAppMessage = (growingIO: GrowingIOType) => {
|
|
79
|
-
const { platformConfig } = growingIO;
|
|
80
|
-
try {
|
|
81
|
-
this.growingIO.shareAppMessage = function () {
|
|
82
|
-
const params = arguments[0];
|
|
83
|
-
share?.share(params);
|
|
84
|
-
growingIO?.eventTracking?.pageEffects(
|
|
85
|
-
this,
|
|
86
|
-
platformConfig.listeners.page.shareApp as any,
|
|
87
|
-
arguments
|
|
88
|
-
);
|
|
89
|
-
};
|
|
90
|
-
} catch (e) {
|
|
91
|
-
//
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* 页面相关
|
|
97
|
-
*/
|
|
98
|
-
// 获取当前页面栈
|
|
99
|
-
getCurrentPage = () => {
|
|
100
|
-
niceTry(() => {
|
|
101
|
-
if (router?.getPages) {
|
|
102
|
-
return last(router?.getPages()) || {};
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
return {};
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// 获取当前页面路由
|
|
109
|
-
getCurrentPath = () => {
|
|
110
|
-
niceTry(() => {
|
|
111
|
-
if (router?.getState) {
|
|
112
|
-
return router?.getState()?.path || '';
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
return '';
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// 获取页面标题(除wx以外其他平台)
|
|
119
|
-
getPageTitle = (page) => {
|
|
120
|
-
let title = '';
|
|
121
|
-
try {
|
|
122
|
-
// this.$page.setTitleBar是只读方法,不能hook
|
|
123
|
-
// 第一优先级支持客户自己在页面中设置页面title
|
|
124
|
-
title = isString(page?.gioPageTitle) ? page?.gioPageTitle : '';
|
|
125
|
-
// 第三优先级取页面的titleBarText
|
|
126
|
-
if (!title) {
|
|
127
|
-
const instConfig = page?.$app?.$def?.manifast?.display?.pages ?? {};
|
|
128
|
-
const pageInfo = instConfig?.[page.route];
|
|
129
|
-
if (pageInfo) {
|
|
130
|
-
title = pageInfo.titleBarText;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// 第四优先级取router状态
|
|
134
|
-
if (!title) {
|
|
135
|
-
const route = router?.getState();
|
|
136
|
-
title = route?.name || '';
|
|
137
|
-
}
|
|
138
|
-
} catch (e) {
|
|
139
|
-
return '';
|
|
140
|
-
}
|
|
141
|
-
return limitString(title);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* 存储相关
|
|
146
|
-
*/
|
|
147
|
-
// 同步获取存储数据
|
|
148
|
-
getStorageSync = () => '';
|
|
149
|
-
|
|
150
|
-
// 异步获取存储数据
|
|
151
|
-
getStorage = async (key: string): Promise<string> => {
|
|
152
|
-
return await new Promise((resolve) => {
|
|
153
|
-
storage?.get({
|
|
154
|
-
key,
|
|
155
|
-
success: (res) => resolve(res),
|
|
156
|
-
fail: () => resolve(null)
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
// 同步存储数据
|
|
162
|
-
setStorageSync = () => {}; // eslint-disable-line
|
|
163
|
-
|
|
164
|
-
// 异步存储数据
|
|
165
|
-
setStorage = (key: string, value: string) => {}; // eslint-disable-line
|
|
166
|
-
|
|
167
|
-
// 同步移除指定数据
|
|
168
|
-
removeStorageSync = () => {}; // eslint-disable-line
|
|
169
|
-
|
|
170
|
-
// 异步移除指定数据
|
|
171
|
-
removeStorage = (key: string) => {
|
|
172
|
-
storage?.delete({ key });
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* 网络相关
|
|
177
|
-
*/
|
|
178
|
-
// 获取网络类型
|
|
179
|
-
getNetworkType = async (): Promise<{
|
|
180
|
-
networkType: string;
|
|
181
|
-
}> => {
|
|
182
|
-
const self = this;
|
|
183
|
-
return await new Promise((resolve) => {
|
|
184
|
-
network?.getType({
|
|
185
|
-
success: (res) => {
|
|
186
|
-
self.network = res;
|
|
187
|
-
resolve(res);
|
|
188
|
-
},
|
|
189
|
-
fail: () => resolve(null)
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
// 发起请求
|
|
195
|
-
request = ({ url, header, method, data, success, fail, complete }) => {
|
|
196
|
-
return fetch?.fetch({ url, header, method, data, success, fail, complete });
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* 系统相关
|
|
201
|
-
*/
|
|
202
|
-
// 获取设备系统信息
|
|
203
|
-
getSystemInfo = async (): Promise<SystemInfo> => {
|
|
204
|
-
const self = this;
|
|
205
|
-
return await new Promise((resolve) => {
|
|
206
|
-
device?.getInfo({
|
|
207
|
-
success: (res) => {
|
|
208
|
-
const info = {
|
|
209
|
-
...res,
|
|
210
|
-
version: res.platformVersionName,
|
|
211
|
-
platform: res.osType
|
|
212
|
-
};
|
|
213
|
-
self.systemInfo = info;
|
|
214
|
-
resolve(info);
|
|
215
|
-
},
|
|
216
|
-
fail: () => resolve(null)
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
// 监听网络变更
|
|
222
|
-
setNetworkStatusListener = () => {
|
|
223
|
-
network.subscribe({
|
|
224
|
-
callback: (data) => {
|
|
225
|
-
if (data.type) {
|
|
226
|
-
this.network.networkType = data.type;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export default QuickApp;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { GrowingIOType } from '@@/types/growingIO';
|
|
2
|
-
|
|
3
|
-
import BaseImplements from './base';
|
|
4
|
-
|
|
5
|
-
class Baidu extends BaseImplements {
|
|
6
|
-
constructor(public growingIO: GrowingIOType) {
|
|
7
|
-
super(growingIO);
|
|
8
|
-
this.hookSetTitle();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// 采集曝光事件
|
|
12
|
-
initImpression = (collectPage: any) => {
|
|
13
|
-
this.growingIO.plugins?.gioImpressionTracking?.main(
|
|
14
|
-
collectPage,
|
|
15
|
-
'selectAll'
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default Baidu;
|
package/src/minipInstance/tb.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { GrowingIOType } from '@@/types/growingIO';
|
|
2
|
-
import BaseImplements from './base';
|
|
3
|
-
|
|
4
|
-
class Taobao extends BaseImplements {
|
|
5
|
-
constructor(public growingIO: GrowingIOType) {
|
|
6
|
-
super(growingIO);
|
|
7
|
-
this.hookSetTitle();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
hookSetTitle = () => {
|
|
11
|
-
const originSetter = this.minip?.setNavigationBar;
|
|
12
|
-
const self = this;
|
|
13
|
-
if (originSetter) {
|
|
14
|
-
Object.defineProperty(this.minip, 'setNavigationBar', {
|
|
15
|
-
writable: true,
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
value: function () {
|
|
19
|
-
if (self.growingIO.gioSDKInitialized) {
|
|
20
|
-
// 这个currentPath一般认为是在onLoad中获取的当前小程序页面的path,此时SDK还没有parse,保存的还是上一个页面的信息
|
|
21
|
-
const currentPath = self.getCurrentPath();
|
|
22
|
-
const { title } = arguments[0] || {};
|
|
23
|
-
self.growingIO.dataStore.eventHooks.currentPage.configuredTitle[
|
|
24
|
-
currentPath
|
|
25
|
-
] = title;
|
|
26
|
-
}
|
|
27
|
-
return originSetter.apply(this, arguments);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// 采集曝光事件
|
|
34
|
-
initImpression = (collectPage: any) => {
|
|
35
|
-
this.growingIO.plugins?.gioImpressionTracking?.main(
|
|
36
|
-
collectPage,
|
|
37
|
-
'selectAll'
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// 同步获取存储数据(支付宝小程序返回值与其他平台不同)
|
|
42
|
-
getStorageSync = (key: string) => {
|
|
43
|
-
const { data } = my.getStorageSync({ key });
|
|
44
|
-
return data;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// 同步存储数据(支付宝小程序参数与其他平台不同)
|
|
48
|
-
setStorageSync = (key: string, value: any) => {
|
|
49
|
-
this.minip?.setStorageSync({ key, data: value });
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// 同步移除指定数据
|
|
53
|
-
removeStorageSync = (key: string) => {
|
|
54
|
-
this.minip?.removeStorageSync({ key });
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default Taobao;
|
package/src/minipInstance/tt.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { GrowingIOType } from '@@/types/growingIO';
|
|
2
|
-
|
|
3
|
-
import BaseImplements from './base';
|
|
4
|
-
|
|
5
|
-
class Bytedance extends BaseImplements {
|
|
6
|
-
constructor(public growingIO: GrowingIOType) {
|
|
7
|
-
super(growingIO);
|
|
8
|
-
this.hookSetTitle();
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default Bytedance;
|
package/src/minipInstance/wx.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { GrowingIOType } from '@@/types/growingIO';
|
|
2
|
-
import { SystemInfo } from '@@/types/minipInstance';
|
|
3
|
-
|
|
4
|
-
import BaseImplements from './base';
|
|
5
|
-
|
|
6
|
-
class Weixin extends BaseImplements {
|
|
7
|
-
constructor(public growingIO: GrowingIOType) {
|
|
8
|
-
super(growingIO);
|
|
9
|
-
this.hookSetTitle();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// 获取小程序系统信息
|
|
13
|
-
getSystemInfo = (): Promise<SystemInfo> => {
|
|
14
|
-
const self = this;
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
const systemInfo = {
|
|
17
|
-
...this.minip?.getDeviceInfo(),
|
|
18
|
-
...this.minip?.getWindowInfo(),
|
|
19
|
-
...this.minip?.getAppBaseInfo()
|
|
20
|
-
};
|
|
21
|
-
self.systemInfo = systemInfo;
|
|
22
|
-
resolve(systemInfo);
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default Weixin;
|
package/src/minipInstance/xhs.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { GrowingIOType } from '@@/types/growingIO';
|
|
2
|
-
|
|
3
|
-
import BaseImplements from './base';
|
|
4
|
-
|
|
5
|
-
class XiaoHongShu extends BaseImplements {
|
|
6
|
-
constructor(public growingIO: GrowingIOType) {
|
|
7
|
-
super(growingIO);
|
|
8
|
-
this.hookSetTitle();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// 采集曝光事件
|
|
12
|
-
initImpression = (collectPage: any) => {
|
|
13
|
-
this.growingIO.plugins?.gioImpressionTracking?.main(
|
|
14
|
-
collectPage,
|
|
15
|
-
'selectAll'
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default XiaoHongShu;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { PlatformConfigType } from '@@/types/platforms';
|
|
2
|
-
|
|
3
|
-
const Config: PlatformConfigType = {
|
|
4
|
-
scnPrefix: '',
|
|
5
|
-
appHandlers: [
|
|
6
|
-
'onLaunch',
|
|
7
|
-
'onShow',
|
|
8
|
-
'onHide',
|
|
9
|
-
'onError', // 实际sdk不会执行,但需要写在hook里,防止被归为自定义事件
|
|
10
|
-
'onPageNotFound', // 实际sdk不会执行,但需要写在hook里,防止被归为自定义事件
|
|
11
|
-
'onUnhandledRejection', // 实际sdk不会执行,但需要写在hook里,防止被归为自定义事件
|
|
12
|
-
'onThemeChange' // 实际sdk不会执行,但需要写在hook里,防止被归为自定义事件
|
|
13
|
-
],
|
|
14
|
-
pageHandlers: [
|
|
15
|
-
'onLoad',
|
|
16
|
-
'onShow',
|
|
17
|
-
'onReady',
|
|
18
|
-
'onHide',
|
|
19
|
-
'onShareAppMessage',
|
|
20
|
-
'onTabItemTap',
|
|
21
|
-
'onUnload', // 实际sdk不会执行,但需要写在hook里,防止被归为自定义事件
|
|
22
|
-
'onPullDownRefresh', // 实际sdk不会执行,但需要写在hook里,防止被归为自定义事件
|
|
23
|
-
'onReachBottom', // 实际sdk不会执行,但需要写在hook里,防止被归为自定义事件
|
|
24
|
-
'onResize' // 实际sdk不会执行,但需要写在hook里,防止被归为自定义事件
|
|
25
|
-
],
|
|
26
|
-
shareEventTypes: ['onShareAppMessage', 'onShareTimeline', 'onAddToFavorites'],
|
|
27
|
-
actionEventTypes: [
|
|
28
|
-
'onclick',
|
|
29
|
-
'tap',
|
|
30
|
-
'onTap',
|
|
31
|
-
'longpress',
|
|
32
|
-
'longTap',
|
|
33
|
-
'blur',
|
|
34
|
-
'change',
|
|
35
|
-
'onChange',
|
|
36
|
-
'submit',
|
|
37
|
-
'confirm',
|
|
38
|
-
'getuserinfo',
|
|
39
|
-
'getphonenumber',
|
|
40
|
-
'contact',
|
|
41
|
-
'mouseup'
|
|
42
|
-
],
|
|
43
|
-
canHook: true,
|
|
44
|
-
hooks: {
|
|
45
|
-
App: true,
|
|
46
|
-
Page: true,
|
|
47
|
-
Component: true,
|
|
48
|
-
Behavior: true
|
|
49
|
-
},
|
|
50
|
-
listeners: {
|
|
51
|
-
app: {
|
|
52
|
-
appLaunch: 'onLaunch',
|
|
53
|
-
appShow: 'onShow',
|
|
54
|
-
appClose: 'onHide'
|
|
55
|
-
},
|
|
56
|
-
page: {
|
|
57
|
-
pageLoad: 'onLoad',
|
|
58
|
-
pageShow: 'onShow',
|
|
59
|
-
pageReady: 'onReady',
|
|
60
|
-
pageHide: 'onHide',
|
|
61
|
-
pageUnload: 'onUnload',
|
|
62
|
-
tabTap: 'onTabItemTap',
|
|
63
|
-
shareApp: 'onShareAppMessage'
|
|
64
|
-
},
|
|
65
|
-
actions: {
|
|
66
|
-
click: [
|
|
67
|
-
'onclick',
|
|
68
|
-
'tap',
|
|
69
|
-
'longpress',
|
|
70
|
-
'longTap',
|
|
71
|
-
'getuserinfo',
|
|
72
|
-
'getphonenumber',
|
|
73
|
-
'contact',
|
|
74
|
-
'mouseup'
|
|
75
|
-
],
|
|
76
|
-
change: ['blur', 'change', 'confirm'],
|
|
77
|
-
submit: ['submit']
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export default Config;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { niceTry, getPlainPlatform } from '@@/utils/tools';
|
|
2
|
-
|
|
3
|
-
import XHSConfig from './xhs';
|
|
4
|
-
import JDConfig from './jd';
|
|
5
|
-
import KSConfig from './ks';
|
|
6
|
-
import MyConfig from './my';
|
|
7
|
-
import TbConfig from './tb';
|
|
8
|
-
import QQConfig from './qq';
|
|
9
|
-
import SwanConfig from './swan';
|
|
10
|
-
import TTConfig from './tt';
|
|
11
|
-
import WXConfig from './wx';
|
|
12
|
-
|
|
13
|
-
const plainPlatform = getPlainPlatform();
|
|
14
|
-
const FrameworkConfig = niceTry(() => {
|
|
15
|
-
const INST = {
|
|
16
|
-
xhs: XHSConfig,
|
|
17
|
-
jd: JDConfig,
|
|
18
|
-
ks: KSConfig,
|
|
19
|
-
my: MyConfig,
|
|
20
|
-
tb: TbConfig,
|
|
21
|
-
qq: QQConfig,
|
|
22
|
-
swan: SwanConfig,
|
|
23
|
-
tt: TTConfig,
|
|
24
|
-
wx: WXConfig
|
|
25
|
-
};
|
|
26
|
-
const targetConfig = INST[plainPlatform];
|
|
27
|
-
targetConfig.canHook = false;
|
|
28
|
-
return targetConfig;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export default FrameworkConfig;
|