@cloudbase/lowcode-builder 1.8.106 → 1.8.108

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.
Files changed (48) hide show
  1. package/lib/builder/config/dependencies.d.ts +10 -0
  2. package/lib/builder/config/dependencies.js +46 -0
  3. package/lib/builder/config/index.d.ts +1 -0
  4. package/lib/builder/config/index.js +5 -3
  5. package/lib/builder/core/index.d.ts +1 -1
  6. package/lib/builder/core/index.js +13 -13
  7. package/lib/builder/h5/generate.js +1 -0
  8. package/lib/builder/mp/BuildContext.d.ts +1 -0
  9. package/lib/builder/mp/index.d.ts +1 -2
  10. package/lib/builder/mp/index.js +13 -38
  11. package/lib/builder/mp/lowcode.js +5 -1
  12. package/lib/builder/mp/materials.d.ts +2 -3
  13. package/lib/builder/mp/materials.js +28 -26
  14. package/lib/builder/mp/mp_config.js +2 -1
  15. package/lib/builder/mp/util.d.ts +5 -2
  16. package/lib/builder/mp/util.js +14 -6
  17. package/lib/builder/mp/wxml.d.ts +3 -1
  18. package/lib/builder/mp/wxml.js +20 -7
  19. package/lib/builder.web.js +8 -8
  20. package/package.json +4 -4
  21. package/template/html/index.html.ejs +4 -2
  22. package/template/mp/app/common.js +0 -2
  23. package/template/mp/app/weapps-api.js +1 -20
  24. package/template/mp/common/info/index.js +4 -2
  25. package/template/mp/common/util.js +33 -774
  26. package/template/mp/common/weapp-page.js +12 -514
  27. package/template/mp/component/index.js +52 -19
  28. package/template/mp/component/index.json +1 -1
  29. package/template/mp/datasources/index.js.tpl +3 -99
  30. package/template/mp/package.json +4 -15
  31. package/template/mp/packages/$wd_system/pages/login/index.json +1 -1
  32. package/template/mp/packages/$wd_system/pages/login/methods/loginByWXPhone.js +6 -3
  33. package/template/mp/page/index.js +1 -2
  34. package/template/mp/common/constant.js +0 -1
  35. package/template/mp/common/data-patch-test.js +0 -60
  36. package/template/mp/common/data-patch.js +0 -66
  37. package/template/mp/common/event-emitter.js +0 -124
  38. package/template/mp/common/flow.js +0 -65
  39. package/template/mp/common/merge-renderer.js +0 -75
  40. package/template/mp/common/placeholder/index.js +0 -1
  41. package/template/mp/common/placeholder/index.json +0 -4
  42. package/template/mp/common/placeholder/index.wxml +0 -1
  43. package/template/mp/common/placeholder/index.wxss +0 -1
  44. package/template/mp/common/query.js +0 -300
  45. package/template/mp/common/style.js +0 -34
  46. package/template/mp/common/watch.js +0 -70
  47. package/template/mp/common/weapp-component.js +0 -289
  48. package/template/mp/common/widget.js +0 -872
@@ -1,13 +1,7 @@
1
- import { auth, getWedaAPI } from '@cloudbase/weda-client'
2
- import { redirectToLogin, findLoginPage, getAuthConfig, checkAnonymous } from '../common/util';
3
- import { setConfig, initTcb } from '../common/cloud-sdk';
4
-
5
- const getAccessToken = auth.getAccessToken
6
- const loginScope = auth.loginScope
7
-
1
+ import { auth, getWedaAPI, app as clientApp } from '@cloudbase/weda-client'
8
2
  import { default as config, AEGIS_CONFIG } from './config'
9
3
 
