@cloudbase/framework-plugin-low-code 0.7.24 → 1.0.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/lib/generate.d.ts +1 -2
- package/lib/generate.d.ts.map +1 -1
- package/lib/generate.js +4 -5
- package/lib/index.d.ts +4 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +78 -125
- package/lib/utils/dataSource.d.ts +0 -4
- package/lib/utils/dataSource.d.ts.map +1 -1
- package/lib/utils/dataSource.js +12 -27
- package/lib/utils/postProcess.d.ts.map +1 -1
- package/package.json +4 -3
- package/template/html/index.html.ejs +1 -1
- package/template/mp/app/app-global.js +0 -4
- package/template/mp/app/common.js +0 -26
- package/template/mp/app/handlers.js +0 -15
- package/template/mp/app/weapps-api.js +0 -89
- package/template/mp/app.js +0 -114
- package/template/mp/app.json +0 -1
- package/template/mp/app.wxss +0 -15
- package/template/mp/common/data-patch-test.js +0 -60
- package/template/mp/common/data-patch.js +0 -44
- package/template/mp/common/merge-renderer.js +0 -67
- package/template/mp/common/process.js +0 -1
- package/template/mp/common/style.js +0 -34
- package/template/mp/common/url.js +0 -21
- package/template/mp/common/util.js +0 -395
- package/template/mp/common/utils.wxs +0 -11
- package/template/mp/common/weapp-component.js +0 -250
- package/template/mp/common/weapp-page.js +0 -204
- package/template/mp/common/weapp-sdk.js +0 -76
- package/template/mp/common/widget.js +0 -381
- package/template/mp/common/wx_yypt_report_v2.js +0 -460
- package/template/mp/component/index.js +0 -66
- package/template/mp/component/index.json +0 -4
- package/template/mp/component/index.wxml +0 -1
- package/template/mp/component/index.wxss +0 -1
- package/template/mp/datasources/config.js.tpl +0 -25
- package/template/mp/datasources/dataset-profiles.js.tpl +0 -5
- package/template/mp/datasources/datasource-profiles.js.tpl +0 -4
- package/template/mp/datasources/index.js +0 -31
- package/template/mp/package.json +0 -17
- package/template/mp/page/api.js +0 -1
- package/template/mp/page/index.js +0 -42
- package/template/mp/page/index.json +0 -3
- package/template/mp/page/index.wxml +0 -1
- package/template/mp/page/index.wxss +0 -3
- package/template/mp/project.config.json +0 -1
|
@@ -1,460 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { observable } from 'mobx';
|
|
2
|
-
import { createComponent } from '../../../common/weapp-component'
|
|
3
|
-
import { mpCompToWidget } from '../../../common/widget'
|
|
4
|
-
import { concatClassList, px2rpx } from '../../../common/style'
|
|
5
|
-
import app from '../../../common/weapp-sdk'
|
|
6
|
-
import index from './lowcode/index'
|
|
7
|
-
import lifeCycle from './lowcode/lifecycle'
|
|
8
|
-
import stateFn from './lowcode/state'
|
|
9
|
-
import computedFuncs from './lowcode/computed'
|
|
10
|
-
<% handlers.forEach(h => {%>
|
|
11
|
-
import _handler<%= h %> from './lowcode/handler/<%= h %>' <%}) %>
|
|
12
|
-
import * as constObj from '../libCommonRes/const'
|
|
13
|
-
import * as toolsObj from '../libCommonRes/tools'
|
|
14
|
-
|
|
15
|
-
const context = observable({});
|
|
16
|
-
|
|
17
|
-
const libCode = '<%= materialName %>'
|
|
18
|
-
|
|
19
|
-
const widgetProps = <%= stringifyObj(widgetProps, {depth: null}) %>
|
|
20
|
-
|
|
21
|
-
const evtListeners = {<% Object.entries(eventHandlers).map(([handlerName, listeners])=>{%>
|
|
22
|
-
<%= handlerName%>: [
|
|
23
|
-
<%listeners.map(l=> { %>{
|
|
24
|
-
key: '<%= l.key %>',
|
|
25
|
-
handler: <% if (l.type == 'rematch') {%> _handler<%= l.handler %> <%} else {%> <%= l.handler %> <%} %>,
|
|
26
|
-
data: <%= stringifyObj(l.data, {depth: null}) %>,
|
|
27
|
-
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':(lists, forItems, event, $context) => {const $for=forItems; return (
|
|
28
|
-
<%= expr === ''? 'undefined': expr %>
|
|
29
|
-
)},
|
|
30
|
-
<%}) %>}
|
|
31
|
-
},<%})%>
|
|
32
|
-
],<%})%>
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const behaviors = [<% if(formEvents) { %>'wx://form-field'<% } %>]
|
|
36
|
-
|
|
37
|
-
const properties = {<% Object.entries(propDefs).filter(([prop,def])=>{
|
|
38
|
-
return !!jsonSchemaType2jsClass[def.type]
|
|
39
|
-
}).map(([prop, def])=> {%>
|
|
40
|
-
<%= prop %>: {
|
|
41
|
-
type: <%= jsonSchemaType2jsClass[def.type] %>,<%if(def.extraTypes) { %>
|
|
42
|
-
optionalTypes: [<%= def.extraTypes.split('|').map(t => jsonSchemaType2jsClass[t]).join(',') %>], <% }%>
|
|
43
|
-
<%if(def.default != null) {%>value: <%= JSON.stringify(def.default) %><%}%>
|
|
44
|
-
},<%})%>
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const events = [<% emitEvents.map(evtName => {%>
|
|
48
|
-
{name: "<%= evtName %>", <% if(formEvents && formEvents[evtName]){%>getValueFromEvent: (event)=> <%= formEvents[evtName] %><%}%>},<%}) %>
|
|
49
|
-
]
|
|
50
|
-
|
|
51
|
-
const handler = {<% handlers.forEach(h => {%>
|
|
52
|
-
<%= h %>: _handler<%= h %>, <%}) %>
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
|
|
56
|
-
<%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
|
|
57
|
-
<%= prop %>: function (lists, forItems, event, $context) {const $for=forItems; return (
|
|
58
|
-
<%= expr === '' ? 'undefined': expr %>
|
|
59
|
-
); },<% }) %>
|
|
60
|
-
},<%}) %>
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const config = <%= JSON.stringify(config || {})%>
|
|
64
|
-
|
|
65
|
-
createComponent('<%= key %>', behaviors, properties, events, handler, dataBinds, evtListeners, widgetProps,
|
|
66
|
-
index, lifeCycle, stateFn, computedFuncs, config, { const: constObj, tools: toolsObj }, libCode, context)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= content %>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import './lowcode/style.wxss';
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import datasetProfiles from './dataset-profiles'
|
|
2
|
-
const dataSourceProfiles = require('./datasource-profiles.js')
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 数据源基本配置
|
|
6
|
-
*/
|
|
7
|
-
export default {
|
|
8
|
-
/** 当前是否处于正式发布模式 */
|
|
9
|
-
isProd: <%= isProd %>,
|
|
10
|
-
/** 低码应用ID */
|
|
11
|
-
appID: '<%= appID %>',
|
|
12
|
-
/** 云开发环境ID */
|
|
13
|
-
envID: '<%= envID %>',
|
|
14
|
-
/** 应用端ID */
|
|
15
|
-
tcbClientId: '<%= clientID %>',
|
|
16
|
-
/** 云开发资源所属的微信app id */
|
|
17
|
-
resourceAppid: '<%= resourceAppid %>',
|
|
18
|
-
/** 数据源描述对象数组 */
|
|
19
|
-
dataSourceProfiles: dataSourceProfiles,
|
|
20
|
-
/**
|
|
21
|
-
* 新的dataset变量配置对象
|
|
22
|
-
* key 为页面ID(全局为$global), val 为变量配置数组
|
|
23
|
-
*/
|
|
24
|
-
datasetProfiles: datasetProfiles,
|
|
25
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { _WEDA_CLOUD_SDK as WEDA_CLOUD_SDK, auth} from '@cloudbase/weda-client'
|
|
2
|
-
const {
|
|
3
|
-
setConfig,
|
|
4
|
-
initTcb,
|
|
5
|
-
CLOUD_SDK,
|
|
6
|
-
createDataset,
|
|
7
|
-
createStateDataSourceVar,
|
|
8
|
-
generateParamsParser,
|
|
9
|
-
EXTRA_API,
|
|
10
|
-
DS_API,
|
|
11
|
-
DS_SDK,
|
|
12
|
-
} = WEDA_CLOUD_SDK
|
|
13
|
-
const getAccessToken = auth.getAccessToken
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
createDataset,
|
|
17
|
-
createStateDataSourceVar,
|
|
18
|
-
generateParamsParser,
|
|
19
|
-
EXTRA_API,
|
|
20
|
-
CLOUD_SDK,
|
|
21
|
-
DS_API,
|
|
22
|
-
DS_SDK,
|
|
23
|
-
setConfig,
|
|
24
|
-
getAccessToken,
|
|
25
|
-
initTcb,
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
import config from './config'
|
|
29
|
-
|
|
30
|
-
setConfig(config)
|
|
31
|
-
initTcb()
|
package/template/mp/package.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "lcap-<%= appId%>",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"scripts": {},
|
|
5
|
-
"dependencies": {
|
|
6
|
-
"@cloudbase/weda-client": "0.2.15",
|
|
7
|
-
"@cloudbase/oauth": "0.1.1-alpha.5",
|
|
8
|
-
"mobx": "^5.15.4",
|
|
9
|
-
"lodash.get": "^4.4.2",
|
|
10
|
-
"lodash.set": "^4.3.2",
|
|
11
|
-
"miniprogram-gesture": "^1.0.6",
|
|
12
|
-
"miniprogram-api-promise": "^1.0.4"<% Object.keys(extraDeps).map(depName => {%>,
|
|
13
|
-
"<%= depName%>": "<%= extraDeps[depName]%>"<%
|
|
14
|
-
})
|
|
15
|
-
%>
|
|
16
|
-
}
|
|
17
|
-
}
|
package/template/mp/page/api.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const $page = {}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { observable } from 'mobx';
|
|
2
|
-
import { createPage } from '<%= subLevelPath %>../../common/weapp-page'
|
|
3
|
-
import { mpCompToWidget } from '<%= subLevelPath %>../../common/widget'
|
|
4
|
-
import { concatClassList, px2rpx } from '<%= subLevelPath %>../../common/style'
|
|
5
|
-
import { app } from '<%= subLevelPath %>../../app/weapps-api'
|
|
6
|
-
import { $page } from './api'
|
|
7
|
-
import { <%= pageName %> as handlers } from '../../app/handlers'
|
|
8
|
-
import lifecyle from '../../lowcode/<%= pageName %>/lifecycle'
|
|
9
|
-
import state from '../../lowcode/<%= pageName %>/state'
|
|
10
|
-
import computed from '../../lowcode/<%= pageName %>/computed'
|
|
11
|
-
|
|
12
|
-
const context = observable({});
|
|
13
|
-
|
|
14
|
-
const widgetProps = <%= stringifyObj(widgetProps, {depth: null}) %>
|
|
15
|
-
/** widget event listeners **/
|
|
16
|
-
const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listeners])=>{%>
|
|
17
|
-
<%= handlerName%>: [
|
|
18
|
-
<%listeners.map(l=> { %>{
|
|
19
|
-
key: '<%= l.key %>',
|
|
20
|
-
handler: <% if (l.type === 'rematch') {%> handlers.<%= l.handler %> <%} else if (l.type == 'material') {%> function(...args) { return require('../../materials/<%= l.handlerModule %>/actions/<%= l.handler %>/index').default(...args) } <%} else {%> <%= l.handler %> <%} %>,
|
|
21
|
-
data: <%= stringifyObj(l.data, {depth: null}) %>,
|
|
22
|
-
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':(lists, forItems, event, $context) => {const $for = forItems; return (
|
|
23
|
-
<%= expr === '' ? 'undefined': expr %>
|
|
24
|
-
)},
|
|
25
|
-
<%}) %>}
|
|
26
|
-
},<%})%>
|
|
27
|
-
],<%})%>
|
|
28
|
-
}
|
|
29
|
-
const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
|
|
30
|
-
<%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
|
|
31
|
-
<%= prop %>: function (lists, forItems, event, $context) {const $for = forItems; return (
|
|
32
|
-
<%= expr === '' ? 'undefined': expr %>
|
|
33
|
-
); },<% }) %>
|
|
34
|
-
},<%}) %>
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const pageAttributes = <%= pageAttributes?JSON.stringify(pageAttributes):'{}' %>
|
|
38
|
-
|
|
39
|
-
$page.id = '<%= pageName %>'
|
|
40
|
-
$page.uuid = '<%= pageUUID %>'
|
|
41
|
-
$page.handler = handlers
|
|
42
|
-
createPage(lifecyle, widgetProps, state, computed, evtListeners, dataBinds, app, $page, context,pageAttributes)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= content %>
|