@lcap/nasl 0.3.9-beta → 0.3.10-beta.oom2
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 -0
- package/out/types/app/App.js +29 -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 +5 -1
- package/out/types/index.js +8 -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 +28 -0
- package/out/types/logic/Logic.js +116 -31
- package/out/types/logic/Logic.js.map +1 -1
- package/out/types/logic/LogicItem.d.ts +1 -0
- package/out/types/logic/LogicItem.js +43 -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 +8 -0
- package/out/types/page/Element.js +145 -129
- 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 +71 -37
- package/out/types/page/Page.js.map +1 -1
- package/out/types/page/View.d.ts +1 -1
- package/out/types/page/View.js +50 -42
- 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 -3
- package/src/service/create/errHandles.js +6 -2
- 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 +32 -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 +5 -1
- package/src/types/logic/Logic.ts +109 -28
- package/src/types/logic/LogicItem.ts +48 -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.js +0 -4
- package/src/types/logic/translator_backup.js +5 -16
- package/src/types/nuims/Nuims.ts +11 -5
- package/src/types/page/Element.ts +101 -73
- package/src/types/page/Event.ts +0 -3
- package/src/types/page/Page.ts +86 -49
- package/src/types/page/View.ts +31 -22
- package/src/types/page/ViewParam.ts +22 -3
- package/src/types/page/ViewVariable.ts +4 -8
- package/src/types/permission/Permission.ts +112 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import generate from '@babel/generator';
|
|
2
2
|
import * as babel from '@babel/core';
|
|
3
|
-
import {
|
|
4
|
-
import { Vertex, vertexesMap, utils } from '..';
|
|
5
|
-
import { getQuerySchemaMap } from './tools';
|
|
3
|
+
import { Vertex, utils } from '..';
|
|
6
4
|
|
|
7
5
|
function switchCase2If(cases) {
|
|
8
6
|
const cas = cases.shift();
|
|
@@ -81,9 +79,7 @@ export default function (source) {
|
|
|
81
79
|
} else if (node.type === 'MemberExpression') {
|
|
82
80
|
return checkThis(node.object);
|
|
83
81
|
} else if (node.type === 'CallExpression') {
|
|
84
|
-
(node.arguments || []).forEach((arg) =>
|
|
85
|
-
return checkThis(arg);
|
|
86
|
-
});
|
|
82
|
+
(node.arguments || []).forEach((arg) => checkThis(arg));
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
85
|
function safeGenerate(node) {
|
|
@@ -586,7 +582,7 @@ export default function (source) {
|
|
|
586
582
|
const jsBlock_${index} = async () => {
|
|
587
583
|
${node.code}
|
|
588
584
|
}
|
|
589
|
-
|
|
585
|
+
|
|
590
586
|
await jsBlock_${index}();
|
|
591
587
|
}`,
|
|
592
588
|
{
|
|
@@ -600,16 +596,9 @@ export default function (source) {
|
|
|
600
596
|
}
|
|
601
597
|
});
|
|
602
598
|
|
|
603
|
-
// console.info("JSON generate:", JSON.stringify(logic.body));
|
|
604
|
-
// console.log(generate({ type: 'Program', body: logic.body }).code);
|
|
605
|
-
|
|
606
599
|
return `methods['${logic.name}'] = async function (${logic.params.map((param) => param.name).join(', ')}) {
|
|
607
|
-
${logic.params.length ? logic.params.map((param) => {
|
|
608
|
-
|
|
609
|
-
}).join('\n') + '' : ''}
|
|
610
|
-
${logic.variables.length ? logic.variables.map((variable) => {
|
|
611
|
-
return `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});`;
|
|
612
|
-
}).join('\n') + '' : ''}
|
|
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') + '' : ''}
|
|
613
602
|
let ${returnObj.name} = this.$genInitFromSchema(${JSON.stringify(returnObj.schema)}, ${JSON.stringify(returnObj.defaultValue)});
|
|
614
603
|
${generate({ type: 'Program', body: logic.body }).code}
|
|
615
604
|
}`;
|
package/src/types/nuims/Nuims.ts
CHANGED
|
@@ -17,7 +17,7 @@ interface RoleItem extends Role {
|
|
|
17
17
|
toggling?: Boolean,
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
interface Permission{
|
|
20
|
+
interface Permission {
|
|
21
21
|
DomainName: string,
|
|
22
22
|
PermissionId: string,
|
|
23
23
|
PermissionValue: string,
|
|
@@ -79,7 +79,7 @@ export class Nuims {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
async getInitRoles() {
|
|
82
|
+
async getInitRoles(auto: unknown) {
|
|
83
83
|
let isCreated = false;
|
|
84
84
|
let resource = await this.getResource();
|
|
85
85
|
if (!resource) {
|
|
@@ -99,9 +99,15 @@ export class Nuims {
|
|
|
99
99
|
await this.bindRolesAndPermissions(role, permission);
|
|
100
100
|
}
|
|
101
101
|
roleName2Permission.set(role.RoleName, permission);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
if (auto) {
|
|
103
|
+
if ((ResourceValue === '/dashboard' || ((ResourceValue === '/index' || ResourceValue === '/user') && config.scope === 'h5')) && role.RoleName === 'DEV-AdminRole') {
|
|
104
|
+
await this.attachPermissionResourceAction();
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
// 创建 /dashboard 资源时自动关联 DEV-AdminRole 权限
|
|
108
|
+
if (isCreated && (ResourceValue === '/dashboard' || ((ResourceValue === '/index' || ResourceValue === '/user') && config.scope === 'h5')) && role.RoleName === 'DEV-AdminRole') {
|
|
109
|
+
await this.attachPermissionResourceAction();
|
|
110
|
+
}
|
|
105
111
|
}
|
|
106
112
|
roleItem.permission = permission;
|
|
107
113
|
const resources = await this.getResourcesFromPermission(permission);
|
|
@@ -1,14 +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 {
|
|
11
|
-
import
|
|
9
|
+
import { isPlainObject, cloneDeep, mapValues } from 'lodash';
|
|
10
|
+
import * as utilsAll from '../../../src/types/utils/string';
|
|
11
|
+
import { refreshHtml } from '../cache';
|
|
12
|
+
import { BusinessCode } from '../enum';
|
|
12
13
|
|
|
13
14
|
export interface ElementToVueOptions {
|
|
14
15
|
indentStyle?: 'space' | 'tab';
|
|
@@ -28,6 +29,18 @@ export interface ParseContext {
|
|
|
28
29
|
[key: string]: any;
|
|
29
30
|
}
|
|
30
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
|
+
|
|
31
44
|
/**
|
|
32
45
|
* 前端页面元素
|
|
33
46
|
* @example
|
|
@@ -142,15 +155,13 @@ export class Element extends Vertex {
|
|
|
142
155
|
*/
|
|
143
156
|
@immutable()
|
|
144
157
|
public readonly children?: Array<Element> = [];
|
|
158
|
+
|
|
145
159
|
/**
|
|
146
160
|
* @param source 需要合并的部分参数
|
|
147
161
|
*/
|
|
148
162
|
constructor(source?: Partial<Element>) {
|
|
149
163
|
super();
|
|
150
164
|
source && this.assign(source);
|
|
151
|
-
// 为了给生成的节点使用
|
|
152
|
-
// !this.id && this.assign({ id: uuidv4() });
|
|
153
|
-
// this.assign({ id: 'temp-' + uuidv4() });
|
|
154
165
|
}
|
|
155
166
|
assign(source?: any) {
|
|
156
167
|
['attrList', 'eventList', 'directiveList', 'children'].forEach((key) => {
|
|
@@ -170,7 +181,6 @@ export class Element extends Vertex {
|
|
|
170
181
|
}
|
|
171
182
|
|
|
172
183
|
config.defaultApp?.emit('saving');
|
|
173
|
-
try {
|
|
174
184
|
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
175
185
|
const body = this.toJSON();
|
|
176
186
|
body.parentId = this.parent && this.parent.id;
|
|
@@ -183,15 +193,7 @@ export class Element extends Vertex {
|
|
|
183
193
|
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
184
194
|
},
|
|
185
195
|
body,
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
// Nuims createResource
|
|
189
|
-
// Element 对应资源增删在 undo/redo 情况下可能存在权限丢失的情况
|
|
190
|
-
// 暂时只增不减
|
|
191
|
-
// new Nuims({
|
|
192
|
-
// domainName: this.view.page.service.app.name,
|
|
193
|
-
// element: this,
|
|
194
|
-
// }).createResource();
|
|
196
|
+
}).catch(catchFn(this.view));
|
|
195
197
|
|
|
196
198
|
this.deepPick(result, ['id', 'parentId', 'elementId']);
|
|
197
199
|
// attr,directive,event的id,exprssion需要合并
|
|
@@ -218,14 +220,6 @@ export class Element extends Vertex {
|
|
|
218
220
|
config.defaultApp?.emit('saved');
|
|
219
221
|
}
|
|
220
222
|
return this;
|
|
221
|
-
} catch (err) {
|
|
222
|
-
if (this.view) {
|
|
223
|
-
await this.view.load();
|
|
224
|
-
this.view.emit('change');
|
|
225
|
-
config.defaultApp?.emit('saved');
|
|
226
|
-
}
|
|
227
|
-
throw err;
|
|
228
|
-
}
|
|
229
223
|
}
|
|
230
224
|
/**
|
|
231
225
|
* 删除元素
|
|
@@ -246,7 +240,6 @@ export class Element extends Vertex {
|
|
|
246
240
|
|
|
247
241
|
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
248
242
|
if (this.id) {
|
|
249
|
-
try {
|
|
250
243
|
await elementService.delete({
|
|
251
244
|
headers: {
|
|
252
245
|
appId: config.defaultApp?.id,
|
|
@@ -256,19 +249,7 @@ export class Element extends Vertex {
|
|
|
256
249
|
query: {
|
|
257
250
|
id: this.id,
|
|
258
251
|
},
|
|
259
|
-
});
|
|
260
|
-
} catch (err) {
|
|
261
|
-
await config.defaultApp?.history.load();
|
|
262
|
-
throw err;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Nuims deleteResource
|
|
266
|
-
// Element 对应资源增删在 undo/redo 情况下可能存在权限丢失的情况
|
|
267
|
-
// 暂时只增不减
|
|
268
|
-
// new Nuims({
|
|
269
|
-
// domainName: this.view.page.service.app.name,
|
|
270
|
-
// element: this,
|
|
271
|
-
// }).deleteResources();
|
|
252
|
+
}).catch(catchFn(this.view));
|
|
272
253
|
}
|
|
273
254
|
}
|
|
274
255
|
|
|
@@ -293,7 +274,6 @@ export class Element extends Vertex {
|
|
|
293
274
|
config.defaultApp?.emit('saving');
|
|
294
275
|
|
|
295
276
|
source && this.assign(source);
|
|
296
|
-
try {
|
|
297
277
|
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
298
278
|
const body = this.toPlainJSON();
|
|
299
279
|
utils.logger.debug('修改组件', body);
|
|
@@ -304,28 +284,41 @@ export class Element extends Vertex {
|
|
|
304
284
|
operationDesc: actionOptions?.actionDesc || `修改组件"${this.getElementTitle()}"`,
|
|
305
285
|
},
|
|
306
286
|
body,
|
|
307
|
-
});
|
|
287
|
+
}).catch(catchFn(this.view));
|
|
308
288
|
}
|
|
309
289
|
|
|
310
290
|
this.view && this.view.emit('change');
|
|
311
291
|
await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
|
|
312
292
|
operationAction: 'Element.update',
|
|
313
|
-
operationBeforeImage: null,
|
|
293
|
+
operationBeforeImage: null,
|
|
314
294
|
operationAfterImage: null,
|
|
315
295
|
operationDesc: `修改组件"${this.getElementTitle()}"`,
|
|
316
296
|
});
|
|
317
297
|
|
|
318
298
|
config.defaultApp?.emit('saved');
|
|
319
299
|
return this;
|
|
320
|
-
} catch (err) {
|
|
321
|
-
if (this.view) {
|
|
322
|
-
await this.view.load();
|
|
323
|
-
this.view.emit('change');
|
|
324
|
-
config.defaultApp?.emit('saved');
|
|
325
|
-
}
|
|
326
|
-
throw err;
|
|
327
|
-
}
|
|
328
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
|
+
|
|
329
322
|
async move(options: {
|
|
330
323
|
parentId?: string,
|
|
331
324
|
_posIndex?: number,
|
|
@@ -363,11 +356,16 @@ export class Element extends Vertex {
|
|
|
363
356
|
}
|
|
364
357
|
|
|
365
358
|
config.defaultApp?.emit('element.moved');
|
|
359
|
+
config.defaultApp?.emit('saved');
|
|
366
360
|
} catch (err) {
|
|
367
361
|
if (this.view) {
|
|
368
362
|
await this.view.load();
|
|
369
363
|
this.view.emit('change');
|
|
370
364
|
}
|
|
365
|
+
config.defaultApp?.emit('saved', {
|
|
366
|
+
action: 'move',
|
|
367
|
+
err,
|
|
368
|
+
});
|
|
371
369
|
throw err;
|
|
372
370
|
}
|
|
373
371
|
}
|
|
@@ -381,6 +379,7 @@ export class Element extends Vertex {
|
|
|
381
379
|
|
|
382
380
|
const index = this.parent.children.indexOf(this);
|
|
383
381
|
const newNode = Element.fromHTML(code, this.parent, this.view);
|
|
382
|
+
|
|
384
383
|
const mergeExpression = (originList: Array<Attr|Directive>, newList: Array<Attr|Directive>) => {
|
|
385
384
|
newList.forEach((item) => {
|
|
386
385
|
const originItem = originList.find((originItem) => originItem.name === item.name);
|
|
@@ -432,6 +431,15 @@ export class Element extends Vertex {
|
|
|
432
431
|
}
|
|
433
432
|
};
|
|
434
433
|
|
|
434
|
+
const arrayComp = this.findElementsByTag('u-modal');
|
|
435
|
+
const existingNames = Object.values(mapValues(arrayComp, (o) => o.name));
|
|
436
|
+
// 处理弹窗组件的命名问题
|
|
437
|
+
if (newNode.tag === 'u-modal') {
|
|
438
|
+
Object.assign(newNode, {
|
|
439
|
+
name: utilsAll.unique('saveModal1', existingNames as any),
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
|
|
435
443
|
traverseMergeNode(this, newNode);
|
|
436
444
|
~index && this.parent.children.splice(index + 1, 0, newNode);
|
|
437
445
|
this.parent.children.forEach((item, index) => {
|
|
@@ -488,11 +496,14 @@ export class Element extends Vertex {
|
|
|
488
496
|
await this.update(undefined, {
|
|
489
497
|
actionDesc: `设置组件"${this.getElementTitle()}"的名称为"${name}"`,
|
|
490
498
|
});
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
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
|
+
}
|
|
496
507
|
|
|
497
508
|
this.view && this.view.emit('change');
|
|
498
509
|
if (this.view && this.view.page && this.view.page.service) {
|
|
@@ -541,9 +552,7 @@ export class Element extends Vertex {
|
|
|
541
552
|
async setAttr(name: string, type: 'string' | 'static' | 'dynamic', value?: any) {
|
|
542
553
|
let attr = this.getAttr(name);
|
|
543
554
|
//
|
|
544
|
-
if (value
|
|
545
|
-
|
|
546
|
-
} else {
|
|
555
|
+
if (value !== undefined) {
|
|
547
556
|
if (typeof value !== 'string')
|
|
548
557
|
value = JSON.stringify(value);
|
|
549
558
|
|
|
@@ -554,7 +563,7 @@ export class Element extends Vertex {
|
|
|
554
563
|
});
|
|
555
564
|
await attr.update(undefined, {
|
|
556
565
|
actionDesc: `设置组件"${this.getElementTitle()}"属性"${attr.name}"的值为"${attr.value}"`,
|
|
557
|
-
});
|
|
566
|
+
}).catch(catchFn(this.view));
|
|
558
567
|
} else {
|
|
559
568
|
attr = Attr.from({
|
|
560
569
|
name,
|
|
@@ -564,7 +573,7 @@ export class Element extends Vertex {
|
|
|
564
573
|
}, this);
|
|
565
574
|
await attr.create(undefined, {
|
|
566
575
|
actionDesc: `设置组件"${this.getElementTitle()}"属性"${attr.name}"的值为"${attr.value}"`,
|
|
567
|
-
});
|
|
576
|
+
}).catch(catchFn(this.view));
|
|
568
577
|
this.attrList.push(attr);
|
|
569
578
|
}
|
|
570
579
|
}
|
|
@@ -581,7 +590,7 @@ export class Element extends Vertex {
|
|
|
581
590
|
|
|
582
591
|
await event.create(undefined, Object.assign({
|
|
583
592
|
actionDesc: `添加组件"${this.getElementTitle()}"事件"${event.name}"`,
|
|
584
|
-
}, actionOptions));
|
|
593
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
585
594
|
event = Event.from(event, this);
|
|
586
595
|
this.eventList.push(event);
|
|
587
596
|
|
|
@@ -604,7 +613,7 @@ export class Element extends Vertex {
|
|
|
604
613
|
|
|
605
614
|
await event.delete(undefined, Object.assign({
|
|
606
615
|
actionDesc: `删除组件"${this.getElementTitle()}"事件"${event.name}"`,
|
|
607
|
-
}, actionOptions));
|
|
616
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
608
617
|
const index = this.eventList.indexOf(event);
|
|
609
618
|
~index && this.eventList.splice(index, 1);
|
|
610
619
|
|
|
@@ -622,7 +631,7 @@ export class Element extends Vertex {
|
|
|
622
631
|
const directive = new Directive(data);
|
|
623
632
|
await directive.create(undefined, Object.assign({
|
|
624
633
|
actionDesc: `添加组件"${this.getElementTitle()}"指令"${directive.name}"`,
|
|
625
|
-
}, actionOptions));
|
|
634
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
626
635
|
this.directiveList.push(Directive.from(directive, this));
|
|
627
636
|
|
|
628
637
|
this.view && this.view.emit('change');
|
|
@@ -639,7 +648,7 @@ export class Element extends Vertex {
|
|
|
639
648
|
|
|
640
649
|
await directive.delete(undefined, Object.assign({
|
|
641
650
|
actionDesc: `删除组件"${this.getElementTitle()}"属性"${directive.name}"`,
|
|
642
|
-
}, actionOptions));
|
|
651
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
643
652
|
const index = this.directiveList.indexOf(directive);
|
|
644
653
|
~index && this.directiveList.splice(index, 1);
|
|
645
654
|
|
|
@@ -808,6 +817,33 @@ export class Element extends Vertex {
|
|
|
808
817
|
}
|
|
809
818
|
}
|
|
810
819
|
}
|
|
820
|
+
|
|
821
|
+
findElementsByTag(tag: string): Array<any> {
|
|
822
|
+
let existingNames: Array<any> = [];
|
|
823
|
+
existingNames = this.findElementsByTagCurrent(tag, existingNames);
|
|
824
|
+
this.findElementsByTagInChildren(this.view.$html.children, tag, existingNames);
|
|
825
|
+
return existingNames;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
findElementsByTagCurrent(tag: string, existingNames: Array<any>) {
|
|
829
|
+
if (this.tag === tag) {
|
|
830
|
+
existingNames.push(this);
|
|
831
|
+
}
|
|
832
|
+
return existingNames;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
findElementsByTagInChildren(children: Array<any>, tag: string, existingNames: Array<any>) {
|
|
836
|
+
for (const child of children) {
|
|
837
|
+
const result = child.findElementByTag(tag);
|
|
838
|
+
|
|
839
|
+
if (child.children) {
|
|
840
|
+
this.findElementsByTagInChildren(child.children, tag, existingNames);
|
|
841
|
+
}
|
|
842
|
+
if (result) {
|
|
843
|
+
existingNames.push(result);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
811
847
|
/**
|
|
812
848
|
* 从 Vue 的 ASTNode 转换成 ASL 元素
|
|
813
849
|
* @param astNode Vue 的 ASTNode
|
|
@@ -852,8 +888,6 @@ export class Element extends Vertex {
|
|
|
852
888
|
}
|
|
853
889
|
}
|
|
854
890
|
|
|
855
|
-
// if (astNode.tag === 'template')
|
|
856
|
-
// astNode.tag = 'div';
|
|
857
891
|
element = new Element({
|
|
858
892
|
tag: astNode.tag,
|
|
859
893
|
name: astNode.attrsMap.ref,
|
|
@@ -894,7 +928,6 @@ export class Element extends Vertex {
|
|
|
894
928
|
}
|
|
895
929
|
}
|
|
896
930
|
element.attrList.push(attr);
|
|
897
|
-
// element.attrMap[attr.name] = attr;
|
|
898
931
|
});
|
|
899
932
|
|
|
900
933
|
// compiler 处理:value.sync 时会加上update:value事件,需要过滤
|
|
@@ -906,10 +939,6 @@ export class Element extends Vertex {
|
|
|
906
939
|
value,
|
|
907
940
|
logicId: value[0] === '$' ? undefined : value,
|
|
908
941
|
}, element));
|
|
909
|
-
// element.eventMap[name] = new Event({
|
|
910
|
-
// name,
|
|
911
|
-
// value: oldEvent.value,
|
|
912
|
-
// });
|
|
913
942
|
});
|
|
914
943
|
|
|
915
944
|
astNode.directives && astNode.directives.forEach((directive) => {
|
|
@@ -936,7 +965,6 @@ export class Element extends Vertex {
|
|
|
936
965
|
arg: directive.arg,
|
|
937
966
|
modifiers: directive.modifiers,
|
|
938
967
|
}, element));
|
|
939
|
-
// element.directiveMap[directive.name] = );
|
|
940
968
|
}
|
|
941
969
|
});
|
|
942
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
|
* 前端组件事件
|