10
- setConfig({
4
+ clientApp.init({
11
5
  ...config,
12
6
  // 设置数据源请求的 loading 及 toast 处理
13
7
  beforeDSRequest: (cfg) => {
@@ -15,42 +9,6 @@ setConfig({
15
9
  if (!cfg.options || !cfg.options.showLoading) return;
16
10
  app.showLoading();
17
11
  },
18
- beforeCallFunction: async (params) => {
19
- const { app } = getWedaAPI();
20
- try {
21
- const loginPage = findLoginPage();
22
-
23
- let skip = false;
24
- switch (params?.data?.methodName) {
25
- case 'callWedaApi': {
26
- if (['GetMiniProgramUserTicket', 'DescribeRuntimeResourceStrategy'].includes(params?.data?.params.action)) {
27
- skip = true;
28
- }
29
- break;
30
- }
31
- }
32
-
33
- // 后续做过滤处理
34
- const endpointType = app?.__internal__?.getCloudSdkConfig('endpointType');
35
- if ((params?.data?.mode === 'c' && skip) || (endpointType !== 'tcb-api' && !loginPage)) {
36
- return params;
37
- }
38
- // await initTcb();
39
- const { accessToken } = await getAccessToken();
40
- if (accessToken) {
41
- params.data.accessToken = accessToken;
42
- }
43
- } catch (e) {
44
- if (app?.cloud?.currentUser?.userType === 'externalUser' && e?.error === 'unauthenticated') {
45
- app.showToast({
46
- title: '登录态失效',
47
- icon: 'error',
48
- });
49
- }
50
- // console.error('beforeCallFunction error', e);
51
- }
52
- return params;
53
- },
54
12
  afterDSRequest: (cfg, error, result) => {
55
13
  const { app } = getWedaAPI();
56
14
  if (!cfg.options) return;
@@ -59,61 +17,7 @@ setConfig({
59
17
  const isSuccess = !error && result && !result.code;
60
18
  app.showToast({ icon: isSuccess ? 'success' : 'error' });
61
19
  },
62
- async afterCallFunction(params, error, res) {
63
- const { app } = getWedaAPI();
64
- let oauthError =
65
- error?.message?.includes?.('PERMISSION_DENIED') ||
66
- error?.code === 'unauthenticated' ||
67
- error?.error === 'unauthenticated' ||
68
- error?.code === 'invalid_grant' ||
69
- error?.error === 'invalid_grant' ||
70
- error?.code === 'INVALID_ACCESS_TOKEN';
71
-
72
- if (!oauthError) {
73
- try {
74
- /**
75
- * js-sdk v2 实现上吞了所有错误
76
- * 返回 new Error(JSON.stringify({code: "OPERATION_FAIL", msg:"[INVALID_ACCESS_TOKEN]XXX"}))
77
- */
78
- let tcbErrorObj = JSON.parse(error.message);
79
- if (tcbErrorObj?.code === 'OPERATION_FAIL' && /\[INVALID_ACCESS_TOKEN\]/.test(tcbErrorObj.msg)) {
80
- oauthError = true;
81
- }
82
- } catch (e) {}
83
- }
84
-
85
- if (
86
- params?.data?.params?.action != 'DescribeRuntimeResourceStrategy' &&
87
- (['InnerError.AuthFailure', 'InvalidAccessToken'].includes(res?.result?.code) || oauthError)
88
- ) {
89
- const loginPage = findLoginPage();
90
- if (loginPage) {
91
- const authConfig = await getAuthConfig();
92
- if (authConfig.RejectStrategy === 'to_login') {
93
- if (['InnerError.AuthFailure'].includes(res?.result?.code)) {
94
- const isAnonymous = await checkAnonymous();
95
- if (!isAnonymous) return;
96
- // 匿名用户越权去登录
97
- }
98
- redirectToLogin();
99
- } else if (authConfig.RejectStrategy === 'show_warning') {
100
- if (oauthError) {
101
- const isAnonymous = await checkAnonymous();
102
- if (!isAnonymous) {
103
- redirectToLogin();
104
- return;
105
- }
106
- }
107
- app.showToast({
108
- title: '接口无访问权限',
109
- icon: 'error',
110
- });
111
- }
112
- }
113
- }
114
- },
115
- });
116
- initTcb()
20
+ })
117
21
 
118
22
  <% if(cdnEndpoints.aegis){ %>
119
23
  require.async('../packages/$wd_system/index.js').then(({ Aegis }) => {
@@ -1,19 +1,8 @@
1
1
  {
2
2
  "name": "lcap-<%= appId%>",
3
3
  "version": "1.0.8",
4
- "scripts": {},
5
- "dependencies": {<% if(importJSSDK) {%>
6
- "@cloudbase/js-sdk": "2.5.45-beta.0",<%
7
- } %>
8
- "@cloudbase/oauth": "0.1.1-alpha.11",
9
- "@cloudbase/weda-client": "1.0.34",
10
- "@cloudbase/weda-cloud-sdk": "1.0.63",
11
- "mobx": "^5.15.4",
12
- "lodash.get": "^4.4.2",
13
- "lodash.set": "^4.3.2",
14
- "miniprogram-gesture": "^1.0.6",
15
- "miniprogram-api-promise": "^1.0.4"<% Object.keys(extraDeps).map(depName => {%>,
16
- "<%= depName%>": "<%= extraDeps[depName]%>"<%
17
- })%>
18
- }
4
+ "scripts": {
5
+ "fix:cloud": "node -e 'try{const fix = require(\"@cloudbase/weda-cloud-sdk/scripts/fix-wx-none-private.js\");fix()}catch(e){}'"
6
+ },
7
+ "dependencies": <%= JSON.stringify(extraDeps, undefined, 2) %>
19
8
  }
@@ -3,7 +3,7 @@
3
3
  "login-input": "./components/input/index",
4
4
  "gsd-h5-react-Modal": "../../../../materials/gsd-h5-react/components/modal/index",
5
5
  "gsd-h5-react-RichTextView": "../../../../materials/gsd-h5-react/components/richText/index",
6
- "wd-ph": "../../../../common/placeholder/index",
6
+ "wd-ph": "@cloudbase/weda-client/mp/runtime/placeholder/index",
7
7
  "wd-info": "../../../../common/info/index",
8
8
  "captcha-dialog": "./components/captchaDialog/index"
9
9
  },
@@ -9,7 +9,9 @@ export default async function (instance, { event }) {
9
9
  const endpointType = app.__internal__ && app.__internal__.getCloudSdkConfig && app.__internal__.getCloudSdkConfig('endpointType');
10
10
  const isTcbApi = endpointType === 'tcb-api';
11
11
  const phoneCode = event.detail.code
12
- const providerInfo = {};
12
+ const providerInfo = {
13
+ provider_params: { provider_code_type: "phone" }
14
+ };
13
15
  wx.showLoading()
14
16
  if (isTcbApi) {
15
17
  const { code } = await wx.login();
@@ -27,7 +29,7 @@ export default async function (instance, { event }) {
27
29
  if (!token) {
28
30
  throw new Error('请在控制台检查小程序相关配置');
29
31
  }
30
- providerInfo.provider_id = 'weda';
32
+ providerInfo.provider_id = providerId;
31
33
  providerInfo.provider_access_token = `${
32
34
  app.utils._getConfig
33
35
  ? app.utils._getConfig().envId
@@ -44,7 +46,8 @@ export default async function (instance, { event }) {
44
46
  provider_token: providerToken.provider_token,
45
47
  provider_id: providerId,
46
48
  provider_params: {
47
- code: phoneCode
49
+ code: phoneCode,
50
+ provider_code_type: "phone"
48
51
  },
49
52
  })
50
53
  }
@@ -1,6 +1,5 @@
1
- import { observable } from 'mobx';
2
1
  import { createPage, PAGE_ROOT_SYMBOL } from '<%= subLevelPath %>../../common/weapp-page'
3
- import { concatClassList, px2rpx } from '<%= subLevelPath %>../../common/style'
2
+ import { concatClassList, px2rpx } from '@cloudbase/weda-client'
4
3
  import { app, $app } from '<%= subLevelPath %>../../app/weapps-api'
5
4
  import { <%= pageNameVar %> as handlers } from '../../app/handlers'
6
5
  <%= importor.lifecycle? `import lifecycle from '../../lowcode/${pageName}/lifecycle'` : "const lifecycle = {}" %>
@@ -1 +0,0 @@
1
- export const REPEATER = <%= REPEATER %>
@@ -1,60 +0,0 @@
1
- import assert from 'assert'
2
- import { getDatapatch } from './data-patch.js'
3
-
4
- const cases = [
5
- {
6
- desc: 'New component',
7
- base: {},
8
- data: { id1: { a: 1 } },
9
- patch: { id1: { a: 1 } }
10
- }, {
11
- desc: 'Component prop update',
12
- base: { id1: { a: 1, b: 2 } },
13
- data: { id1: { a: 1, b: 3 } },
14
- patch: { 'id1.b': 3 }
15
- }, {
16
- desc: 'More than 1/3 of props changed',
17
- base: { id1: { a: 1, b: 2, c: 3 } },
18
- data: { id1: { a: 1, b: 4, c: 5 } },
19
- patch: { id1: { a: 1, b: 4, c: 5 } }
20
- }, {
21
- desc: 'New multiple components',
22
- base: {},
23
- data: { id1: { a: 1 }, id2: { c: 2 }, id3: [{ c: 1 }] },
24
- patch: { id1: { a: 1 }, id2: { c: 2 }, id3: [{ c: 1 }] }
25
- },
26
- {
27
- desc: 'Update component prop in array',
28
- base: { id1: [{ a: 1 }, { a: 2 }, { a: 8 }] },
29
- data: { id1: [{ a: 1 }, { a: 3 }, { a: 8 }] },
30
- patch: { 'id1[1].a': 3 }
31
- },
32
- {
33
- desc: 'Update component prop in 2d array',
34
- base: { id1: [[{ a: 1 }, { a: 2 }], [{ a: 1 }]] },
35
- data: { id1: [[{ a: 1 }, { a: 3 }], [{ a: 1 }]] },
36
- patch: { 'id1[0][1].a': 3 }
37
- },
38
- {
39
- desc: 'Add component in array',
40
- base: { id1: [{ a: 1 }, { a: 2 }] },
41
- data: { id1: [{ a: 1 }, { a: 2 }, { a: 9 }] },
42
- patch: { 'id1[2]': { a: 9 } }
43
- },
44
- {
45
- desc: 'Add 2 components in array',
46
- base: { id1: [{ a: 1 }, { a: 2 }] },
47
- data: { id1: [{ a: 1 }, { a: 2 }, { a: 9 }, { a: 8 }] },
48
- patch: { 'id1[2]': { a: 9 }, 'id1[3]': { a: 8 } }
49
- },
50
- {
51
- desc: 'array: delete component',
52
- base: { id1: [{ a: 1 }, { a: 2 }, { a: 2 }] },
53
- data: { id1: [{ a: 1 }, { a: 2 }] },
54
- patch: { id1: [{ a: 1 }, { a: 2 }] }
55
- }
56
- ]
57
-
58
- for (const c of cases) {
59
- assert.deepStrictEqual(getDatapatch(c.base, c.data), c.patch, c.desc)
60
- }
@@ -1,66 +0,0 @@
1
- import { deepEqual } from "./util"
2
-
3
- export function getDatapatch(base, pendingData) {
4
- const patch = {}
5
- for (const widgetId in pendingData) {
6
- const baseWidget = base[widgetId]
7
- const pendingWidget = pendingData[widgetId]
8
- if (!baseWidget || typeof pendingWidget === 'string') {
9
- patch[widgetId] = pendingWidget
10
- } else {
11
- patchProp(baseWidget, pendingWidget, patch, widgetId)
12
- }
13
- }
14
- return patch
15
- }
16
-
17
- function patchProp(baseWidget, pendingWidget, patch, prefixes) {
18
- if (Array.isArray(pendingWidget)) {
19
- /**
20
- * 数组长度发生变化,更新整个数组
21
- * 当启用 _WaForKey,且可以取到key时,更新整个数组
22
- * 通过 array[0].xxx 进行更新,id 不会更新,疑似 mp 实现 bug
23
- */
24
- if (pendingWidget.length != baseWidget.length) {
25
- patch[prefixes] = pendingWidget
26
- } else if (pendingWidget?.some(item=>item._waForKey) && pendingWidget[0]?._key) {
27
- patch[prefixes] = pendingWidget
28
- } else {
29
- for (let i = 0; i < pendingWidget.length; i++) {
30
- if (!baseWidget[i]) {
31
- patch[prefixes + '[' + i + ']'] = pendingWidget[i]
32
- } else {
33
- patchProp(baseWidget[i], pendingWidget[i], patch, prefixes + '[' + i + ']')
34
- }
35
- }
36
- }
37
- } else {
38
- if (pendingWidget._waIf === false && baseWidget._waIf === false) {
39
- return
40
- }
41
- const propSet = new Set([...Object.keys(pendingWidget), ...Object.keys(baseWidget)])
42
- // 额外剔除公共数据
43
- propSet.delete('_parentId');
44
- const allProps = Array.from(propSet);
45
- // Attention: can not set xxx value to undefined with setData
46
- let hasUndefined = false;
47
- const differentProps = allProps.filter(prop => {
48
- if(pendingWidget[prop] === undefined) {
49
- hasUndefined = true;
50
- }
51
- // container 组件上的属性依赖自身的数据,例如 container.style 依赖 container.data,deepequal 防止死循环
52
- if (prop === 'data' && typeof pendingWidget[prop] === 'object' && deepEqual(pendingWidget[prop], baseWidget[prop])) {
53
- return false
54
- }
55
- // Attention: since setData will copy data deeply, if property is object, it should be treated as different
56
- return typeof pendingWidget[prop] === 'object' || pendingWidget[prop] !== baseWidget[prop]
57
- })
58
- if (differentProps.length === 1 || differentProps.length <= allProps.length / 3) {
59
- differentProps.map(patchProp => {
60
- patch[prefixes + '.' + patchProp] = pendingWidget[patchProp]
61
- })
62
- } else {
63
- patch[prefixes] = pendingWidget
64
- }
65
- }
66
- }
@@ -1,124 +0,0 @@
1
- function checkFunc(listener) {
2
- if (!listener instanceof Function) {
3
- throw new Error(' The listener argument must be of type Function. ');
4
- }
5
- }
6
-
7
- export default class EventEmitter {
8
- constructor() {
9
- this.listeners = {};
10
- }
11
-
12
- on(eventName, listener) {
13
- checkFunc(listener);
14
- let listeners = this.listeners[eventName];
15
- if (!listeners) {
16
- this.listeners[eventName] = [listener];
17
- } else {
18
- listeners.push(listener);
19
- }
20
- }
21
-
22
- off(eventName, listener) {
23
- let listeners = this.listeners[eventName];
24
- if (listeners && listeners.length) {
25
- const index = listeners.indexOf(listener);
26
- index > -1 && listeners.splice(index, 1);
27
- }
28
- }
29
-
30
- emit(eventName, ...args) {
31
- let listeners = this.listeners[eventName] || [];
32
- listeners.forEach((fn) => {
33
- try {
34
- fn.call(this, ...args);
35
- } catch (err) {
36
- console.error(err);
37
- }
38
- });
39
- }
40
-
41
- clear() {
42
- this.listeners = {};
43
- }
44
- }
45
-
46
- // interface IEventProps {
47
- // type: string;
48
- // currentTarget: any;
49
- // target?: any;
50
- // detail?: any;
51
- // _isCapturePhase?: boolean;
52
- // origin?: Event;
53
- // }
54
-
55
- export class Event {
56
- type /* : string*/;
57
- detail /* : any*/;
58
- /**
59
- * 类别应当为 typeof UserWidget
60
- * 当前类别为 typeof $page.widgets.xxxx
61
- * 添加上报确定用量
62
- */
63
- currentTarget /* : any */ /* typeof UserWidget */;
64
- target /* ?: any */ /* typeof UserWidget */;
65
- /**
66
- * 内部实现
67
- * 外部不应该进行访问
68
- */
69
- _isCapturePhase; /* : boolean; */
70
- origin /* : Event */;
71
- originEvent /* ?: React.SyntheticEvent */;
72
- constructor(
73
- {
74
- type = '',
75
- detail = undefined,
76
- currentTarget = undefined,
77
- target = undefined,
78
- _isCapturePhase = false,
79
- origin,
80
- originEvent = undefined,
81
- } /* : IEventProps*/,
82
- ) {
83
- function proxyWrapper(target, key) {
84
- try {
85
- return new Proxy(target, {
86
- get(target, p) {
87
- if (p !== 'id') {
88
- // reportEvent(`event.${key}.${String(p)}`);
89
- }
90
- return target[p];
91
- },
92
- });
93
- } catch (e) {
94
- return target;
95
- }
96
- }
97
- this.type = type;
98
- this.detail = detail;
99
- this.currentTarget = proxyWrapper(currentTarget, 'currentTarget');
100
- this.target = proxyWrapper(target, 'target');
101
- this.origin = proxyWrapper(origin, 'origin');
102
- this.originEvent = originEvent;
103
-
104
- this._isCapturePhase = _isCapturePhase;
105
- return new Proxy(this, {
106
- get(target, prop) {
107
- switch (prop) {
108
- case 'name': {
109
- console.warn('[deprecated] event.name 将在未来版本放弃支持,请使用 event.type 替代');
110
- return target.type;
111
- }
112
- case 'origin':
113
- case 'target':
114
- case 'currentTarget': {
115
- return target[prop];
116
- break;
117
- }
118
- }
119
-
120
- return target[prop];
121
- },
122
- });
123
- }
124
- }
@@ -1,65 +0,0 @@
1
- import { createEventHandlers, getMpEventHandlerName } from './util';
2
- import { Event } from './event-emitter';
3
- export class EventFlow {
4
- #eventHandlerMap = {};
5
- #context = {}
6
- constructor({ schema, context, options }) {
7
- this.#eventHandlerMap = {};
8
- this.#context = context;
9
- const { id, description, eventHandlers = {} } = schema || {};
10
- this.id = id || '';
11
- this.description = description || '';
12
- this.#eventHandlerMap = Object.entries(
13
- createEventHandlers(eventHandlers, {
14
- looseError: true,
15
- isComposite: options?.isComposite || false,
16
- syncCall: true,
17
- }),
18
- ).reduce(
19
- (map, [key, fn]) => {
20
- map[key] = fn;
21
- return map;
22
- },
23
- {
24
- _getInstance: () => this.#context.$page || this.#context.$app,
25
- },
26
- );
27
- return this;
28
- }
29
- trigger(additionalScope, options = {}) {
30
- const mergedContext = {
31
- ...this.#context,
32
- ...options,
33
- };
34
- const { target } = mergedContext;
35
- const eventName = `${this.id}.start`;
36
- return this.#eventHandlerMap[getMpEventHandlerName(this.id, eventName)](
37
- new Event({
38
- type: eventName,
39
- detail: additionalScope,
40
- target,
41
- currentTarget: target,
42
- }),
43
- );
44
- // const emit = (trigger, eventData, originEvent?) =>
45
- // generateEmit($w, target)(
46
- // trigger,
47
- // this._listenerInstances,
48
- // eventData,
49
- // forContext,
50
- // originEvent,
51
- // scopeContext,
52
- // dataContext,
53
- // $w.page.id,
54
- // true,
55
- // );
56
- // return emit(`${this.id}.start`, additionalScope);
57
- }
58
- }
59
- export function generateEventFlows(flows = [], context, options) {
60
- const result = {};
61
- for (let flow of flows) {
62
- result[flow.id] = new EventFlow({ schema: flow, context, options });
63
- }
64
- return result;
65
- }
@@ -1,75 +0,0 @@
1
- import { autorun } from 'mobx'
2
- import { touchObj, throttle } from './util'
3
- import { resolveWidgetData } from './widget'
4
- import { getDatapatch } from './data-patch'
5
-
6
- export default {
7
- // Attention, must be called at the end of attached or page load to make sure user init take effect
8
- initMergeRenderer(widgets, dataFactory = {}) {
9
- this.flushPendingData = throttle(this.flushPendingData.bind(this), 18)
10
-
11
- for (const id in widgets) {
12
- const props = widgets[id]
13
- dataFactory['<%= dataPropNames.widgetProp %>' + id] = () => resolveWidgetData(props, id)
14
- }
15
- const disposers = []
16
- for (const k in dataFactory) {
17
- const disposer = autorun(r => {
18
- this.requestRender({ [k]: dataFactory[k]() })
19
- })
20
- disposers.push(disposer)
21
- }
22
- this.flushPendingData() // Prepare data for first paint
23
- return disposers
24
- },
25
-
26
- // setData merging
27
- pendingData: null,
28
- _settingData: false, // flag to prevent multiple setData at the same time
29
- _flushId: null,
30
- flushPendingData() {
31
- if (!this.pendingData || this._settingData) { return }
32
- const patch = getDatapatch(this.data, this.pendingData)
33
- this.pendingData = null
34
- const label = `setData ${this.is} ${this.id}(${Object.keys(patch).join(',')})`
35
-
36
- if (Object.keys(patch).length < 1) {
37
- return
38
- }
39
- this._settingData = true
40
- const lastUpdateTime = Date.now()
41
- this._flushId = lastUpdateTime;
42
- /**
43
- * 兜底逻辑,当长时间 setData 没有返回时
44
- * 直接抛弃,扭转 pending 状态
45
- */
46
- setTimeout(()=>{
47
- if(this._flushId === lastUpdateTime && this._settingData) {
48
- this._settingData = false;
49
- this.flushPendingData()
50
- }
51
- }, 100)
52
- this.setData(patch, () => {<% if(debug) {%>
53
- const elapsedTime = Date.now() - lastUpdateTime;
54
- if(elapsedTime > 16) {
55
- console.warn(label, elapsedTime)
56
- }else {
57
- console.info(label, elapsedTime)
58
- }<%} %>
59
- this._settingData = false;
60
- this.flushPendingData()
61
- })
62
- },
63
- requestRender(data) {
64
- if(!this._pageActive) {
65
- // The callback of wx.chooseLocation occured when page is inactive
66
- console.warn(`Attention, you're updating widgets(${Object.keys(data).join(',')}) of inactive page(${this.is})`)
67
- }
68
- if (!this.pendingData) {
69
- this.pendingData = {}
70
- }
71
- wx.nextTick(this.flushPendingData)
72
- touchObj(data) // Touch all props to monitor data deeply, FIXME
73
- Object.assign(this.pendingData, data)
74
- },
75
- }
@@ -1 +0,0 @@
1
- Component({})
@@ -1,4 +0,0 @@
1
- {
2
- "component": true,
3
- "usingComponents": {}
4
- }
@@ -1 +0,0 @@
1
- <block></block>
@@ -1 +0,0 @@
1
- /* common/placeholder/index.wxss */