@lcap/nasl 0.3.10-beta.oom4 → 0.3.12-beta
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/out/service/app/api.js +17 -17
- package/out/service/app/api.js.map +1 -1
- package/out/service/create/errHandles.js +12 -0
- package/out/service/create/errHandles.js.map +1 -1
- package/out/service/create/index.js +5 -0
- package/out/service/create/index.js.map +1 -1
- package/out/service/logic/logic.d.ts +26 -17
- package/out/service/logic/logic.js +6 -0
- package/out/service/logic/logic.js.map +1 -1
- package/out/types/app/App.d.ts +9 -0
- package/out/types/app/App.js +25 -1
- package/out/types/app/App.js.map +1 -1
- package/out/types/app/History.js +3 -2
- package/out/types/app/History.js.map +1 -1
- package/out/types/app/Service.d.ts +3 -0
- package/out/types/app/Service.js +14 -6
- package/out/types/app/Service.js.map +1 -1
- package/out/types/cacheData.js.map +1 -1
- package/out/types/common/Vertex.js +2 -1
- package/out/types/common/Vertex.js.map +1 -1
- package/out/types/data/Entity.d.ts +4 -0
- package/out/types/data/Entity.js +8 -0
- package/out/types/data/Entity.js.map +1 -1
- package/out/types/data/EntityProperty.d.ts +5 -0
- package/out/types/data/EntityProperty.js +16 -0
- package/out/types/data/EntityProperty.js.map +1 -1
- package/out/types/data/GlobalLogicNode.js +8 -1
- package/out/types/data/GlobalLogicNode.js.map +1 -1
- package/out/types/data/dataTypes.js +1 -1
- package/out/types/data/dataTypes.js.map +1 -1
- package/out/types/data/genBlock/genCurdEditTableBlock.d.ts +3 -0
- package/out/types/data/genBlock/genCurdEditTableBlock.js +578 -0
- package/out/types/data/genBlock/genCurdEditTableBlock.js.map +1 -0
- package/out/types/data/genBlock/genEditTableBlock.d.ts +234 -0
- package/out/types/data/genBlock/genEditTableBlock.js +419 -0
- package/out/types/data/genBlock/genEditTableBlock.js.map +1 -0
- package/out/types/data/genBlock/genQueryComponent.d.ts +20 -0
- package/out/types/data/genBlock/genQueryComponent.js +57 -1
- package/out/types/data/genBlock/genQueryComponent.js.map +1 -1
- package/out/types/data/genBlock/genTableBlock.js +9 -5
- package/out/types/data/genBlock/genTableBlock.js.map +1 -1
- package/out/types/data/genBlock/index.d.ts +2 -0
- package/out/types/data/genBlock/index.js +2 -0
- package/out/types/data/genBlock/index.js.map +1 -1
- package/out/types/data/genBlock/utils.d.ts +7 -0
- package/out/types/data/genBlock/utils.js +38 -1
- package/out/types/data/genBlock/utils.js.map +1 -1
- package/out/types/logic/Logic.d.ts +4 -0
- package/out/types/logic/Logic.js +35 -10
- package/out/types/logic/Logic.js.map +1 -1
- package/out/types/logic/LogicItem.js +6 -8
- package/out/types/logic/LogicItem.js.map +1 -1
- package/out/types/logic/Param.js +5 -13
- package/out/types/logic/Param.js.map +1 -1
- package/out/types/logic/Return.js +3 -11
- package/out/types/logic/Return.js.map +1 -1
- package/out/types/logic/Variable.js +3 -6
- package/out/types/logic/Variable.js.map +1 -1
- package/out/types/logic/translator.js +39 -8
- package/out/types/logic/translator.js.map +1 -1
- package/out/types/page/Element.d.ts +21 -2
- package/out/types/page/Element.js +86 -5
- package/out/types/page/Element.js.map +1 -1
- package/out/types/page/Page.d.ts +4 -0
- package/out/types/page/Page.js +7 -0
- package/out/types/page/Page.js.map +1 -1
- package/out/types/page/View.d.ts +18 -0
- package/out/types/page/View.js +112 -7
- package/out/types/page/View.js.map +1 -1
- package/out/types/page/ViewVariable.js +0 -6
- package/out/types/page/ViewVariable.js.map +1 -1
- package/out/types/process/ProcessParam.js +3 -1
- package/out/types/process/ProcessParam.js.map +1 -1
- package/out/types/utils/index.d.ts +1 -0
- package/out/types/utils/index.js +16 -7
- package/out/types/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/service/app/api.js +4 -4
- package/src/service/create/errHandles.js +12 -0
- package/src/service/create/index.js +6 -0
- package/src/service/logic/logic.js +6 -0
- package/src/types/app/App.ts +32 -9
- package/src/types/app/History.ts +3 -2
- package/src/types/app/Service.ts +18 -9
- package/src/types/cacheData.ts +7 -7
- package/src/types/common/Vertex.ts +2 -1
- package/src/types/data/Entity.ts +7 -0
- package/src/types/data/EntityProperty.ts +12 -0
- package/src/types/data/GlobalLogicNode.ts +8 -1
- package/src/types/data/dataTypes.ts +1 -1
- package/src/types/data/genBlock/genCurdEditTableBlock.ts +581 -0
- package/src/types/data/genBlock/genEditTableBlock.ts +470 -0
- package/src/types/data/genBlock/genQueryComponent.ts +56 -0
- package/src/types/data/genBlock/genTableBlock.ts +14 -10
- package/src/types/data/genBlock/index.ts +2 -0
- package/src/types/data/genBlock/utils.ts +38 -0
- package/src/types/logic/Logic.ts +45 -17
- package/src/types/logic/LogicItem.ts +8 -11
- package/src/types/logic/Param.ts +25 -35
- package/src/types/logic/Return.ts +18 -26
- package/src/types/logic/Variable.ts +18 -20
- package/src/types/logic/translator.js +41 -10
- package/src/types/page/Element.ts +157 -71
- package/src/types/page/Page.ts +7 -0
- package/src/types/page/View.ts +150 -41
- package/src/types/page/ViewVariable.ts +13 -19
- package/src/types/page/dist/View.js +727 -0
- package/src/types/process/ProcessParam.ts +4 -1
- package/src/types/utils/index.ts +16 -7
- package/out/service/debugger/debugger.d.ts +0 -3
- package/out/service/debugger/debugger.js +0 -95
- package/out/service/debugger/debugger.js.map +0 -1
- package/out/test/units/config.spec.d.ts +0 -1
- package/out/test/units/config.spec.js +0 -12
- package/out/test/units/config.spec.js.map +0 -1
- package/out/types/logic/BreakPoint.d.ts +0 -42
- package/out/types/logic/BreakPoint.js +0 -155
- package/out/types/logic/BreakPoint.js.map +0 -1
- package/out/types/logic/Debugger.d.ts +0 -156
- package/out/types/logic/Debugger.js +0 -912
- package/out/types/logic/Debugger.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vertex } from '..';
|
|
1
|
+
import { Vertex, utils } from '..';
|
|
2
2
|
|
|
3
3
|
function switchCase2If(cases) {
|
|
4
4
|
const cas = cases.shift();
|
|
@@ -8,7 +8,13 @@ function switchCase2If(cases) {
|
|
|
8
8
|
test: cas.test,
|
|
9
9
|
consequent: {
|
|
10
10
|
type: 'BlockStatement',
|
|
11
|
-
body:
|
|
11
|
+
body: [
|
|
12
|
+
{
|
|
13
|
+
type: 'CallConsoleInfo',
|
|
14
|
+
content: 'SWITCHCASE',
|
|
15
|
+
},
|
|
16
|
+
...cas.consequent || [],
|
|
17
|
+
],
|
|
12
18
|
},
|
|
13
19
|
alternate: null,
|
|
14
20
|
};
|
|
@@ -18,7 +24,13 @@ function switchCase2If(cases) {
|
|
|
18
24
|
} else {
|
|
19
25
|
return {
|
|
20
26
|
type: 'BlockStatement',
|
|
21
|
-
body:
|
|
27
|
+
body: [
|
|
28
|
+
{
|
|
29
|
+
type: 'CallConsoleInfo',
|
|
30
|
+
content: 'SWITCHDEFAULT',
|
|
31
|
+
},
|
|
32
|
+
...cas.consequent || [],
|
|
33
|
+
],
|
|
22
34
|
};
|
|
23
35
|
}
|
|
24
36
|
|
|
@@ -26,6 +38,7 @@ function switchCase2If(cases) {
|
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
export default function (source) {
|
|
41
|
+
const isGONGHANG = utils.getGlobalEnv() === 'gonghang';
|
|
29
42
|
const definition = typeof source === 'string' ? JSON.parse(source) : source;
|
|
30
43
|
|
|
31
44
|
function traverse(node, func, parent, index) {
|
|
@@ -458,6 +471,13 @@ export default function (source) {
|
|
|
458
471
|
return `${newLine()}console.log(${generateNode(node.arguments[0])})${colon()}${newLine()}`;
|
|
459
472
|
}
|
|
460
473
|
|
|
474
|
+
if (node.type === 'CallConsoleInfo') {
|
|
475
|
+
if (isGONGHANG) {
|
|
476
|
+
return `console.info("${node.content}")${colon()}`;
|
|
477
|
+
}
|
|
478
|
+
return '';
|
|
479
|
+
}
|
|
480
|
+
|
|
461
481
|
if (node.type === 'Destination') {
|
|
462
482
|
const params = (node.params || [])
|
|
463
483
|
.filter((param) => param.pageParamKey && param.pageParamKeyValue)
|
|
@@ -478,16 +498,27 @@ export default function (source) {
|
|
|
478
498
|
if (Array.isArray(node.consequent)) {
|
|
479
499
|
node.consequent = {
|
|
480
500
|
type: 'BlockStatement',
|
|
481
|
-
body:
|
|
501
|
+
body: [
|
|
502
|
+
{
|
|
503
|
+
type: 'CallConsoleInfo',
|
|
504
|
+
content: 'IF',
|
|
505
|
+
},
|
|
506
|
+
...node.consequent,
|
|
507
|
+
],
|
|
482
508
|
};
|
|
483
509
|
}
|
|
484
|
-
if (Array.isArray(node.alternate)) {
|
|
510
|
+
if (Array.isArray(node.alternate) && node.alternate.length > 0) {
|
|
485
511
|
node.alternate = {
|
|
486
512
|
type: 'BlockStatement',
|
|
487
|
-
body:
|
|
513
|
+
body: [
|
|
514
|
+
{
|
|
515
|
+
type: 'CallConsoleInfo',
|
|
516
|
+
content: 'ELSE',
|
|
517
|
+
},
|
|
518
|
+
...node.alternate,
|
|
519
|
+
],
|
|
488
520
|
};
|
|
489
521
|
}
|
|
490
|
-
|
|
491
522
|
let alternateScript = '';
|
|
492
523
|
if (node.alternate) {
|
|
493
524
|
alternateScript = generateNode(node.alternate);
|
|
@@ -597,9 +628,9 @@ export default function (source) {
|
|
|
597
628
|
});
|
|
598
629
|
|
|
599
630
|
return `methods['${logic.name}'] = async function (${logic.params.map((param) => param.name).join(', ')}) {
|
|
600
|
-
${logic.params.length ? logic.params.map((param) => `${param.name} = ${param.name} !== undefined ? ${param.name} : this.$genInitFromSchema(${JSON.stringify(param.schema)}, ${JSON.stringify(param.defaultValue)});`).join('\n') + '' : ''}
|
|
601
|
-
${logic.variables.length ? logic.variables.map((variable) => `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});`).join('\n') + '' : ''}
|
|
602
|
-
let ${returnObj.name} = this.$genInitFromSchema(${JSON.stringify(returnObj.schema)}, ${JSON.stringify(returnObj.defaultValue)})
|
|
631
|
+
${logic.params.length ? logic.params.map((param) => `${param.name} = ${param.name} !== undefined ? ${param.name} : this.$genInitFromSchema(${JSON.stringify(param.schema)}, ${JSON.stringify(param.defaultValue)});` + (isGONGHANG ? `console.info(${param.name})` : '')).join('\n') + '' : ''}
|
|
632
|
+
${logic.variables.length ? logic.variables.map((variable) => `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});` + (isGONGHANG ? `console.info(${variable.name})` : '')).join('\n') + '' : ''}
|
|
633
|
+
let ${returnObj.name} = this.$genInitFromSchema(${JSON.stringify(returnObj.schema)}, ${JSON.stringify(returnObj.defaultValue)});` + (isGONGHANG ? `console.info(${returnObj.name})` : '') + `
|
|
603
634
|
${script}
|
|
604
635
|
}`;
|
|
605
636
|
});
|
|
@@ -30,14 +30,14 @@ export interface ParseContext {
|
|
|
30
30
|
|
|
31
31
|
export function catchFn(view: View) {
|
|
32
32
|
return async (err: any) => {
|
|
33
|
-
if(err.code !== BusinessCode.HasReferenced)
|
|
33
|
+
if (err.code !== BusinessCode.HasReferenced) // 节点被引用,不用刷新数据
|
|
34
34
|
await refreshHtml(view);
|
|
35
35
|
else
|
|
36
36
|
config.defaultApp?.emit('saved', err);
|
|
37
37
|
|
|
38
38
|
config.defaultApp?.history.load();
|
|
39
39
|
throw err;
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -75,6 +75,12 @@ export class Element extends Vertex {
|
|
|
75
75
|
*/
|
|
76
76
|
@immutable()
|
|
77
77
|
public readonly name: string = undefined;
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
* 描述信息
|
|
81
|
+
*/
|
|
82
|
+
@immutable()
|
|
83
|
+
public readonly description: string = undefined;
|
|
78
84
|
/**
|
|
79
85
|
* 属性列表
|
|
80
86
|
* 和原来的 attrsList 不同,注意区分
|
|
@@ -154,6 +160,16 @@ export class Element extends Vertex {
|
|
|
154
160
|
*/
|
|
155
161
|
@immutable()
|
|
156
162
|
public readonly children?: Array<Element> = [];
|
|
163
|
+
/**
|
|
164
|
+
* 标签名前缀
|
|
165
|
+
*/
|
|
166
|
+
@immutable()
|
|
167
|
+
public static readonly TAG_NAME_PREFIX_REG?: RegExp = /^([lieu]|van)[-_]/;
|
|
168
|
+
/**
|
|
169
|
+
* 忽略命名的标签
|
|
170
|
+
*/
|
|
171
|
+
@immutable()
|
|
172
|
+
public static readonly ignoreTag?: Array<string> = ['div', 'span'];
|
|
157
173
|
|
|
158
174
|
/**
|
|
159
175
|
* @param source 需要合并的部分参数
|
|
@@ -180,45 +196,45 @@ export class Element extends Vertex {
|
|
|
180
196
|
}
|
|
181
197
|
|
|
182
198
|
config.defaultApp?.emit('saving');
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
operationAction: 'Element.create',
|
|
192
|
-
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
193
|
-
},
|
|
194
|
-
body,
|
|
195
|
-
}).catch(catchFn(this.view));
|
|
196
|
-
|
|
197
|
-
this.deepPick(result, ['id', 'parentId', 'elementId']);
|
|
198
|
-
// attr,directive,event的id,exprssion需要合并
|
|
199
|
-
this.attrList.forEach((attr, index) => {
|
|
200
|
-
attr.deepPick(result.attrList[index], ['id', 'expression']);
|
|
201
|
-
});
|
|
202
|
-
this.directiveList.forEach((directive, index) => {
|
|
203
|
-
directive.deepPick(result.directiveList[index], ['id', 'expression']);
|
|
204
|
-
});
|
|
205
|
-
this.eventList.forEach((event, index) => {
|
|
206
|
-
event.deepPick(result.eventList[index], ['id']);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
this.view && this.view.emit('change');
|
|
211
|
-
|
|
212
|
-
if (actionOptions?.loadHistory !== false) {
|
|
213
|
-
await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
|
|
199
|
+
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
200
|
+
const body = this.toJSON();
|
|
201
|
+
body.parentId = this.parent && this.parent.id;
|
|
202
|
+
body._posIndex = this.parent && this.parent.children.indexOf(this);
|
|
203
|
+
utils.logger.debug('添加元素', body);
|
|
204
|
+
const result = await elementService.create({
|
|
205
|
+
headers: {
|
|
206
|
+
appId: config.defaultApp?.id,
|
|
214
207
|
operationAction: 'Element.create',
|
|
215
|
-
operationBeforeImage: null,
|
|
216
|
-
operationAfterImage: JSON.parse(JSON.stringify(this)),
|
|
217
208
|
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
218
|
-
}
|
|
209
|
+
},
|
|
210
|
+
body,
|
|
211
|
+
}).catch(catchFn(this.view));
|
|
212
|
+
|
|
213
|
+
this.deepPick(result, ['id', 'parentId', 'elementId']);
|
|
214
|
+
// attr,directive,event的id,expression需要合并
|
|
215
|
+
this.attrList.forEach((attr, index) => {
|
|
216
|
+
attr.deepPick(result.attrList[index], ['id', 'expression']);
|
|
217
|
+
});
|
|
218
|
+
this.directiveList.forEach((directive, index) => {
|
|
219
|
+
directive.deepPick(result.directiveList[index], ['id', 'expression']);
|
|
220
|
+
});
|
|
221
|
+
this.eventList.forEach((event, index) => {
|
|
222
|
+
event.deepPick(result.eventList[index], ['id']);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
this.view && this.view.emit('change');
|
|
227
|
+
|
|
228
|
+
if (actionOptions?.loadHistory !== false) {
|
|
229
|
+
await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
|
|
230
|
+
operationAction: 'Element.create',
|
|
231
|
+
operationBeforeImage: null,
|
|
232
|
+
operationAfterImage: JSON.parse(JSON.stringify(this)),
|
|
233
|
+
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
234
|
+
});
|
|
219
235
|
config.defaultApp?.emit('saved');
|
|
220
|
-
|
|
221
|
-
|
|
236
|
+
}
|
|
237
|
+
return this;
|
|
222
238
|
}
|
|
223
239
|
/**
|
|
224
240
|
* 删除元素
|
|
@@ -228,6 +244,7 @@ export class Element extends Vertex {
|
|
|
228
244
|
if (actionOptions?.actionMode === ACTION_MODE.local) {
|
|
229
245
|
const index = this.parent.children.indexOf(this);
|
|
230
246
|
~index && this.parent.children.splice(index, 1);
|
|
247
|
+
this.deepRemoveElementsName();
|
|
231
248
|
this.view && this.view.emit('local-change');
|
|
232
249
|
return this;
|
|
233
250
|
}
|
|
@@ -239,21 +256,24 @@ export class Element extends Vertex {
|
|
|
239
256
|
|
|
240
257
|
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
241
258
|
if (this.id) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
259
|
+
await elementService.delete({
|
|
260
|
+
headers: {
|
|
261
|
+
appId: config.defaultApp?.id,
|
|
262
|
+
operationAction: 'Element.delete',
|
|
263
|
+
operationDesc: `删除组件"${this.getElementTitle()}"`,
|
|
264
|
+
},
|
|
265
|
+
query: {
|
|
266
|
+
id: this.id,
|
|
267
|
+
},
|
|
268
|
+
}).catch(catchFn(this.view));
|
|
252
269
|
}
|
|
253
270
|
}
|
|
254
271
|
|
|
255
272
|
const index = this.parent.children.indexOf(this);
|
|
256
273
|
~index && this.parent.children.splice(index, 1);
|
|
274
|
+
|
|
275
|
+
// 递归删除组件名的缓存
|
|
276
|
+
this.deepRemoveElementsName();
|
|
257
277
|
this.destroy();
|
|
258
278
|
this.view && this.view.emit('change');
|
|
259
279
|
if (actionOptions?.loadHistory !== false) {
|
|
@@ -273,32 +293,32 @@ export class Element extends Vertex {
|
|
|
273
293
|
config.defaultApp?.emit('saving');
|
|
274
294
|
|
|
275
295
|
source && this.assign(source);
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
296
|
+
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
297
|
+
const body = this.toPlainJSON();
|
|
298
|
+
utils.logger.debug('修改组件', body);
|
|
299
|
+
await elementService.update({
|
|
300
|
+
headers: {
|
|
301
|
+
appId: config.defaultApp?.id,
|
|
302
|
+
operationAction: actionOptions?.actionName || 'Element.update',
|
|
303
|
+
operationDesc: actionOptions?.actionDesc || `修改组件"${this.getElementTitle()}"`,
|
|
304
|
+
},
|
|
305
|
+
body,
|
|
306
|
+
}).catch(catchFn(this.view));
|
|
307
|
+
}
|
|
288
308
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
309
|
+
this.view && this.view.emit('change');
|
|
310
|
+
await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
|
|
311
|
+
operationAction: 'Element.update',
|
|
312
|
+
operationBeforeImage: null,
|
|
313
|
+
operationAfterImage: null,
|
|
314
|
+
operationDesc: `修改组件"${this.getElementTitle()}"`,
|
|
315
|
+
});
|
|
296
316
|
|
|
297
317
|
config.defaultApp?.emit('saved');
|
|
298
318
|
return this;
|
|
299
319
|
}
|
|
300
320
|
|
|
301
|
-
|
|
321
|
+
/**
|
|
302
322
|
* 按当前 id 加载逻辑数据
|
|
303
323
|
*/
|
|
304
324
|
async load() {
|
|
@@ -378,6 +398,8 @@ export class Element extends Vertex {
|
|
|
378
398
|
|
|
379
399
|
const index = this.parent.children.indexOf(this);
|
|
380
400
|
const newNode = Element.fromHTML(code, this.parent, this.view);
|
|
401
|
+
// 复制的元素需重新命名
|
|
402
|
+
newNode.deepRenameElements();
|
|
381
403
|
|
|
382
404
|
const mergeExpression = (originList: Array<Attr|Directive>, newList: Array<Attr|Directive>) => {
|
|
383
405
|
newList.forEach((item) => {
|
|
@@ -495,7 +517,7 @@ export class Element extends Vertex {
|
|
|
495
517
|
await this.update(undefined, {
|
|
496
518
|
actionDesc: `设置组件"${this.getElementTitle()}"的名称为"${name}"`,
|
|
497
519
|
});
|
|
498
|
-
|
|
520
|
+
|
|
499
521
|
if (!(window as any).globalData.hasUserCenter) {
|
|
500
522
|
// 同步权限
|
|
501
523
|
new Nuims({
|
|
@@ -509,6 +531,22 @@ export class Element extends Vertex {
|
|
|
509
531
|
this.view.page.service.emit('vertexIdToNameChange', this.id, this.name);
|
|
510
532
|
}
|
|
511
533
|
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* 更新描述信息
|
|
537
|
+
* @param description
|
|
538
|
+
*/
|
|
539
|
+
async setDescription(description: string) {
|
|
540
|
+
this.assign({ description });
|
|
541
|
+
await this.update(undefined, {
|
|
542
|
+
actionDesc: `设置组件"${this.getElementTitle()}"的描述为"${description}"`,
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
this.view && this.view.emit('change');
|
|
546
|
+
if (this.view && this.view.page && this.view.page.service) {
|
|
547
|
+
this.view.page.service.emit('vertexIdToNameChange', this.id, this.name);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
512
550
|
/**
|
|
513
551
|
* 添加组件属性
|
|
514
552
|
*/
|
|
@@ -729,8 +767,11 @@ export class Element extends Vertex {
|
|
|
729
767
|
if (attr.level === LEVEL_ENUM.attr) {
|
|
730
768
|
const api = config.allNodesAPI[el.tag];
|
|
731
769
|
const apiOfAttr = api && api.attrs && api.attrs.find((_attr) => _attr.name === attr.name);
|
|
732
|
-
if (apiOfAttr && apiOfAttr['designer-value']) {
|
|
733
|
-
|
|
770
|
+
if (apiOfAttr && apiOfAttr['designer-value'] !== undefined) {
|
|
771
|
+
let designerValue = apiOfAttr['designer-value'];
|
|
772
|
+
if (typeof designerValue === 'string') {
|
|
773
|
+
designerValue = designerValue.replace(/"/g, '\'');
|
|
774
|
+
}
|
|
734
775
|
try {
|
|
735
776
|
json5.parse(designerValue);
|
|
736
777
|
return `:${attr.name}="${designerValue}"`;
|
|
@@ -843,6 +884,46 @@ export class Element extends Vertex {
|
|
|
843
884
|
}
|
|
844
885
|
}
|
|
845
886
|
}
|
|
887
|
+
|
|
888
|
+
// 初始化组件名
|
|
889
|
+
public initElementName() {
|
|
890
|
+
if (Element.ignoreTag.includes(this.tag)) {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
const name = this.genElementName();
|
|
894
|
+
this.assign({ name });
|
|
895
|
+
this.view.addElementName(name);
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// 生成新的组件名
|
|
899
|
+
public genElementName(): string {
|
|
900
|
+
const compNameSet = this.view.elementNameSet;
|
|
901
|
+
const tagName = this.tag.replace(Element.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
902
|
+
const componentName = utils.unique(tagName + '1', compNameSet);
|
|
903
|
+
return componentName;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// 递归生成组件名
|
|
907
|
+
public deepRenameElements(): void {
|
|
908
|
+
return this.traverseChildren((ele: Element) => {
|
|
909
|
+
ele.initElementName();
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
// 递归删除组件名的缓存
|
|
914
|
+
public deepRemoveElementsName(): void {
|
|
915
|
+
return this.traverseChildren((ele: Element) => {
|
|
916
|
+
this.view.removeElementName(ele.name);
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// 递归遍历组件
|
|
921
|
+
public traverseChildren(cb: (ele: Element) => void): void {
|
|
922
|
+
utils.traverse((current) => {
|
|
923
|
+
cb(current.node);
|
|
924
|
+
}, { node: this });
|
|
925
|
+
}
|
|
926
|
+
|
|
846
927
|
/**
|
|
847
928
|
* 从 Vue 的 ASTNode 转换成 ASL 元素
|
|
848
929
|
* @param astNode Vue 的 ASTNode
|
|
@@ -1321,6 +1402,11 @@ export class Element extends Vertex {
|
|
|
1321
1402
|
const element = this.parse(html, context);
|
|
1322
1403
|
utils.traverse((current) => {
|
|
1323
1404
|
current.node.assign({ view, parent: current.parent });
|
|
1405
|
+
// 生成唯一组件名 依赖element.view
|
|
1406
|
+
|
|
1407
|
+
if (!current.node.name) {
|
|
1408
|
+
current.node.initElementName();
|
|
1409
|
+
}
|
|
1324
1410
|
}, { node: element, parent });
|
|
1325
1411
|
return element;
|
|
1326
1412
|
}
|
package/src/types/page/Page.ts
CHANGED