@cloudbase/lowcode-builder 1.1.5-alpha.2 → 1.1.6
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/lib/builder/config/index.d.ts +0 -8
- package/lib/builder/config/index.js +1 -16
- package/lib/builder/core/index.d.ts +2 -32
- package/lib/builder/core/index.js +30 -147
- package/lib/builder/h5/generate.d.ts +1 -3
- package/lib/builder/h5/generate.js +1 -2
- package/lib/builder/h5/index.d.ts +6 -6
- package/lib/builder/h5/index.js +14 -20
- package/lib/builder/h5/webpack.d.ts +1 -3
- package/lib/builder/h5/webpack.js +1 -2
- package/lib/builder/mp/BuildContext.d.ts +0 -4
- package/lib/builder/mp/index.d.ts +14 -5
- package/lib/builder/mp/index.js +28 -17
- package/lib/builder/mp/materials.js +0 -6
- package/lib/builder/mp/mixMode.d.ts +2 -3
- package/lib/builder/mp/mixMode.js +2 -5
- package/lib/builder/mp/mp_config.d.ts +1 -1
- package/lib/builder/mp/mp_config.js +2 -4
- package/lib/builder/mp/util.js +1 -1
- package/lib/builder/service/webpack.d.ts +0 -7
- package/lib/builder/service/webpack.js +21 -31
- package/lib/builder/util/generateFiles.d.ts +1 -0
- package/lib/builder/util/generateFiles.js +8 -6
- package/lib/builder/util/junk.d.ts +1 -0
- package/lib/builder/util/junk.js +7 -1
- package/lib/builder/util/net.js +4 -0
- package/lib/builder.web.js +21 -13
- package/package.json +2 -2
- package/template/html/index.html.ejs +11 -23
- package/template/mp/common/util.js +9 -5
- package/template/mp/common/widget.js +2 -2
- package/template/mp/common/wx_yypt_report_v2.js +460 -0
- package/template/mp/datasources/config.js.tpl +0 -1
- package/template/mp/package.json +6 -6
- package/template/package.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
|
|
5
5
|
"author": "yhsunshining@gmail.com",
|
|
6
6
|
"homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@cloudbase/cals": "^0.4.10",
|
|
42
|
-
"@cloudbase/lowcode-generator": "^1.1.2
|
|
42
|
+
"@cloudbase/lowcode-generator": "^1.1.2",
|
|
43
43
|
"axios": "^0.21.0",
|
|
44
44
|
"browserfs": "^1.4.3",
|
|
45
45
|
"browserify-zlib": "^0.2.0",
|
|
@@ -12,12 +12,9 @@
|
|
|
12
12
|
<meta name="description" content="<%= desc %>" />
|
|
13
13
|
<link
|
|
14
14
|
rel="stylesheet"
|
|
15
|
-
href="
|
|
16
|
-
cdnEndpoints.cdngo
|
|
17
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.ba91c21b0d605c84ac7f.css"
|
|
15
|
+
href="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.ba91c21b0d605c84ac7f.css"
|
|
18
16
|
/>
|
|
19
|
-
|
|
20
|
-
<script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis/aegis-sdk/latest/aegis.min.js?v=1"></script>
|
|
17
|
+
<script crossorigin="anonymous" src="https://cdn-go.cn/aegis/aegis-sdk/latest/aegis.min.js?v=1"></script>
|
|
21
18
|
<script>
|
|
22
19
|
<% if(!isAdminPortal){ %>
|
|
23
20
|
const _aegis = new Aegis({
|
|
@@ -39,7 +36,6 @@
|
|
|
39
36
|
window._aegis = _aegis;
|
|
40
37
|
window._aegis_inited = Date.now()
|
|
41
38
|
</script>
|
|
42
|
-
<% }%>
|
|
43
39
|
<title><%= title %></title>
|
|
44
40
|
<% if(mode !== 'production'){ %>
|
|
45
41
|
<!-- <script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.3.4/vconsole.min.js"></script>
|
|
@@ -391,10 +387,10 @@
|
|
|
391
387
|
<script type="module" src="/src/index.jsx"></script>
|
|
392
388
|
<% } %> <% if(!isAdminPortal){ %>
|
|
393
389
|
<script src="/weda-config/weda-private.js"></script>
|
|
394
|
-
<script src="
|
|
390
|
+
<script src="//static.cloudbase.net/cloudbase-js-sdk/2.4.7-beta.0/cloudbase.full.js?v=1"></script>
|
|
395
391
|
<% }%>
|
|
396
392
|
<script>
|
|
397
|
-
if (window.cloudbase
|
|
393
|
+
if (window.cloudbase) {
|
|
398
394
|
const _callFunction = window.cloudbase.__proto__.callFunction;
|
|
399
395
|
window.cloudbase.__proto__.callFunction = function (args) {
|
|
400
396
|
let promise = _callFunction.call(window.cloudbase, ...arguments);
|
|
@@ -435,23 +431,19 @@
|
|
|
435
431
|
</script>
|
|
436
432
|
<script
|
|
437
433
|
crossorigin
|
|
438
|
-
src="
|
|
434
|
+
src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/react@16.14.0/umd/react.production.min.js"
|
|
439
435
|
></script>
|
|
440
436
|
<script
|
|
441
437
|
crossorigin
|
|
442
|
-
src="
|
|
443
|
-
cdnEndpoints.cdngo
|
|
444
|
-
%>/lcap/lcap-resource-cdngo/-/release/_npm/react-dom@16.14.0/umd/react-dom.production.min.js"
|
|
438
|
+
src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/react-dom@16.14.0/umd/react-dom.production.min.js"
|
|
445
439
|
></script>
|
|
446
440
|
<script
|
|
447
|
-
src="
|
|
441
|
+
src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.2/_url/ajax/libs/mobx/5.15.7/mobx.umd.js"
|
|
448
442
|
crossorigin="anonymous"
|
|
449
443
|
></script>
|
|
450
444
|
<script
|
|
451
445
|
crossorigin="anonymous"
|
|
452
|
-
src="
|
|
453
|
-
cdnEndpoints.cdngo
|
|
454
|
-
%>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.19/dist/h5.browser.js"
|
|
446
|
+
src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.19/dist/h5.browser.js"
|
|
455
447
|
></script>
|
|
456
448
|
<script>
|
|
457
449
|
// zxing polifill
|
|
@@ -461,19 +453,15 @@
|
|
|
461
453
|
</script>
|
|
462
454
|
<script
|
|
463
455
|
crossorigin="anonymous"
|
|
464
|
-
src="
|
|
456
|
+
src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.2/_url/npm/@zxing/library@0.18.6/umd/index.min.js"
|
|
465
457
|
></script>
|
|
466
458
|
<script
|
|
467
459
|
crossorigin
|
|
468
|
-
src="
|
|
469
|
-
cdnEndpoints.cdngo
|
|
470
|
-
%>/lcap/lcap-resource-cdngo/-/release/_url/qcloud/lowcode/static/ide/assets/js/babel.min.js"
|
|
460
|
+
src="https://qbase.cdn-go.cn//lcap/lcap-resource-cdngo/-/release/_url/qcloud/lowcode/static/ide/assets/js/babel.min.js"
|
|
471
461
|
></script>
|
|
472
462
|
<script
|
|
473
463
|
crossorigin
|
|
474
|
-
src="
|
|
475
|
-
cdnEndpoints.cdngo
|
|
476
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.90a1845eb61a012b3d66.bundle.js"
|
|
464
|
+
src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.90a1845eb61a012b3d66.bundle.js"
|
|
477
465
|
></script>
|
|
478
466
|
</body>
|
|
479
467
|
</html>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import { findForItemsOfWidget, getWidget } from './widget'
|
|
3
|
-
import { observable } from 'mobx';
|
|
3
|
+
import { observable, untracked } from 'mobx';
|
|
4
4
|
import { getAccessToken } from '../datasources/index'
|
|
5
5
|
import { app } from '../app/weapps-api'
|
|
6
6
|
|
|
@@ -31,9 +31,13 @@ export function createComputed(funcs, bindContext = null) {
|
|
|
31
31
|
export function generateDataContext(widget) {
|
|
32
32
|
const dataContext = {};
|
|
33
33
|
while (widget?._scope) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const current = widget
|
|
35
|
+
// 此处采用代理的方式,是为了可以获取到最新的 _scope.dataContext 防止 dataContext 引用被重新赋值
|
|
36
|
+
Object.defineProperty(dataContext, current._scope.id, {
|
|
37
|
+
get() {
|
|
38
|
+
return current._scope.dataContext;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
37
41
|
widget = widget.parent;
|
|
38
42
|
}
|
|
39
43
|
return dataContext;
|
|
@@ -57,7 +61,7 @@ export function createEventHandlers(evtListeners) {
|
|
|
57
61
|
const [prefix = ''] = name.split('$');
|
|
58
62
|
// The page event handler
|
|
59
63
|
const { lists = [], itemsById = {} } = !!currentTarget && findForItemsOfWidget(currentTarget) || {}
|
|
60
|
-
const dataContext = generateDataContext(currentTarget)
|
|
64
|
+
const dataContext = untracked(()=>generateDataContext(currentTarget))
|
|
61
65
|
|
|
62
66
|
listeners.forEach(async l => {
|
|
63
67
|
let { data = {}, boundData = {} } = l;
|
|
@@ -221,7 +221,7 @@ function runFor(
|
|
|
221
221
|
clearTimeout(_FOR_ERROR_CACHE_MAP[nodeId]);
|
|
222
222
|
|
|
223
223
|
const $instance = ownerMpInst.getWeAppInst();
|
|
224
|
-
const dataContext = generateDataContext(defaultParent);
|
|
224
|
+
const dataContext = untracked(()=>generateDataContext(defaultParent));
|
|
225
225
|
|
|
226
226
|
forList = dataBinds[nodeId]._waFor.call(
|
|
227
227
|
$instance,
|
|
@@ -364,7 +364,7 @@ function setUpWidgetDataBinds(w, dataBinds, forItems, failedBinds, ctx) {
|
|
|
364
364
|
try {
|
|
365
365
|
clearTimeout(timer);
|
|
366
366
|
|
|
367
|
-
const dataContext = generateDataContext(w);
|
|
367
|
+
const dataContext = untracked(()=>generateDataContext(w));
|
|
368
368
|
|
|
369
369
|
// Computed data bind in the next tick since data bind may read widgets data
|
|
370
370
|
const value = dataBinds[prop].call(ctx, ctx, forItems.lists, forItems.itemsById, undefined, dataContext);
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* 使用方法
|
|
3
|
+
const wxReportSdk = require('./components/gsd-lib/report/index.js');
|
|
4
|
+
new wxReportSdk({
|
|
5
|
+
reportUrl:'http://www.qq.com',
|
|
6
|
+
})
|
|
7
|
+
*/
|
|
8
|
+
export default class wxReportSdk {
|
|
9
|
+
constructor (opt) {
|
|
10
|
+
this.originPage = Page;
|
|
11
|
+
this.originApp = App;
|
|
12
|
+
this.logTimer = null;
|
|
13
|
+
this.idxKey = '_monitor_idx';
|
|
14
|
+
this.config = {
|
|
15
|
+
mp_appid: '', // 填入小程序的appid
|
|
16
|
+
appKey: '', // 填入你的应用key
|
|
17
|
+
stopReport: false, // 停止上报
|
|
18
|
+
isNet: true, // 是否上报网络信息(默认:true)
|
|
19
|
+
isSys: true, // 是否上报系统信息(默认:true)
|
|
20
|
+
isError: true, // 是否开启错误上报 (默认:false)
|
|
21
|
+
autoReportPV: false, // 是否自动上报页面PV
|
|
22
|
+
commonPageEId: 'MP_ALLPAGES_ONSHOW', // 统一的页面上报标志
|
|
23
|
+
getRemoteParamsUrl: '',// 获取远程参数url
|
|
24
|
+
reportUrl: '', // 上报url
|
|
25
|
+
intervalTime: 3, // 间隔多久执行一次上报,默认3秒
|
|
26
|
+
reportLogsNum: 5, // 每次合并上报记录条数,默认5次
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
this.reportData = {
|
|
30
|
+
ky: '',//app key,应用的身份标识
|
|
31
|
+
pf: 'MiniProgram',// 平台类型
|
|
32
|
+
id: '',// 平台型相关的ID字段,如微信平台中则是open_id
|
|
33
|
+
cui: '',// custom user id,自定义用户id,用户上报的自定义用户id,也就是app业务方统计用户的身份标识,用于多平台帐号打通。
|
|
34
|
+
geo: '',// 地理位置
|
|
35
|
+
scene: '', // 入口场景,小程序的场景值
|
|
36
|
+
ev: {
|
|
37
|
+
'cn': '',//connect type,设备连接方式
|
|
38
|
+
'lg': '',//anguage,系统语言类型
|
|
39
|
+
'sr': '',//screen resolution,屏幕分辨率
|
|
40
|
+
'tz': '',//time zone,系统的时区
|
|
41
|
+
'os': '',//操作系统,
|
|
42
|
+
'ua': '-', //
|
|
43
|
+
},
|
|
44
|
+
ui: '',// 一个随机生成的id,因为大多数没有id,cui,所以用ui计算uv
|
|
45
|
+
si: '',//session id,会话id,一串随机产生的数字,标识一个新的会话
|
|
46
|
+
ts: '',//timestamp,时间戳
|
|
47
|
+
pi: '',// page id,页面id
|
|
48
|
+
rf: '',// refer page id,来源页面id
|
|
49
|
+
et: '1',// eventtype,事件类型,PAGE_VIEW(1),PAGE_HIDE(3001),SESSION_ENV(2),ERROR(3),CUSTOM(1000),ADDITION(1001),MONITOR_STAT(1002);SPECIAL_CUSTON(),小程序onshow使用PAGE_VIEW,关闭或隐藏时使用PAGE_HIDE,事件使用1000
|
|
50
|
+
ht: '',// hot tag string 屏幕的点击事件ID
|
|
51
|
+
htx: '',// hot tag x string 点击位置的X坐标
|
|
52
|
+
hty: '',// hot tag y string 点击位置的Y坐标
|
|
53
|
+
ei: '',// event id,自定义事件id string 自定义事件id
|
|
54
|
+
kv: '',// Key-Value,自定义事件Key-Value参数对 map JSON格式
|
|
55
|
+
er: '',// error,错误、异常信息 string 错误字符串或堆栈异常信息
|
|
56
|
+
ea: '',//error attribute uint 共有4种错误类型:USER_MSG(0)、USER_EXCEPTION(1)、AUTO_EXCEPTION(2)、NATIVE_CRASH(3)、SDK_EXCEPTION(99)
|
|
57
|
+
ext: '',//扩展字段,不进行计算,可存储更细的用户信息
|
|
58
|
+
region: '', // 城市码
|
|
59
|
+
mp_appid: '', // 小程序appid
|
|
60
|
+
adt: "", // 自定义渠道来源
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
this.config = Object.assign(this.config, opt || {});
|
|
64
|
+
this.reportLogs = [];
|
|
65
|
+
this.pagePrams = {};//存储每个页面自定义上报的数据,例如kv
|
|
66
|
+
this.cusSid = this._getCusSid();
|
|
67
|
+
this._init();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 获取自定义session
|
|
71
|
+
_getCusSid(len = 10) {
|
|
72
|
+
const $chars = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz123456789";
|
|
73
|
+
const maxPos = $chars.length;
|
|
74
|
+
let pwd = "";
|
|
75
|
+
for (let i = 0; i < len; i++) {
|
|
76
|
+
pwd = pwd + $chars.charAt(Math.floor(Math.random() * maxPos));
|
|
77
|
+
}
|
|
78
|
+
return pwd + new Date().getTime();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 获取用户唯一标示
|
|
82
|
+
_getUuid () {
|
|
83
|
+
let uuidKey = "_mp_monitor_uuid_v2";
|
|
84
|
+
let uuid = wx.getStorageSync(uuidKey);
|
|
85
|
+
if (uuid) {
|
|
86
|
+
return uuid;
|
|
87
|
+
}
|
|
88
|
+
let s = [];
|
|
89
|
+
let hexDigits = '0123456789abcdef';
|
|
90
|
+
for (let i = 0; i < 36; i++) {
|
|
91
|
+
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
|
|
92
|
+
}
|
|
93
|
+
s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
|
|
94
|
+
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
|
95
|
+
s[8] = s[13] = s[18] = s[23] = '-';
|
|
96
|
+
uuid = "mc_" + s.join('');
|
|
97
|
+
wx.setStorageSync(uuidKey, uuid);
|
|
98
|
+
return uuid;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
startReport () {
|
|
102
|
+
if (this.config.stopReport || !this._isAllowReport()) return;
|
|
103
|
+
const _this = this;
|
|
104
|
+
_this._logRequest();
|
|
105
|
+
_this.logTimer = setInterval(function () {
|
|
106
|
+
_this._logRequest();
|
|
107
|
+
}, _this.config.intervalTime * 1000);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/*点击流上报
|
|
111
|
+
* eid 事件id
|
|
112
|
+
* kv Key-Value,自定义事件Key-Value参数对
|
|
113
|
+
* event 事件对象
|
|
114
|
+
* */
|
|
115
|
+
eventClick (eid, params = {}, event) {
|
|
116
|
+
let cookiedObj = {};
|
|
117
|
+
// 兼容老版本事项直接传入kv值
|
|
118
|
+
if (eid === 'MP_SHIXIANG' && !params.kv) {
|
|
119
|
+
cookiedObj.kv = params;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
cookiedObj = params;
|
|
123
|
+
}
|
|
124
|
+
this._statpid(Object.assign({
|
|
125
|
+
et: '1000',// eventtype 事件使用1000
|
|
126
|
+
ei: eid, // 事件id
|
|
127
|
+
htx: event ? event.detail.x : '',
|
|
128
|
+
hty: event ? event.detail.y : '',
|
|
129
|
+
ht: event ? event.target.id : '',// hot tag string 屏幕的点击事件ID
|
|
130
|
+
}, cookiedObj));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
logInfo (msg, params = {}) {
|
|
134
|
+
params.type = 'info';
|
|
135
|
+
params.msg = msg;
|
|
136
|
+
this._logReport(params);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
logWarn (msg, params = {}) {
|
|
140
|
+
params.type = 'warn';
|
|
141
|
+
params.msg = msg;
|
|
142
|
+
this._logReport(params);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
logError (msg, params = {}) {
|
|
146
|
+
params.type = 'error';
|
|
147
|
+
params.msg = msg;
|
|
148
|
+
this._logReport(params);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// 日志上报
|
|
152
|
+
_logReport (params = {}) {
|
|
153
|
+
let cookiedObj = { kv: params };
|
|
154
|
+
this._statpid(Object.assign({
|
|
155
|
+
et: '2000',//
|
|
156
|
+
}, cookiedObj));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/*页面pv上报
|
|
160
|
+
* pageId 页面标识id
|
|
161
|
+
* params 额外参数,比如城市码
|
|
162
|
+
* */
|
|
163
|
+
pagePV (pageId, params = {}) {
|
|
164
|
+
this._statpid(Object.assign({
|
|
165
|
+
et: '3001',// eventtype,事件类型,PAGE_VIEW(1),PAGE_HIDE(3001),SESSION_ENV(2),ERROR(3),CUSTOM(1000),ADDITION(1001),MONITOR_STAT(1002);SPECIAL_CUSTON(),小程序onshow使用PAGE_VIEW,关闭或隐藏时使用PAGE_HIDE,事件使用1000å
|
|
166
|
+
ei: pageId, // 事件id
|
|
167
|
+
}, params));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// 设置页面参数
|
|
171
|
+
setPagePrams (params) {
|
|
172
|
+
let pagePath = this._getPagePath();
|
|
173
|
+
if (pagePath && params) {
|
|
174
|
+
this.pagePrams[pagePath] = params;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 是否允许上报
|
|
179
|
+
_isAllowReport () {
|
|
180
|
+
if (!this.config.reportUrl || !this.config.appKey) {
|
|
181
|
+
console.error('reportUrl、appKey,存在没传的参数,不允许上报');
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
_init () {
|
|
188
|
+
if (this.config.stopReport || !this._isAllowReport()) return;
|
|
189
|
+
this._spyApp();
|
|
190
|
+
this._spyPage();
|
|
191
|
+
if (this.config.isNet) this._network();
|
|
192
|
+
if (this.config.isSys) this._system();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// 包装App对象
|
|
196
|
+
_spyApp () {
|
|
197
|
+
const _this = this;
|
|
198
|
+
App = (app) => {
|
|
199
|
+
const _onError = app.onError || function () { };
|
|
200
|
+
const _onLaunch = app.onLaunch || function () { };
|
|
201
|
+
const _onHide = app.onHide || function () { };
|
|
202
|
+
app.onLaunch = function (opt) {
|
|
203
|
+
_this.reportData.adt = opt.query.ysschannel || '';
|
|
204
|
+
// _this.reportData.mp_appid = opt.referrerInfo &&
|
|
205
|
+
// opt.referrerInfo.appId ||
|
|
206
|
+
// '';
|
|
207
|
+
_this.reportData.sense = opt.scene;
|
|
208
|
+
wx.setStorageSync(_this.idxKey, 1);
|
|
209
|
+
if (_this.config.getRemoteParamsUrl) {
|
|
210
|
+
wx.request({
|
|
211
|
+
url: _this.config.getRemoteParamsUrl,
|
|
212
|
+
data: {},
|
|
213
|
+
}).then((res) => {
|
|
214
|
+
if (res.open) {
|
|
215
|
+
_this.config = Object.assign(_this.config,
|
|
216
|
+
{
|
|
217
|
+
intervalTime: res.sec || _this.config.intervalTime,
|
|
218
|
+
reportLogsNum: res.num || _this.config.reportLogsNum,
|
|
219
|
+
stopReport: !!res.stop,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
return _onLaunch.apply(this, arguments);
|
|
225
|
+
};
|
|
226
|
+
if (this.config.isError) {
|
|
227
|
+
// 错误捕获并上报
|
|
228
|
+
app.onError = function (err) {
|
|
229
|
+
let errspit = err.split(/\n/) || [];
|
|
230
|
+
let src, col, line;
|
|
231
|
+
let errs = err.match(/\(.+?\)/);
|
|
232
|
+
if (errs && errs.length) errs = errs[0];
|
|
233
|
+
errs = (errs || '').replace(/\w.+js/g, $1 => {
|
|
234
|
+
src = $1;
|
|
235
|
+
return '';
|
|
236
|
+
});
|
|
237
|
+
errs = errs.split(':');
|
|
238
|
+
if (errs && errs.length > 1) line = parseInt(errs[1] || 0);
|
|
239
|
+
col = parseInt(errs[2] || 0);
|
|
240
|
+
_this._reportError(JSON.stringify({
|
|
241
|
+
col: col,
|
|
242
|
+
line: line,
|
|
243
|
+
name: src,
|
|
244
|
+
msg: `${errspit[0]};${errspit[1]};${errspit[2]};`,
|
|
245
|
+
type: 'js',
|
|
246
|
+
}));
|
|
247
|
+
return _onError.apply(this, arguments);
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
app.onHide = function () {
|
|
251
|
+
if (_this.logTimer) {
|
|
252
|
+
clearInterval(_this.logTimer);
|
|
253
|
+
}
|
|
254
|
+
_this._logRequest(true);
|
|
255
|
+
return _onHide.apply(this, arguments);
|
|
256
|
+
};
|
|
257
|
+
_this.originApp(app);
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
_wrapPagePV (pageOnShowTime) {
|
|
262
|
+
const _this = this;
|
|
263
|
+
if (_this.config.autoReportPV) {
|
|
264
|
+
_this.pagePV(_this.config.commonPageEId,
|
|
265
|
+
{ du: Math.ceil((Date.now() - pageOnShowTime) / 1000) });
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// 包装page对象
|
|
270
|
+
_spyPage () {
|
|
271
|
+
const _this = this;
|
|
272
|
+
Page = (page) => {
|
|
273
|
+
const _onShow = page.onShow || function () { };
|
|
274
|
+
const _onHide = page.onHide || function () { };
|
|
275
|
+
const _onUnload = page.onUnload || function () { };
|
|
276
|
+
let pageOnShowTime = 0;
|
|
277
|
+
page.onShow = function () {
|
|
278
|
+
pageOnShowTime = Date.now();
|
|
279
|
+
if (_this.config.autoReportPV) {
|
|
280
|
+
_this.pagePV(_this.config.commonPageEId, { et: '1' });
|
|
281
|
+
}
|
|
282
|
+
return _onShow.apply(this, arguments);
|
|
283
|
+
};
|
|
284
|
+
page.onHide = function () {
|
|
285
|
+
_this._wrapPagePV(pageOnShowTime);
|
|
286
|
+
return _onHide.apply(this, arguments);
|
|
287
|
+
};
|
|
288
|
+
page.onUnload = function () {
|
|
289
|
+
_this._wrapPagePV(pageOnShowTime);
|
|
290
|
+
return _onUnload.apply(this, arguments);
|
|
291
|
+
};
|
|
292
|
+
_this.originPage(page);
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
Component = (component) => {
|
|
296
|
+
if (component._componentType === 'page') {
|
|
297
|
+
const _this = this
|
|
298
|
+
const _onShow = component.pageLifetimes.show || function() { }
|
|
299
|
+
const _onHide = component.pageLifetimes.hide || function() { }
|
|
300
|
+
let pageOnShowTime = 0
|
|
301
|
+
component.pageLifetimes.show = function() {
|
|
302
|
+
pageOnShowTime = Date.now()
|
|
303
|
+
if (_this.config.autoReportPV) {
|
|
304
|
+
_this.pagePV(_this.config.commonPageEId, { et: '1' })
|
|
305
|
+
}
|
|
306
|
+
return _onShow.apply(this, arguments)
|
|
307
|
+
}
|
|
308
|
+
component.pageLifetimes.hide = function() {
|
|
309
|
+
_this._wrapPagePV(pageOnShowTime)
|
|
310
|
+
return _onHide.apply(this, arguments)
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
_this.originComponent(component)
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// 集中收集 logs 方法
|
|
318
|
+
// type = 'memory' | 'storage'
|
|
319
|
+
_collectLogs (item) {
|
|
320
|
+
let nData = [];
|
|
321
|
+
let oData = this.reportLogs;
|
|
322
|
+
Array.isArray(item) ? nData = item : nData.push(item);
|
|
323
|
+
// 剔除掉无值的字段,减少体积
|
|
324
|
+
nData.forEach(tempItem => {
|
|
325
|
+
for (let tempKey in tempItem) {
|
|
326
|
+
let tempVal = tempItem[tempKey];
|
|
327
|
+
if (tempVal === '' ||
|
|
328
|
+
(typeof tempVal === 'object' && Object.keys(tempVal).length === 0)) {
|
|
329
|
+
delete tempItem[tempKey];
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
// 内存不能超过 100 条
|
|
334
|
+
let rule = oData.length > 100;
|
|
335
|
+
if (rule) {
|
|
336
|
+
oData.splice(0, nData.length);
|
|
337
|
+
}
|
|
338
|
+
this.reportLogs = oData.concat(nData);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// 获取页面路径
|
|
342
|
+
_getPagePath () {
|
|
343
|
+
let currentPages = getCurrentPages();
|
|
344
|
+
if (currentPages && currentPages.length) {
|
|
345
|
+
const length = currentPages.length;
|
|
346
|
+
const lastpage = currentPages[length - 1];
|
|
347
|
+
return lastpage.__route__;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
return '';
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// 埋点上报
|
|
355
|
+
_statpid (opt) {
|
|
356
|
+
let currentPages = getCurrentPages();
|
|
357
|
+
if (currentPages && currentPages.length) {
|
|
358
|
+
const length = currentPages.length;
|
|
359
|
+
const lastpage = currentPages[length - 1];
|
|
360
|
+
opt.pi = lastpage.__route__;
|
|
361
|
+
if (length >= 2) {
|
|
362
|
+
opt.rf = currentPages[length - 2].__route__;
|
|
363
|
+
}
|
|
364
|
+
opt.ext = lastpage.options || {};
|
|
365
|
+
// 合并用户传入的自定义参数
|
|
366
|
+
opt = Object.assign(opt, this.pagePrams[opt.pi]);
|
|
367
|
+
}
|
|
368
|
+
let idx = Number(wx.getStorageSync(this.idxKey) || '0') + 1;
|
|
369
|
+
wx.setStorageSync(this.idxKey, idx);
|
|
370
|
+
opt.idx = idx;
|
|
371
|
+
const _statpid2 = this._getCookiedReportData(opt);
|
|
372
|
+
this._collectLogs(_statpid2);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/*错误上报
|
|
376
|
+
* desc 错误信息
|
|
377
|
+
* */
|
|
378
|
+
_reportError (desc) {
|
|
379
|
+
this._logReport({ type: 'error', msg: desc });
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
_getCookiedReportData (opt) {
|
|
383
|
+
const realUserId = wx.getStorageSync('wx-openid') || wx.getStorageSync('tif-openid') ||
|
|
384
|
+
wx.getStorageSync('openid') || opt.openid || this._getUuid();
|
|
385
|
+
return Object.assign({}, this.reportData, {
|
|
386
|
+
ts: Date.now(),//timestamp,时间戳
|
|
387
|
+
ky: this.config.appKey, // app key,应用的身份标识
|
|
388
|
+
si: wx.getStorageSync('wx-sessionid') || wx.getStorageSync('tif-sid') || this.cusSid,
|
|
389
|
+
id: realUserId, // 平台型相关的ID字段,如微信平台中则是open_id
|
|
390
|
+
cui: realUserId, // custom user
|
|
391
|
+
ui: wx.getStorageSync('tif-unionid') || realUserId, // id,自定义用户id,用户上报的自定义用户id,也就是app业务方统计用户的身份标识,用于多平台帐号打通。
|
|
392
|
+
region: wx.getStorageSync('reportRegion') || '',
|
|
393
|
+
mp_appid: this.config.mp_appid || '',
|
|
394
|
+
}, opt);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/*
|
|
398
|
+
* cycle:是否循环上报
|
|
399
|
+
* */
|
|
400
|
+
_logRequest (cycle = false) {
|
|
401
|
+
// 过滤掉开发者工具、测试环境的logs
|
|
402
|
+
let _this = this;
|
|
403
|
+
// 停止上报
|
|
404
|
+
if (_this.config.stopReport) return;
|
|
405
|
+
const reportLogs = _this.reportLogs;
|
|
406
|
+
if (reportLogs.length === 0) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
let data = reportLogs.splice(0, _this.config.reportLogsNum);
|
|
410
|
+
let sessionid = wx.getStorageSync('wx-sessionid') || wx.getStorageSync('tif-sid')
|
|
411
|
+
wx.request({
|
|
412
|
+
url: _this.config.reportUrl,
|
|
413
|
+
header: {
|
|
414
|
+
'x-tif-sid': sessionid,
|
|
415
|
+
'x-tif-did': wx.getStorageSync('tif-did'),
|
|
416
|
+
'wx-sessionid': sessionid,
|
|
417
|
+
'content-type': 'application/x-www-form-urlencoded',
|
|
418
|
+
},
|
|
419
|
+
data: {reportInfo: JSON.stringify(data)},
|
|
420
|
+
method: 'POST',
|
|
421
|
+
complete (res) {
|
|
422
|
+
if (cycle && res.data && Number(res.data.errcode) === 0 &&
|
|
423
|
+
reportLogs.length > 0) {
|
|
424
|
+
_this._logRequest(true);
|
|
425
|
+
}
|
|
426
|
+
if (res.data && (Number(res.data.errcode) !== 0)) {
|
|
427
|
+
if (data && data.length !== 0) {
|
|
428
|
+
_this._collectLogs(data);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// 获取网络类型
|
|
436
|
+
_network () {
|
|
437
|
+
wx.getNetworkType({
|
|
438
|
+
success: res => {
|
|
439
|
+
this.reportData.ev.cn = res.networkType;//connect type,设备连接方式
|
|
440
|
+
},
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// 获取系统信息
|
|
445
|
+
_system () {
|
|
446
|
+
wx.getSystemInfo({
|
|
447
|
+
success: res => {
|
|
448
|
+
this.reportData.ev = {
|
|
449
|
+
'lg': res.language,//anguage,系统语言类型
|
|
450
|
+
'sr': res.screenWidth + '*' + res.screenHeight,//screen resolution,屏幕分辨率
|
|
451
|
+
'tz': new Date().getTimezoneOffset(),//time zone,系统的时区
|
|
452
|
+
'os': res.system,//操作系统,
|
|
453
|
+
'version': res.version,//微信版本号
|
|
454
|
+
'SDKVersion': res.SDKVersion,//客户端基础库版本
|
|
455
|
+
'ua': `oa=${res.system},mp_version=${res.version},mp_sdk=${res.SDKVersion}`,
|
|
456
|
+
};
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
}
|
package/template/mp/package.json
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
"name": "lcap-<%= appId%>",
|
|
3
3
|
"version": "1.0.8",
|
|
4
4
|
"scripts": {},
|
|
5
|
-
"dependencies": {
|
|
6
|
-
"@cloudbase/js-sdk": "2.5.2-beta.0",<% } %>
|
|
7
|
-
"@cloudbase/oauth": "0.1.1-alpha.5",
|
|
5
|
+
"dependencies": {
|
|
8
6
|
"@cloudbase/weda-client": "0.2.25",
|
|
9
|
-
"@cloudbase/weda-cloud-sdk": "1.0.
|
|
7
|
+
"@cloudbase/weda-cloud-sdk": "1.0.19",
|
|
8
|
+
"@cloudbase/oauth": "0.1.1-alpha.5",
|
|
10
9
|
"mobx": "^5.15.4",
|
|
11
10
|
"lodash.get": "^4.4.2",
|
|
12
11
|
"lodash.set": "^4.3.2",
|
|
13
12
|
"miniprogram-gesture": "^1.0.6",
|
|
14
13
|
"miniprogram-api-promise": "^1.0.4"<% Object.keys(extraDeps).map(depName => {%>,
|
|
15
|
-
|
|
16
|
-
})
|
|
14
|
+
"<%= depName%>": "<%= extraDeps[depName]%>"<%
|
|
15
|
+
})
|
|
16
|
+
%>
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
package/template/package.json
CHANGED