@lcap/nasl 0.3.9 → 0.3.10-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/create/errHandles.js +7 -2
- package/out/service/create/errHandles.js.map +1 -1
- package/out/service/debugger/debugger.d.ts +3 -0
- package/out/service/debugger/debugger.js +95 -0
- package/out/service/debugger/debugger.js.map +1 -0
- package/out/service/logic/logic.d.ts +27 -0
- package/out/service/logic/logic.js +20 -0
- package/out/service/logic/logic.js.map +1 -1
- package/out/service/page/element.d.ts +9 -0
- package/out/service/page/element.js +6 -0
- package/out/service/page/element.js.map +1 -1
- package/out/service/permission/api.d.ts +57 -0
- package/out/service/permission/api.js +41 -0
- package/out/service/permission/api.js.map +1 -0
- package/out/service/permission/index.d.ts +2 -0
- package/out/service/permission/index.js +17 -0
- package/out/service/permission/index.js.map +1 -0
- package/out/service/webFile/index.js +5 -0
- package/out/service/webFile/index.js.map +1 -1
- package/out/types/app/App.d.ts +4 -1
- package/out/types/app/App.js +24 -0
- package/out/types/app/App.js.map +1 -1
- package/out/types/app/Service.d.ts +2 -2
- package/out/types/app/Service.js +28 -3
- package/out/types/app/Service.js.map +1 -1
- package/out/types/cache.d.ts +6 -0
- package/out/types/cache.js +54 -0
- package/out/types/cache.js.map +1 -0
- package/out/types/common/Vertex.d.ts +25 -0
- package/out/types/common/Vertex.js +40 -0
- package/out/types/common/Vertex.js.map +1 -1
- package/out/types/data/Entity.js +1 -0
- package/out/types/data/Entity.js.map +1 -1
- package/out/types/data/Enum.d.ts +5 -0
- package/out/types/data/Enum.js +5 -0
- package/out/types/data/Enum.js.map +1 -1
- package/out/types/data/Interface.js +5 -3
- package/out/types/data/Interface.js.map +1 -1
- package/out/types/data/genBlock/genCreateBlock.js +5 -5
- package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
- package/out/types/data/genBlock/genCurdBlock.js +3 -3
- package/out/types/data/genBlock/genCurdBlock.js.map +1 -1
- package/out/types/data/genBlock/genEnumSelectBlock.d.ts +1 -1
- package/out/types/data/genBlock/genEnumSelectBlock.js +2 -2
- package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
- package/out/types/data/genBlock/genGridViewBlock.js +12 -1
- package/out/types/data/genBlock/genGridViewBlock.js.map +1 -1
- package/out/types/data/genBlock/genListViewBlock.js +2 -2
- package/out/types/data/genBlock/genSelectBlock.js +2 -2
- package/out/types/data/genBlock/genTableBlock.js +14 -3
- package/out/types/data/genBlock/genTableBlock.js.map +1 -1
- package/out/types/data/genBlock/genUpdateBlock.js +5 -5
- package/out/types/data/genBlock/genUpdateBlock.js.map +1 -1
- package/out/types/data/systemTypes.js +47 -0
- package/out/types/data/systemTypes.js.map +1 -1
- package/out/types/enum.d.ts +6 -0
- package/out/types/enum.js +11 -0
- package/out/types/enum.js.map +1 -0
- package/out/types/generator/hotReload.d.ts +2 -0
- package/out/types/generator/hotReload.js +12 -1
- package/out/types/generator/hotReload.js.map +1 -1
- package/out/types/index.d.ts +7 -1
- package/out/types/index.js +11 -2
- package/out/types/index.js.map +1 -1
- package/out/types/logic/BreakPoint.d.ts +42 -0
- package/out/types/logic/BreakPoint.js +155 -0
- package/out/types/logic/BreakPoint.js.map +1 -0
- package/out/types/logic/Debugger.d.ts +156 -0
- package/out/types/logic/Debugger.js +912 -0
- package/out/types/logic/Debugger.js.map +1 -0
- package/out/types/logic/Logic.d.ts +40 -0
- package/out/types/logic/Logic.js +130 -31
- package/out/types/logic/Logic.js.map +1 -1
- package/out/types/logic/LogicItem.d.ts +21 -1
- package/out/types/logic/LogicItem.js +227 -24
- package/out/types/logic/LogicItem.js.map +1 -1
- package/out/types/logic/Param.d.ts +1 -0
- package/out/types/logic/Param.js +38 -20
- package/out/types/logic/Param.js.map +1 -1
- package/out/types/logic/Return.js +14 -19
- package/out/types/logic/Return.js.map +1 -1
- package/out/types/logic/Variable.js +14 -19
- package/out/types/logic/Variable.js.map +1 -1
- package/out/types/logic/translator.js +0 -2
- package/out/types/logic/translator.js.map +1 -1
- package/out/types/nuims/Nuims.d.ts +1 -1
- package/out/types/nuims/Nuims.js +11 -4
- package/out/types/nuims/Nuims.js.map +1 -1
- package/out/types/page/Element.d.ts +5 -0
- package/out/types/page/Element.js +114 -130
- package/out/types/page/Element.js.map +1 -1
- package/out/types/page/Event.js.map +1 -1
- package/out/types/page/Page.d.ts +1 -0
- package/out/types/page/Page.js +59 -27
- package/out/types/page/Page.js.map +1 -1
- package/out/types/page/View.d.ts +17 -3
- package/out/types/page/View.js +53 -37
- package/out/types/page/View.js.map +1 -1
- package/out/types/page/ViewParam.d.ts +1 -0
- package/out/types/page/ViewParam.js +23 -4
- package/out/types/page/ViewParam.js.map +1 -1
- package/out/types/page/ViewVariable.js +13 -18
- package/out/types/page/ViewVariable.js.map +1 -1
- package/out/types/permission/Permission.d.ts +41 -0
- package/out/types/permission/Permission.js +122 -0
- package/out/types/permission/Permission.js.map +1 -0
- package/package.json +2 -2
- package/src/service/create/errHandles.js +6 -2
- package/src/service/debugger/debugger.js +90 -0
- package/src/service/developPermission/api.js +37 -0
- package/src/service/developPermission/index.js +13 -0
- package/src/service/logic/logic.js +20 -0
- package/src/service/page/element.js +6 -0
- package/src/service/permission/api.js +38 -0
- package/src/service/permission/index.js +13 -0
- package/src/service/webFile/index.js +6 -1
- package/src/types/app/App.ts +27 -1
- package/src/types/app/Service.ts +32 -3
- package/src/types/cache.ts +50 -0
- package/src/types/common/Vertex.ts +30 -0
- package/src/types/data/Entity.ts +1 -0
- package/src/types/data/Enum.ts +5 -0
- package/src/types/data/Interface.ts +4 -3
- package/src/types/data/genBlock/genCreateBlock.ts +5 -5
- package/src/types/data/genBlock/genCurdBlock.ts +3 -3
- package/src/types/data/genBlock/genEnumSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genGridViewBlock.ts +12 -1
- package/src/types/data/genBlock/genListViewBlock.ts +2 -2
- package/src/types/data/genBlock/genSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genTableBlock.ts +14 -3
- package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
- package/src/types/data/systemTypes.ts +47 -0
- package/src/types/enum.ts +6 -0
- package/src/types/generator/hotReload.ts +10 -0
- package/src/types/index.ts +7 -1
- package/src/types/logic/BreakPoint.ts +200 -0
- package/src/types/logic/Debugger.ts +1140 -0
- package/src/types/logic/Logic.ts +133 -28
- package/src/types/logic/LogicItem.ts +250 -28
- package/src/types/logic/Param.ts +26 -8
- package/src/types/logic/Return.ts +4 -9
- package/src/types/logic/Variable.ts +4 -8
- package/src/types/logic/translator.d.ts +16 -0
- package/src/types/logic/translator.js +144 -88
- package/src/types/logic/translator_backup.js +5 -16
- package/src/types/nuims/Nuims.ts +11 -5
- package/src/types/page/Element.ts +63 -75
- package/src/types/page/Event.ts +0 -3
- package/src/types/page/Page.ts +73 -40
- package/src/types/page/View.ts +45 -18
- package/src/types/page/ViewParam.ts +22 -3
- package/src/types/page/ViewVariable.ts +4 -8
- package/src/types/permission/Permission.ts +112 -0
- package/tsconfig.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// import stringify = require('json-stringify-safe');
|
|
2
1
|
import { action, circular, excludedInJSON, immutable } from '../decorators';
|
|
3
|
-
import { config,
|
|
2
|
+
import { config, utils, LEVEL_ENUM, Vertex, View, Attr, Directive, Event, ExpressionNode, dataTypesMap, LogicItem, ActionOptions, ACTION_MODE, Nuims, Structure } from '..';
|
|
4
3
|
import * as compiler from 'vue-template-compiler';
|
|
5
4
|
import * as json5 from 'json5';
|
|
6
|
-
import { elementService
|
|
5
|
+
import { elementService } from '../../service/page';
|
|
7
6
|
import { vertexsMap } from '../cacheData';
|
|
8
7
|
import Variable from '../logic/Variable';
|
|
9
8
|
import * as babelParser from '@babel/parser';
|
|
10
|
-
import { traverse } from '../utils';
|
|
11
9
|
import { isPlainObject, cloneDeep, mapValues } from 'lodash';
|
|
12
10
|
import * as utilsAll from '../../../src/types/utils/string';
|
|
11
|
+
import { refreshHtml } from '../cache';
|
|
12
|
+
import { BusinessCode } from '../enum';
|
|
13
13
|
|
|
14
14
|
export interface ElementToVueOptions {
|
|
15
15
|
indentStyle?: 'space' | 'tab';
|
|
@@ -29,6 +29,18 @@ export interface ParseContext {
|
|
|
29
29
|
[key: string]: any;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
export function catchFn(view: View) {
|
|
33
|
+
return async (err: any) => {
|
|
34
|
+
if(err.code !== BusinessCode.HasReferenced) // 节点被引用,不用刷新数据
|
|
35
|
+
await refreshHtml(view);
|
|
36
|
+
else
|
|
37
|
+
config.defaultApp?.emit('saved', err);
|
|
38
|
+
|
|
39
|
+
config.defaultApp?.history.load();
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
32
44
|
/**
|
|
33
45
|
* 前端页面元素
|
|
34
46
|
* @example
|
|
@@ -150,9 +162,6 @@ export class Element extends Vertex {
|
|
|
150
162
|
constructor(source?: Partial<Element>) {
|
|
151
163
|
super();
|
|
152
164
|
source && this.assign(source);
|
|
153
|
-
// 为了给生成的节点使用
|
|
154
|
-
// !this.id && this.assign({ id: uuidv4() });
|
|
155
|
-
// this.assign({ id: 'temp-' + uuidv4() });
|
|
156
165
|
}
|
|
157
166
|
assign(source?: any) {
|
|
158
167
|
['attrList', 'eventList', 'directiveList', 'children'].forEach((key) => {
|
|
@@ -172,7 +181,6 @@ export class Element extends Vertex {
|
|
|
172
181
|
}
|
|
173
182
|
|
|
174
183
|
config.defaultApp?.emit('saving');
|
|
175
|
-
try {
|
|
176
184
|
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
177
185
|
const body = this.toJSON();
|
|
178
186
|
body.parentId = this.parent && this.parent.id;
|
|
@@ -185,15 +193,7 @@ export class Element extends Vertex {
|
|
|
185
193
|
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
186
194
|
},
|
|
187
195
|
body,
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
// Nuims createResource
|
|
191
|
-
// Element 对应资源增删在 undo/redo 情况下可能存在权限丢失的情况
|
|
192
|
-
// 暂时只增不减
|
|
193
|
-
// new Nuims({
|
|
194
|
-
// domainName: this.view.page.service.app.name,
|
|
195
|
-
// element: this,
|
|
196
|
-
// }).createResource();
|
|
196
|
+
}).catch(catchFn(this.view));
|
|
197
197
|
|
|
198
198
|
this.deepPick(result, ['id', 'parentId', 'elementId']);
|
|
199
199
|
// attr,directive,event的id,exprssion需要合并
|
|
@@ -220,14 +220,6 @@ export class Element extends Vertex {
|
|
|
220
220
|
config.defaultApp?.emit('saved');
|
|
221
221
|
}
|
|
222
222
|
return this;
|
|
223
|
-
} catch (err) {
|
|
224
|
-
if (this.view) {
|
|
225
|
-
await this.view.load();
|
|
226
|
-
this.view.emit('change');
|
|
227
|
-
config.defaultApp?.emit('saved');
|
|
228
|
-
}
|
|
229
|
-
throw err;
|
|
230
|
-
}
|
|
231
223
|
}
|
|
232
224
|
/**
|
|
233
225
|
* 删除元素
|
|
@@ -248,7 +240,6 @@ export class Element extends Vertex {
|
|
|
248
240
|
|
|
249
241
|
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
250
242
|
if (this.id) {
|
|
251
|
-
try {
|
|
252
243
|
await elementService.delete({
|
|
253
244
|
headers: {
|
|
254
245
|
appId: config.defaultApp?.id,
|
|
@@ -258,19 +249,7 @@ export class Element extends Vertex {
|
|
|
258
249
|
query: {
|
|
259
250
|
id: this.id,
|
|
260
251
|
},
|
|
261
|
-
});
|
|
262
|
-
} catch (err) {
|
|
263
|
-
await config.defaultApp?.history.load();
|
|
264
|
-
throw err;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Nuims deleteResource
|
|
268
|
-
// Element 对应资源增删在 undo/redo 情况下可能存在权限丢失的情况
|
|
269
|
-
// 暂时只增不减
|
|
270
|
-
// new Nuims({
|
|
271
|
-
// domainName: this.view.page.service.app.name,
|
|
272
|
-
// element: this,
|
|
273
|
-
// }).deleteResources();
|
|
252
|
+
}).catch(catchFn(this.view));
|
|
274
253
|
}
|
|
275
254
|
}
|
|
276
255
|
|
|
@@ -295,7 +274,6 @@ export class Element extends Vertex {
|
|
|
295
274
|
config.defaultApp?.emit('saving');
|
|
296
275
|
|
|
297
276
|
source && this.assign(source);
|
|
298
|
-
try {
|
|
299
277
|
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
300
278
|
const body = this.toPlainJSON();
|
|
301
279
|
utils.logger.debug('修改组件', body);
|
|
@@ -306,28 +284,41 @@ export class Element extends Vertex {
|
|
|
306
284
|
operationDesc: actionOptions?.actionDesc || `修改组件"${this.getElementTitle()}"`,
|
|
307
285
|
},
|
|
308
286
|
body,
|
|
309
|
-
});
|
|
287
|
+
}).catch(catchFn(this.view));
|
|
310
288
|
}
|
|
311
289
|
|
|
312
290
|
this.view && this.view.emit('change');
|
|
313
291
|
await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
|
|
314
292
|
operationAction: 'Element.update',
|
|
315
|
-
operationBeforeImage: null,
|
|
293
|
+
operationBeforeImage: null,
|
|
316
294
|
operationAfterImage: null,
|
|
317
295
|
operationDesc: `修改组件"${this.getElementTitle()}"`,
|
|
318
296
|
});
|
|
319
297
|
|
|
320
298
|
config.defaultApp?.emit('saved');
|
|
321
299
|
return this;
|
|
322
|
-
} catch (err) {
|
|
323
|
-
if (this.view) {
|
|
324
|
-
await this.view.load();
|
|
325
|
-
this.view.emit('change');
|
|
326
|
-
config.defaultApp?.emit('saved');
|
|
327
|
-
}
|
|
328
|
-
throw err;
|
|
329
|
-
}
|
|
330
300
|
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* 按当前 id 加载逻辑数据
|
|
304
|
+
*/
|
|
305
|
+
async load() {
|
|
306
|
+
if (!this.id)
|
|
307
|
+
return;
|
|
308
|
+
|
|
309
|
+
const result = await elementService.load({
|
|
310
|
+
headers: {
|
|
311
|
+
appId: config.defaultApp?.id,
|
|
312
|
+
},
|
|
313
|
+
query: {
|
|
314
|
+
id: this.id,
|
|
315
|
+
},
|
|
316
|
+
config: { noErrorTip: true },
|
|
317
|
+
});
|
|
318
|
+
const newElement = Element.from(result, this.parent, this.view);
|
|
319
|
+
this.assign(newElement);
|
|
320
|
+
}
|
|
321
|
+
|
|
331
322
|
async move(options: {
|
|
332
323
|
parentId?: string,
|
|
333
324
|
_posIndex?: number,
|
|
@@ -365,11 +356,16 @@ export class Element extends Vertex {
|
|
|
365
356
|
}
|
|
366
357
|
|
|
367
358
|
config.defaultApp?.emit('element.moved');
|
|
359
|
+
config.defaultApp?.emit('saved');
|
|
368
360
|
} catch (err) {
|
|
369
361
|
if (this.view) {
|
|
370
362
|
await this.view.load();
|
|
371
363
|
this.view.emit('change');
|
|
372
364
|
}
|
|
365
|
+
config.defaultApp?.emit('saved', {
|
|
366
|
+
action: 'move',
|
|
367
|
+
err,
|
|
368
|
+
});
|
|
373
369
|
throw err;
|
|
374
370
|
}
|
|
375
371
|
}
|
|
@@ -383,7 +379,6 @@ export class Element extends Vertex {
|
|
|
383
379
|
|
|
384
380
|
const index = this.parent.children.indexOf(this);
|
|
385
381
|
const newNode = Element.fromHTML(code, this.parent, this.view);
|
|
386
|
-
|
|
387
382
|
|
|
388
383
|
const mergeExpression = (originList: Array<Attr|Directive>, newList: Array<Attr|Directive>) => {
|
|
389
384
|
newList.forEach((item) => {
|
|
@@ -437,7 +432,7 @@ export class Element extends Vertex {
|
|
|
437
432
|
};
|
|
438
433
|
|
|
439
434
|
const arrayComp = this.findElementsByTag('u-modal');
|
|
440
|
-
const existingNames = Object.values(mapValues(arrayComp,
|
|
435
|
+
const existingNames = Object.values(mapValues(arrayComp, (o) => o.name));
|
|
441
436
|
// 处理弹窗组件的命名问题
|
|
442
437
|
if (newNode.tag === 'u-modal') {
|
|
443
438
|
Object.assign(newNode, {
|
|
@@ -501,11 +496,14 @@ export class Element extends Vertex {
|
|
|
501
496
|
await this.update(undefined, {
|
|
502
497
|
actionDesc: `设置组件"${this.getElementTitle()}"的名称为"${name}"`,
|
|
503
498
|
});
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
499
|
+
|
|
500
|
+
if (!(window as any).globalData.hasUserCenter) {
|
|
501
|
+
// 同步权限
|
|
502
|
+
new Nuims({
|
|
503
|
+
domainName: this.view.page.service.app.name,
|
|
504
|
+
element: this,
|
|
505
|
+
}).editResourceFromResourceValue(oldName ? `${this.view.tempPath}/${oldName}` : null);
|
|
506
|
+
}
|
|
509
507
|
|
|
510
508
|
this.view && this.view.emit('change');
|
|
511
509
|
if (this.view && this.view.page && this.view.page.service) {
|
|
@@ -554,9 +552,7 @@ export class Element extends Vertex {
|
|
|
554
552
|
async setAttr(name: string, type: 'string' | 'static' | 'dynamic', value?: any) {
|
|
555
553
|
let attr = this.getAttr(name);
|
|
556
554
|
//
|
|
557
|
-
if (value
|
|
558
|
-
|
|
559
|
-
} else {
|
|
555
|
+
if (value !== undefined) {
|
|
560
556
|
if (typeof value !== 'string')
|
|
561
557
|
value = JSON.stringify(value);
|
|
562
558
|
|
|
@@ -567,7 +563,7 @@ export class Element extends Vertex {
|
|
|
567
563
|
});
|
|
568
564
|
await attr.update(undefined, {
|
|
569
565
|
actionDesc: `设置组件"${this.getElementTitle()}"属性"${attr.name}"的值为"${attr.value}"`,
|
|
570
|
-
});
|
|
566
|
+
}).catch(catchFn(this.view));
|
|
571
567
|
} else {
|
|
572
568
|
attr = Attr.from({
|
|
573
569
|
name,
|
|
@@ -577,7 +573,7 @@ export class Element extends Vertex {
|
|
|
577
573
|
}, this);
|
|
578
574
|
await attr.create(undefined, {
|
|
579
575
|
actionDesc: `设置组件"${this.getElementTitle()}"属性"${attr.name}"的值为"${attr.value}"`,
|
|
580
|
-
});
|
|
576
|
+
}).catch(catchFn(this.view));
|
|
581
577
|
this.attrList.push(attr);
|
|
582
578
|
}
|
|
583
579
|
}
|
|
@@ -594,7 +590,7 @@ export class Element extends Vertex {
|
|
|
594
590
|
|
|
595
591
|
await event.create(undefined, Object.assign({
|
|
596
592
|
actionDesc: `添加组件"${this.getElementTitle()}"事件"${event.name}"`,
|
|
597
|
-
}, actionOptions));
|
|
593
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
598
594
|
event = Event.from(event, this);
|
|
599
595
|
this.eventList.push(event);
|
|
600
596
|
|
|
@@ -617,7 +613,7 @@ export class Element extends Vertex {
|
|
|
617
613
|
|
|
618
614
|
await event.delete(undefined, Object.assign({
|
|
619
615
|
actionDesc: `删除组件"${this.getElementTitle()}"事件"${event.name}"`,
|
|
620
|
-
}, actionOptions));
|
|
616
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
621
617
|
const index = this.eventList.indexOf(event);
|
|
622
618
|
~index && this.eventList.splice(index, 1);
|
|
623
619
|
|
|
@@ -635,7 +631,7 @@ export class Element extends Vertex {
|
|
|
635
631
|
const directive = new Directive(data);
|
|
636
632
|
await directive.create(undefined, Object.assign({
|
|
637
633
|
actionDesc: `添加组件"${this.getElementTitle()}"指令"${directive.name}"`,
|
|
638
|
-
}, actionOptions));
|
|
634
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
639
635
|
this.directiveList.push(Directive.from(directive, this));
|
|
640
636
|
|
|
641
637
|
this.view && this.view.emit('change');
|
|
@@ -652,7 +648,7 @@ export class Element extends Vertex {
|
|
|
652
648
|
|
|
653
649
|
await directive.delete(undefined, Object.assign({
|
|
654
650
|
actionDesc: `删除组件"${this.getElementTitle()}"属性"${directive.name}"`,
|
|
655
|
-
}, actionOptions));
|
|
651
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
656
652
|
const index = this.directiveList.indexOf(directive);
|
|
657
653
|
~index && this.directiveList.splice(index, 1);
|
|
658
654
|
|
|
@@ -839,7 +835,7 @@ export class Element extends Vertex {
|
|
|
839
835
|
findElementsByTagInChildren(children: Array<any>, tag: string, existingNames: Array<any>) {
|
|
840
836
|
for (const child of children) {
|
|
841
837
|
const result = child.findElementByTag(tag);
|
|
842
|
-
|
|
838
|
+
|
|
843
839
|
if (child.children) {
|
|
844
840
|
this.findElementsByTagInChildren(child.children, tag, existingNames);
|
|
845
841
|
}
|
|
@@ -892,8 +888,6 @@ export class Element extends Vertex {
|
|
|
892
888
|
}
|
|
893
889
|
}
|
|
894
890
|
|
|
895
|
-
// if (astNode.tag === 'template')
|
|
896
|
-
// astNode.tag = 'div';
|
|
897
891
|
element = new Element({
|
|
898
892
|
tag: astNode.tag,
|
|
899
893
|
name: astNode.attrsMap.ref,
|
|
@@ -934,7 +928,6 @@ export class Element extends Vertex {
|
|
|
934
928
|
}
|
|
935
929
|
}
|
|
936
930
|
element.attrList.push(attr);
|
|
937
|
-
// element.attrMap[attr.name] = attr;
|
|
938
931
|
});
|
|
939
932
|
|
|
940
933
|
// compiler 处理:value.sync 时会加上update:value事件,需要过滤
|
|
@@ -946,10 +939,6 @@ export class Element extends Vertex {
|
|
|
946
939
|
value,
|
|
947
940
|
logicId: value[0] === '$' ? undefined : value,
|
|
948
941
|
}, element));
|
|
949
|
-
// element.eventMap[name] = new Event({
|
|
950
|
-
// name,
|
|
951
|
-
// value: oldEvent.value,
|
|
952
|
-
// });
|
|
953
942
|
});
|
|
954
943
|
|
|
955
944
|
astNode.directives && astNode.directives.forEach((directive) => {
|
|
@@ -976,7 +965,6 @@ export class Element extends Vertex {
|
|
|
976
965
|
arg: directive.arg,
|
|
977
966
|
modifiers: directive.modifiers,
|
|
978
967
|
}, element));
|
|
979
|
-
// element.directiveMap[directive.name] = );
|
|
980
968
|
}
|
|
981
969
|
});
|
|
982
970
|
|
package/src/types/page/Event.ts
CHANGED
|
@@ -3,10 +3,7 @@ import { action, circular, excludedInJSON, immutable } from '../decorators';
|
|
|
3
3
|
import { config, history, utils, LEVEL_ENUM, Vertex, PackageJSON, App, Page, DataNode, View, Element, ExpressionNode, Logic, genFinalCode, ActionOptions, ACTION_MODE } from '..';
|
|
4
4
|
import { elementService, attributeService, eventService, directiveService } from '../../service/page';
|
|
5
5
|
import * as babel from '@babel/core';
|
|
6
|
-
import { traverse } from '../utils';
|
|
7
|
-
import generate from '@babel/generator';
|
|
8
6
|
import { vertexsMap } from '../cacheData';
|
|
9
|
-
import Variable from '../logic/Variable';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* 前端组件事件
|
package/src/types/page/Page.ts
CHANGED
|
@@ -3,6 +3,23 @@ import { config, history, LEVEL_ENUM, Vertex, Entity, Enum, PackageJSON, App, We
|
|
|
3
3
|
import pageService from '../../service/page';
|
|
4
4
|
import { traverse } from '../utils';
|
|
5
5
|
import { postServiceType } from '../../service/common/preprocess';
|
|
6
|
+
import { refreshPages } from '../cache';
|
|
7
|
+
import { BusinessCode } from '../enum';
|
|
8
|
+
|
|
9
|
+
export function catchFn() {
|
|
10
|
+
return async (err: any) => {
|
|
11
|
+
const code = err?.code;
|
|
12
|
+
// 节点已存在; 节点不存在; 父节点不存在
|
|
13
|
+
if ([BusinessCode.ElementExist, BusinessCode.ElementNotExist, BusinessCode.ParentElementNotExist].includes(code)) {
|
|
14
|
+
await refreshPages();
|
|
15
|
+
} else
|
|
16
|
+
config.defaultApp?.emit('saved', err);
|
|
17
|
+
|
|
18
|
+
config.defaultApp?.history.load();
|
|
19
|
+
|
|
20
|
+
throw err;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
6
23
|
|
|
7
24
|
/**
|
|
8
25
|
* 页面(入口页)类,后端路由控制
|
|
@@ -95,13 +112,12 @@ export class Page extends Vertex {
|
|
|
95
112
|
}, { node: this.rootView });
|
|
96
113
|
const rootView = new View(this.rootView);
|
|
97
114
|
rootView.assign({ page: this });
|
|
98
|
-
|
|
115
|
+
|
|
99
116
|
this.assign({ rootView });
|
|
100
117
|
}
|
|
101
118
|
|
|
102
119
|
addData(res: any) {
|
|
103
120
|
const microService = this.service.app.firstMicroService;
|
|
104
|
-
|
|
105
121
|
|
|
106
122
|
const enums = res.enums as Array<Enum>;
|
|
107
123
|
if (enums && enums.length) {
|
|
@@ -153,8 +169,8 @@ export class Page extends Vertex {
|
|
|
153
169
|
operationDesc: actionOptions?.actionDesc || `添加页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
154
170
|
},
|
|
155
171
|
body,
|
|
156
|
-
});
|
|
157
|
-
|
|
172
|
+
}).catch(catchFn());
|
|
173
|
+
|
|
158
174
|
this.deepPick(result.page, ['id']);
|
|
159
175
|
// 添加数据和接口
|
|
160
176
|
this.addData(result);
|
|
@@ -170,8 +186,8 @@ export class Page extends Vertex {
|
|
|
170
186
|
tempPath: `/${rootView.name}`,
|
|
171
187
|
code: `/ID_${rootView.id}`,
|
|
172
188
|
});
|
|
173
|
-
|
|
174
|
-
if(result.page.isIndex) {
|
|
189
|
+
this.rootView.attachNodePath();
|
|
190
|
+
if (result.page.isIndex) {
|
|
175
191
|
const tasks = this.service.pages.filter((page) => page.isIndex && page.id !== result.page.id)
|
|
176
192
|
.map((page) => {
|
|
177
193
|
page.assign({ isIndex: false });
|
|
@@ -179,7 +195,7 @@ export class Page extends Vertex {
|
|
|
179
195
|
});
|
|
180
196
|
Promise.all(tasks);
|
|
181
197
|
}
|
|
182
|
-
|
|
198
|
+
|
|
183
199
|
await then?.();
|
|
184
200
|
this.service.emit('pageTreeChange');
|
|
185
201
|
|
|
@@ -187,10 +203,10 @@ export class Page extends Vertex {
|
|
|
187
203
|
microService.emit('dataTypesChange');
|
|
188
204
|
microService.emit('enumsChange');
|
|
189
205
|
microService.emit('vertexIdToNameChange');
|
|
190
|
-
|
|
206
|
+
|
|
191
207
|
this.rootView.emit('change');
|
|
192
208
|
// this.assign(Page.from(this, this.service));
|
|
193
|
-
|
|
209
|
+
|
|
194
210
|
await config.defaultApp?.history.load();
|
|
195
211
|
config.defaultApp?.emit('saved');
|
|
196
212
|
return this;
|
|
@@ -215,7 +231,7 @@ export class Page extends Vertex {
|
|
|
215
231
|
});
|
|
216
232
|
this.deepPick(result, ['id']);
|
|
217
233
|
this.rootView.attachNodePath();
|
|
218
|
-
if(result.isIndex) {
|
|
234
|
+
if (result.isIndex) {
|
|
219
235
|
const tasks = this.service.pages.filter((page) => page.isIndex && page.id !== result.id)
|
|
220
236
|
.map((page) => {
|
|
221
237
|
page.assign({ isIndex: false });
|
|
@@ -223,12 +239,12 @@ export class Page extends Vertex {
|
|
|
223
239
|
});
|
|
224
240
|
Promise.all(tasks);
|
|
225
241
|
}
|
|
226
|
-
|
|
242
|
+
|
|
227
243
|
await then?.();
|
|
228
244
|
this.service.emit('pageTreeChange');
|
|
229
245
|
this.rootView.emit('change');
|
|
230
246
|
// this.assign(Page.from(this, this.service));
|
|
231
|
-
|
|
247
|
+
|
|
232
248
|
await config.defaultApp?.history.load();
|
|
233
249
|
config.defaultApp?.emit('saved');
|
|
234
250
|
return this;
|
|
@@ -240,21 +256,16 @@ export class Page extends Vertex {
|
|
|
240
256
|
async delete(none?: void, actionOptions?: ActionOptions) {
|
|
241
257
|
config.defaultApp?.emit('saving');
|
|
242
258
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
});
|
|
254
|
-
} catch(err) {
|
|
255
|
-
await config.defaultApp?.history.load();
|
|
256
|
-
throw err;
|
|
257
|
-
}
|
|
259
|
+
await pageService.removePage({
|
|
260
|
+
headers: {
|
|
261
|
+
appId: config.defaultApp?.id,
|
|
262
|
+
operationAction: actionOptions?.actionName || 'Page.delete',
|
|
263
|
+
operationDesc: actionOptions?.actionDesc || `删除页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
264
|
+
},
|
|
265
|
+
path: {
|
|
266
|
+
id: this.id,
|
|
267
|
+
},
|
|
268
|
+
}).catch(catchFn());
|
|
258
269
|
|
|
259
270
|
const index = this.service.pages.indexOf(this);
|
|
260
271
|
~index && this.service.pages.splice(index, 1);
|
|
@@ -279,7 +290,7 @@ export class Page extends Vertex {
|
|
|
279
290
|
operationDesc: actionOptions?.actionDesc || `修改页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
280
291
|
},
|
|
281
292
|
body,
|
|
282
|
-
});
|
|
293
|
+
}).catch(catchFn());
|
|
283
294
|
|
|
284
295
|
await config.defaultApp?.history.load();
|
|
285
296
|
config.defaultApp?.emit('saved');
|
|
@@ -292,19 +303,41 @@ export class Page extends Vertex {
|
|
|
292
303
|
async setAsIndex() {
|
|
293
304
|
config.defaultApp?.emit('saving');
|
|
294
305
|
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
306
|
+
const oldIndexPages: Array<Page> = this.service.pages.filter((page) => page.isIndex);
|
|
307
|
+
const rejectedPages: Array<Page> = [];
|
|
308
|
+
const tasks = oldIndexPages.map((page) => {
|
|
309
|
+
page.assign({ isIndex: false });
|
|
310
|
+
return page.update().catch((e) => {
|
|
311
|
+
rejectedPages.push(page);
|
|
312
|
+
return Promise.reject(e);
|
|
299
313
|
});
|
|
300
|
-
|
|
301
|
-
tasks.push(this.update(undefined, {
|
|
302
|
-
actionDesc: `设置页面"${this.name}"为首页`,
|
|
303
|
-
}));
|
|
304
|
-
await Promise.all(tasks);
|
|
314
|
+
});
|
|
305
315
|
|
|
306
|
-
|
|
316
|
+
// 去掉旧首页
|
|
317
|
+
try {
|
|
318
|
+
await Promise.all(tasks);
|
|
319
|
+
} catch (e) {
|
|
320
|
+
// 恢复状态
|
|
321
|
+
rejectedPages.forEach((page) => page.assign({ isIndex: true }));
|
|
307
322
|
|
|
323
|
+
this.service.emit('pageTreeChange');
|
|
324
|
+
await config.defaultApp?.history.load();
|
|
325
|
+
config.defaultApp?.emit('saved');
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// 设置新首页
|
|
330
|
+
try {
|
|
331
|
+
this.assign({ isIndex: true });
|
|
332
|
+
await this.update(undefined, {
|
|
333
|
+
actionDesc: `设置页面"${this.name}"为首页`,
|
|
334
|
+
});
|
|
335
|
+
} catch (e) {
|
|
336
|
+
// 恢复状态
|
|
337
|
+
this.assign({ isIndex: false });
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
this.service.emit('pageTreeChange');
|
|
308
341
|
await config.defaultApp?.history.load();
|
|
309
342
|
config.defaultApp?.emit('saved');
|
|
310
343
|
}
|
|
@@ -356,8 +389,8 @@ export class Page extends Vertex {
|
|
|
356
389
|
page.assign({
|
|
357
390
|
rootView: View.from(page.rootView, null, page),
|
|
358
391
|
service,
|
|
359
|
-
tempPath: page.rootView? `/${page.rootView.name}
|
|
360
|
-
code: page.rootView
|
|
392
|
+
tempPath: page.rootView ? `/${page.rootView.name}` : '',
|
|
393
|
+
code: page.rootView ? `/ID_${page.rootView.id}` : '',
|
|
361
394
|
});
|
|
362
395
|
|
|
363
396
|
return page;
|