@cloudbase/framework-plugin-low-code 0.7.31 → 0.7.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "0.7.31",
3
+ "version": "0.7.32",
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",
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { observable, autorun, untracked } from 'mobx';
3
- import { remove } from 'lodash';
3
+ import { remove, set as lodashSet } from 'lodash';
4
4
  import { checkVisible } from '../../utils/index';
5
5
 
6
6
  export const WidgetsContext = React.createContext({ parent: null });
@@ -191,29 +191,41 @@ export function createWidgets(widgetProps, dataBinds, scopeContext = {}, context
191
191
  parentLevelWidgets && parentLevelWidgets[node.id].push(w);
192
192
 
193
193
  // Setup data binds
194
- Object.keys(dataBinds[node.id] || {}).map((prop) => {
195
- if (prop === '_waFor') {
196
- return;
197
- }
198
- function getBindData(options = {}) {
199
- let disposeError = false;
200
- const dispose = autorun(() => {
201
- try {
202
- // Computed data bind in the next tick since data bind may read widgets data
203
- w[prop] = dataBinds[node.id][prop](subForItems, undefined, context, scopeContext);
204
- disposeError = false;
205
- } catch (e) {
206
- options.showLog && console.error(e);
207
- retryQueue.push(getBindData);
208
- disposeError = true;
194
+ Object.keys(dataBinds[node.id] || {})
195
+ .sort((a, b) => {
196
+ return a.length - b.length > 0 ? 1 : -1;
197
+ })
198
+ .map((prop) => {
199
+ if (prop === '_waFor') {
200
+ return;
201
+ }
202
+ function getBindData(options = {}) {
203
+ let disposeError = false;
204
+ const dispose = autorun(() => {
205
+ try {
206
+ // Computed data bind in the next tick since data bind may read widgets data
207
+ const value = dataBinds[node.id][prop](subForItems, undefined, context, scopeContext);
208
+ const paths = prop.split('.').filter((key) => !!key);
209
+ if (paths.length > 1) {
210
+ // 一定要 untracked 不然爆栈了
211
+ untracked(() => lodashSet(w, prop, value));
212
+ } else {
213
+ // 普通 key 直接赋值
214
+ w[prop] = value;
215
+ }
216
+ disposeError = false;
217
+ } catch (e) {
218
+ options.showLog && console.error(e);
219
+ retryQueue.push(getBindData);
220
+ disposeError = true;
221
+ }
222
+ });
223
+ if (!!disposeError && curForNode.id) {
224
+ widgets[curForNode.id]._disposers.push(dispose);
209
225
  }
210
- });
211
- if (!!disposeError && curForNode.id) {
212
- widgets[curForNode.id]._disposers.push(dispose);
213
226
  }
214
- }
215
- getBindData();
216
- });
227
+ getBindData();
228
+ });
217
229
  } else {
218
230
  if (parentLevelWidgets) {
219
231
  const len = parentLevelWidgets[node.id].push([]);