@lcap/nasl 0.3.9 → 0.3.10-beta.6
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/logic/logic.d.ts +50 -14
- package/out/service/logic/logic.js +26 -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 +30 -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/cacheData.js.map +1 -1
- 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/dataTypes.js +1 -1
- package/out/types/data/dataTypes.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/Logic.d.ts +32 -0
- package/out/types/logic/Logic.js +142 -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 +40 -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 +39 -10
- 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 +18 -0
- package/out/types/page/Element.js +174 -132
- 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 +9 -1
- package/out/types/page/View.js +75 -33
- 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/out/types/process/ProcessParam.js +3 -1
- package/out/types/process/ProcessParam.js.map +1 -1
- package/package.json +1 -2
- 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 +26 -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 +36 -1
- package/src/types/app/Service.ts +32 -3
- package/src/types/cache.ts +50 -0
- package/src/types/cacheData.ts +7 -7
- 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/dataTypes.ts +1 -1
- 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 +138 -28
- package/src/types/logic/LogicItem.ts +48 -28
- package/src/types/logic/Param.ts +39 -18
- package/src/types/logic/Return.ts +4 -9
- package/src/types/logic/Variable.ts +4 -8
- package/src/types/logic/translator.js +41 -13
- package/src/types/logic/translator_backup.js +5 -16
- package/src/types/nuims/Nuims.ts +11 -5
- package/src/types/page/Element.ts +187 -137
- package/src/types/page/Event.ts +0 -3
- package/src/types/page/Page.ts +73 -40
- package/src/types/page/View.ts +78 -32
- package/src/types/page/ViewParam.ts +22 -3
- package/src/types/page/ViewVariable.ts +4 -8
- package/src/types/page/dist/View.js +727 -0
- package/src/types/permission/Permission.ts +112 -0
- package/src/types/process/ProcessParam.ts +4 -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
|
@@ -25,8 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
return result;
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.Element = void 0;
|
|
29
|
-
// import stringify = require('json-stringify-safe');
|
|
28
|
+
exports.Element = exports.catchFn = void 0;
|
|
30
29
|
const decorators_1 = require("../decorators");
|
|
31
30
|
const __1 = require("..");
|
|
32
31
|
const compiler = __importStar(require("vue-template-compiler"));
|
|
@@ -35,7 +34,19 @@ const page_1 = require("../../service/page");
|
|
|
35
34
|
const cacheData_1 = require("../cacheData");
|
|
36
35
|
const babelParser = __importStar(require("@babel/parser"));
|
|
37
36
|
const lodash_1 = require("lodash");
|
|
38
|
-
const
|
|
37
|
+
const cache_1 = require("../cache");
|
|
38
|
+
const enum_1 = require("../enum");
|
|
39
|
+
function catchFn(view) {
|
|
40
|
+
return async (err) => {
|
|
41
|
+
if (err.code !== enum_1.BusinessCode.HasReferenced) // 节点被引用,不用刷新数据
|
|
42
|
+
await cache_1.refreshHtml(view);
|
|
43
|
+
else
|
|
44
|
+
__1.config.defaultApp?.emit('saved', err);
|
|
45
|
+
__1.config.defaultApp?.history.load();
|
|
46
|
+
throw err;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
exports.catchFn = catchFn;
|
|
39
50
|
/**
|
|
40
51
|
* 前端页面元素
|
|
41
52
|
* @example
|
|
@@ -134,9 +145,6 @@ class Element extends __1.Vertex {
|
|
|
134
145
|
*/
|
|
135
146
|
this.children = [];
|
|
136
147
|
source && this.assign(source);
|
|
137
|
-
// 为了给生成的节点使用
|
|
138
|
-
// !this.id && this.assign({ id: uuidv4() });
|
|
139
|
-
// this.assign({ id: 'temp-' + uuidv4() });
|
|
140
148
|
}
|
|
141
149
|
assign(source) {
|
|
142
150
|
['attrList', 'eventList', 'directiveList', 'children'].forEach((key) => {
|
|
@@ -154,59 +162,42 @@ class Element extends __1.Vertex {
|
|
|
154
162
|
return this;
|
|
155
163
|
}
|
|
156
164
|
__1.config.defaultApp?.emit('saving');
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
appId: __1.config.defaultApp?.id,
|
|
166
|
-
operationAction: 'Element.create',
|
|
167
|
-
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
168
|
-
},
|
|
169
|
-
body,
|
|
170
|
-
});
|
|
171
|
-
// Nuims createResource
|
|
172
|
-
// Element 对应资源增删在 undo/redo 情况下可能存在权限丢失的情况
|
|
173
|
-
// 暂时只增不减
|
|
174
|
-
// new Nuims({
|
|
175
|
-
// domainName: this.view.page.service.app.name,
|
|
176
|
-
// element: this,
|
|
177
|
-
// }).createResource();
|
|
178
|
-
this.deepPick(result, ['id', 'parentId', 'elementId']);
|
|
179
|
-
// attr,directive,event的id,exprssion需要合并
|
|
180
|
-
this.attrList.forEach((attr, index) => {
|
|
181
|
-
attr.deepPick(result.attrList[index], ['id', 'expression']);
|
|
182
|
-
});
|
|
183
|
-
this.directiveList.forEach((directive, index) => {
|
|
184
|
-
directive.deepPick(result.directiveList[index], ['id', 'expression']);
|
|
185
|
-
});
|
|
186
|
-
this.eventList.forEach((event, index) => {
|
|
187
|
-
event.deepPick(result.eventList[index], ['id']);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
this.view && this.view.emit('change');
|
|
191
|
-
if (actionOptions?.loadHistory !== false) {
|
|
192
|
-
await __1.config.defaultApp?.history.load(actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo && {
|
|
165
|
+
if (actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo) {
|
|
166
|
+
const body = this.toJSON();
|
|
167
|
+
body.parentId = this.parent && this.parent.id;
|
|
168
|
+
body._posIndex = this.parent && this.parent.children.indexOf(this);
|
|
169
|
+
__1.utils.logger.debug('添加元素', body);
|
|
170
|
+
const result = await page_1.elementService.create({
|
|
171
|
+
headers: {
|
|
172
|
+
appId: __1.config.defaultApp?.id,
|
|
193
173
|
operationAction: 'Element.create',
|
|
194
|
-
operationBeforeImage: null,
|
|
195
|
-
operationAfterImage: JSON.parse(JSON.stringify(this)),
|
|
196
174
|
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
175
|
+
},
|
|
176
|
+
body,
|
|
177
|
+
}).catch(catchFn(this.view));
|
|
178
|
+
this.deepPick(result, ['id', 'parentId', 'elementId']);
|
|
179
|
+
// attr,directive,event的id,expression需要合并
|
|
180
|
+
this.attrList.forEach((attr, index) => {
|
|
181
|
+
attr.deepPick(result.attrList[index], ['id', 'expression']);
|
|
182
|
+
});
|
|
183
|
+
this.directiveList.forEach((directive, index) => {
|
|
184
|
+
directive.deepPick(result.directiveList[index], ['id', 'expression']);
|
|
185
|
+
});
|
|
186
|
+
this.eventList.forEach((event, index) => {
|
|
187
|
+
event.deepPick(result.eventList[index], ['id']);
|
|
188
|
+
});
|
|
201
189
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
190
|
+
this.view && this.view.emit('change');
|
|
191
|
+
if (actionOptions?.loadHistory !== false) {
|
|
192
|
+
await __1.config.defaultApp?.history.load(actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo && {
|
|
193
|
+
operationAction: 'Element.create',
|
|
194
|
+
operationBeforeImage: null,
|
|
195
|
+
operationAfterImage: JSON.parse(JSON.stringify(this)),
|
|
196
|
+
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
197
|
+
});
|
|
198
|
+
__1.config.defaultApp?.emit('saved');
|
|
209
199
|
}
|
|
200
|
+
return this;
|
|
210
201
|
}
|
|
211
202
|
/**
|
|
212
203
|
* 删除元素
|
|
@@ -215,6 +206,7 @@ class Element extends __1.Vertex {
|
|
|
215
206
|
if (actionOptions?.actionMode === __1.ACTION_MODE.local) {
|
|
216
207
|
const index = this.parent.children.indexOf(this);
|
|
217
208
|
~index && this.parent.children.splice(index, 1);
|
|
209
|
+
this.deepRemoveElementsName();
|
|
218
210
|
this.view && this.view.emit('local-change');
|
|
219
211
|
return this;
|
|
220
212
|
}
|
|
@@ -223,33 +215,22 @@ class Element extends __1.Vertex {
|
|
|
223
215
|
throw Error('该元素为根节点!');
|
|
224
216
|
if (actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo) {
|
|
225
217
|
if (this.id) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
catch (err) {
|
|
239
|
-
await __1.config.defaultApp?.history.load();
|
|
240
|
-
throw err;
|
|
241
|
-
}
|
|
242
|
-
// Nuims deleteResource
|
|
243
|
-
// Element 对应资源增删在 undo/redo 情况下可能存在权限丢失的情况
|
|
244
|
-
// 暂时只增不减
|
|
245
|
-
// new Nuims({
|
|
246
|
-
// domainName: this.view.page.service.app.name,
|
|
247
|
-
// element: this,
|
|
248
|
-
// }).deleteResources();
|
|
218
|
+
await page_1.elementService.delete({
|
|
219
|
+
headers: {
|
|
220
|
+
appId: __1.config.defaultApp?.id,
|
|
221
|
+
operationAction: 'Element.delete',
|
|
222
|
+
operationDesc: `删除组件"${this.getElementTitle()}"`,
|
|
223
|
+
},
|
|
224
|
+
query: {
|
|
225
|
+
id: this.id,
|
|
226
|
+
},
|
|
227
|
+
}).catch(catchFn(this.view));
|
|
249
228
|
}
|
|
250
229
|
}
|
|
251
230
|
const index = this.parent.children.indexOf(this);
|
|
252
231
|
~index && this.parent.children.splice(index, 1);
|
|
232
|
+
// 递归删除组件名的缓存
|
|
233
|
+
this.deepRemoveElementsName();
|
|
253
234
|
this.destroy();
|
|
254
235
|
this.view && this.view.emit('change');
|
|
255
236
|
if (actionOptions?.loadHistory !== false) {
|
|
@@ -268,37 +249,45 @@ class Element extends __1.Vertex {
|
|
|
268
249
|
async update(source, actionOptions) {
|
|
269
250
|
__1.config.defaultApp?.emit('saving');
|
|
270
251
|
source && this.assign(source);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
this.view && this.view.emit('change');
|
|
285
|
-
await __1.config.defaultApp?.history.load(actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo && {
|
|
286
|
-
operationAction: 'Element.update',
|
|
287
|
-
operationBeforeImage: null,
|
|
288
|
-
operationAfterImage: null,
|
|
289
|
-
operationDesc: `修改组件"${this.getElementTitle()}"`,
|
|
290
|
-
});
|
|
291
|
-
__1.config.defaultApp?.emit('saved');
|
|
292
|
-
return this;
|
|
293
|
-
}
|
|
294
|
-
catch (err) {
|
|
295
|
-
if (this.view) {
|
|
296
|
-
await this.view.load();
|
|
297
|
-
this.view.emit('change');
|
|
298
|
-
__1.config.defaultApp?.emit('saved');
|
|
299
|
-
}
|
|
300
|
-
throw err;
|
|
252
|
+
if (actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo) {
|
|
253
|
+
const body = this.toPlainJSON();
|
|
254
|
+
__1.utils.logger.debug('修改组件', body);
|
|
255
|
+
await page_1.elementService.update({
|
|
256
|
+
headers: {
|
|
257
|
+
appId: __1.config.defaultApp?.id,
|
|
258
|
+
operationAction: actionOptions?.actionName || 'Element.update',
|
|
259
|
+
operationDesc: actionOptions?.actionDesc || `修改组件"${this.getElementTitle()}"`,
|
|
260
|
+
},
|
|
261
|
+
body,
|
|
262
|
+
}).catch(catchFn(this.view));
|
|
301
263
|
}
|
|
264
|
+
this.view && this.view.emit('change');
|
|
265
|
+
await __1.config.defaultApp?.history.load(actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo && {
|
|
266
|
+
operationAction: 'Element.update',
|
|
267
|
+
operationBeforeImage: null,
|
|
268
|
+
operationAfterImage: null,
|
|
269
|
+
operationDesc: `修改组件"${this.getElementTitle()}"`,
|
|
270
|
+
});
|
|
271
|
+
__1.config.defaultApp?.emit('saved');
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* 按当前 id 加载逻辑数据
|
|
276
|
+
*/
|
|
277
|
+
async load() {
|
|
278
|
+
if (!this.id)
|
|
279
|
+
return;
|
|
280
|
+
const result = await page_1.elementService.load({
|
|
281
|
+
headers: {
|
|
282
|
+
appId: __1.config.defaultApp?.id,
|
|
283
|
+
},
|
|
284
|
+
query: {
|
|
285
|
+
id: this.id,
|
|
286
|
+
},
|
|
287
|
+
config: { noErrorTip: true },
|
|
288
|
+
});
|
|
289
|
+
const newElement = Element.from(result, this.parent, this.view);
|
|
290
|
+
this.assign(newElement);
|
|
302
291
|
}
|
|
303
292
|
async move(options, actionOptions) {
|
|
304
293
|
try {
|
|
@@ -327,12 +316,17 @@ class Element extends __1.Vertex {
|
|
|
327
316
|
await __1.config.defaultApp?.history.load();
|
|
328
317
|
}
|
|
329
318
|
__1.config.defaultApp?.emit('element.moved');
|
|
319
|
+
__1.config.defaultApp?.emit('saved');
|
|
330
320
|
}
|
|
331
321
|
catch (err) {
|
|
332
322
|
if (this.view) {
|
|
333
323
|
await this.view.load();
|
|
334
324
|
this.view.emit('change');
|
|
335
325
|
}
|
|
326
|
+
__1.config.defaultApp?.emit('saved', {
|
|
327
|
+
action: 'move',
|
|
328
|
+
err,
|
|
329
|
+
});
|
|
336
330
|
throw err;
|
|
337
331
|
}
|
|
338
332
|
}
|
|
@@ -344,6 +338,8 @@ class Element extends __1.Vertex {
|
|
|
344
338
|
const code = this.toVue();
|
|
345
339
|
const index = this.parent.children.indexOf(this);
|
|
346
340
|
const newNode = Element.fromHTML(code, this.parent, this.view);
|
|
341
|
+
// 复制的元素需重新命名
|
|
342
|
+
newNode.deepRenameElements();
|
|
347
343
|
const mergeExpression = (originList, newList) => {
|
|
348
344
|
newList.forEach((item) => {
|
|
349
345
|
const originItem = originList.find((originItem) => originItem.name === item.name);
|
|
@@ -394,11 +390,11 @@ class Element extends __1.Vertex {
|
|
|
394
390
|
}
|
|
395
391
|
};
|
|
396
392
|
const arrayComp = this.findElementsByTag('u-modal');
|
|
397
|
-
const existingNames = Object.values(lodash_1.mapValues(arrayComp,
|
|
393
|
+
const existingNames = Object.values(lodash_1.mapValues(arrayComp, (o) => o.name));
|
|
398
394
|
// 处理弹窗组件的命名问题
|
|
399
395
|
if (newNode.tag === 'u-modal') {
|
|
400
396
|
Object.assign(newNode, {
|
|
401
|
-
name:
|
|
397
|
+
name: __1.utils.unique('saveModal1', existingNames),
|
|
402
398
|
});
|
|
403
399
|
}
|
|
404
400
|
traverseMergeNode(this, newNode);
|
|
@@ -426,6 +422,8 @@ class Element extends __1.Vertex {
|
|
|
426
422
|
}
|
|
427
423
|
if (lodash_1.isPlainObject(child)) {
|
|
428
424
|
child = Element.from(child, this, this.view);
|
|
425
|
+
child.initElementName();
|
|
426
|
+
child.deepRenameElements();
|
|
429
427
|
}
|
|
430
428
|
if (!this.children.includes(child)) {
|
|
431
429
|
const index = child._posIndex === undefined ? this.children.length : child._posIndex;
|
|
@@ -456,11 +454,13 @@ class Element extends __1.Vertex {
|
|
|
456
454
|
await this.update(undefined, {
|
|
457
455
|
actionDesc: `设置组件"${this.getElementTitle()}"的名称为"${name}"`,
|
|
458
456
|
});
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
457
|
+
if (!window.globalData.hasUserCenter) {
|
|
458
|
+
// 同步权限
|
|
459
|
+
new __1.Nuims({
|
|
460
|
+
domainName: this.view.page.service.app.name,
|
|
461
|
+
element: this,
|
|
462
|
+
}).editResourceFromResourceValue(oldName ? `${this.view.tempPath}/${oldName}` : null);
|
|
463
|
+
}
|
|
464
464
|
this.view && this.view.emit('change');
|
|
465
465
|
if (this.view && this.view.page && this.view.page.service) {
|
|
466
466
|
this.view.page.service.emit('vertexIdToNameChange', this.id, this.name);
|
|
@@ -503,9 +503,7 @@ class Element extends __1.Vertex {
|
|
|
503
503
|
async setAttr(name, type, value) {
|
|
504
504
|
let attr = this.getAttr(name);
|
|
505
505
|
//
|
|
506
|
-
if (value
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
506
|
+
if (value !== undefined) {
|
|
509
507
|
if (typeof value !== 'string')
|
|
510
508
|
value = JSON.stringify(value);
|
|
511
509
|
if (attr) {
|
|
@@ -515,7 +513,7 @@ class Element extends __1.Vertex {
|
|
|
515
513
|
});
|
|
516
514
|
await attr.update(undefined, {
|
|
517
515
|
actionDesc: `设置组件"${this.getElementTitle()}"属性"${attr.name}"的值为"${attr.value}"`,
|
|
518
|
-
});
|
|
516
|
+
}).catch(catchFn(this.view));
|
|
519
517
|
}
|
|
520
518
|
else {
|
|
521
519
|
attr = __1.Attr.from({
|
|
@@ -526,7 +524,7 @@ class Element extends __1.Vertex {
|
|
|
526
524
|
}, this);
|
|
527
525
|
await attr.create(undefined, {
|
|
528
526
|
actionDesc: `设置组件"${this.getElementTitle()}"属性"${attr.name}"的值为"${attr.value}"`,
|
|
529
|
-
});
|
|
527
|
+
}).catch(catchFn(this.view));
|
|
530
528
|
this.attrList.push(attr);
|
|
531
529
|
}
|
|
532
530
|
}
|
|
@@ -540,7 +538,7 @@ class Element extends __1.Vertex {
|
|
|
540
538
|
let event = new __1.Event(data);
|
|
541
539
|
await event.create(undefined, Object.assign({
|
|
542
540
|
actionDesc: `添加组件"${this.getElementTitle()}"事件"${event.name}"`,
|
|
543
|
-
}, actionOptions));
|
|
541
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
544
542
|
event = __1.Event.from(event, this);
|
|
545
543
|
this.eventList.push(event);
|
|
546
544
|
this.view && this.view.emit('change');
|
|
@@ -558,7 +556,7 @@ class Element extends __1.Vertex {
|
|
|
558
556
|
event = this.eventList.find((item) => item.id === event.id);
|
|
559
557
|
await event.delete(undefined, Object.assign({
|
|
560
558
|
actionDesc: `删除组件"${this.getElementTitle()}"事件"${event.name}"`,
|
|
561
|
-
}, actionOptions));
|
|
559
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
562
560
|
const index = this.eventList.indexOf(event);
|
|
563
561
|
~index && this.eventList.splice(index, 1);
|
|
564
562
|
this.view && this.view.emit('change');
|
|
@@ -573,7 +571,7 @@ class Element extends __1.Vertex {
|
|
|
573
571
|
const directive = new __1.Directive(data);
|
|
574
572
|
await directive.create(undefined, Object.assign({
|
|
575
573
|
actionDesc: `添加组件"${this.getElementTitle()}"指令"${directive.name}"`,
|
|
576
|
-
}, actionOptions));
|
|
574
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
577
575
|
this.directiveList.push(__1.Directive.from(directive, this));
|
|
578
576
|
this.view && this.view.emit('change');
|
|
579
577
|
}
|
|
@@ -587,7 +585,7 @@ class Element extends __1.Vertex {
|
|
|
587
585
|
directive = this.directiveList.find((item) => item.id === directive.id);
|
|
588
586
|
await directive.delete(undefined, Object.assign({
|
|
589
587
|
actionDesc: `删除组件"${this.getElementTitle()}"属性"${directive.name}"`,
|
|
590
|
-
}, actionOptions));
|
|
588
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
591
589
|
const index = this.directiveList.indexOf(directive);
|
|
592
590
|
~index && this.directiveList.splice(index, 1);
|
|
593
591
|
this.view && this.view.emit('change');
|
|
@@ -771,6 +769,40 @@ class Element extends __1.Vertex {
|
|
|
771
769
|
}
|
|
772
770
|
}
|
|
773
771
|
}
|
|
772
|
+
// 初始化组件名
|
|
773
|
+
initElementName() {
|
|
774
|
+
if (Element.ignoreTag.includes(this.tag)) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const name = this.genElementName();
|
|
778
|
+
this.assign({ name });
|
|
779
|
+
this.view.addElementName(name);
|
|
780
|
+
}
|
|
781
|
+
// 生成新的组件名
|
|
782
|
+
genElementName() {
|
|
783
|
+
const compNameSet = this.view.elementNameSet;
|
|
784
|
+
const tagName = this.tag.replace(Element.TAG_NAME_REG, '').replace(/-/g, '_');
|
|
785
|
+
const componentName = __1.utils.unique(tagName + '1', compNameSet);
|
|
786
|
+
return componentName;
|
|
787
|
+
}
|
|
788
|
+
// 递归生成组件名
|
|
789
|
+
deepRenameElements() {
|
|
790
|
+
return this.traverseChildren((ele) => {
|
|
791
|
+
ele.initElementName();
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
// 递归删除组件名的缓存
|
|
795
|
+
deepRemoveElementsName() {
|
|
796
|
+
return this.traverseChildren((ele) => {
|
|
797
|
+
this.view.removeElementName(ele.name);
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
// 递归遍历组件
|
|
801
|
+
traverseChildren(cb) {
|
|
802
|
+
__1.utils.traverse((current) => {
|
|
803
|
+
cb(current.node);
|
|
804
|
+
}, { node: this });
|
|
805
|
+
}
|
|
774
806
|
/**
|
|
775
807
|
* 从 Vue 的 ASTNode 转换成 ASL 元素
|
|
776
808
|
* @param astNode Vue 的 ASTNode
|
|
@@ -812,8 +844,6 @@ class Element extends __1.Vertex {
|
|
|
812
844
|
astNode.tag = 'u-router-view';
|
|
813
845
|
}
|
|
814
846
|
}
|
|
815
|
-
// if (astNode.tag === 'template')
|
|
816
|
-
// astNode.tag = 'div';
|
|
817
847
|
element = new Element({
|
|
818
848
|
tag: astNode.tag,
|
|
819
849
|
name: astNode.attrsMap.ref,
|
|
@@ -855,7 +885,6 @@ class Element extends __1.Vertex {
|
|
|
855
885
|
}
|
|
856
886
|
}
|
|
857
887
|
element.attrList.push(attr);
|
|
858
|
-
// element.attrMap[attr.name] = attr;
|
|
859
888
|
});
|
|
860
889
|
// compiler 处理:value.sync 时会加上update:value事件,需要过滤
|
|
861
890
|
astNode.events && Object.keys(astNode.events).filter((name) => !name.startsWith('update:')).forEach((name) => {
|
|
@@ -866,10 +895,6 @@ class Element extends __1.Vertex {
|
|
|
866
895
|
value,
|
|
867
896
|
logicId: value[0] === '$' ? undefined : value,
|
|
868
897
|
}, element));
|
|
869
|
-
// element.eventMap[name] = new Event({
|
|
870
|
-
// name,
|
|
871
|
-
// value: oldEvent.value,
|
|
872
|
-
// });
|
|
873
898
|
});
|
|
874
899
|
astNode.directives && astNode.directives.forEach((directive) => {
|
|
875
900
|
if (directive.name === 'model') {
|
|
@@ -896,7 +921,6 @@ class Element extends __1.Vertex {
|
|
|
896
921
|
arg: directive.arg,
|
|
897
922
|
modifiers: directive.modifiers,
|
|
898
923
|
}, element));
|
|
899
|
-
// element.directiveMap[directive.name] = );
|
|
900
924
|
}
|
|
901
925
|
});
|
|
902
926
|
if (astNode.if) {
|
|
@@ -1237,6 +1261,10 @@ class Element extends __1.Vertex {
|
|
|
1237
1261
|
const element = this.parse(html, context);
|
|
1238
1262
|
__1.utils.traverse((current) => {
|
|
1239
1263
|
current.node.assign({ view, parent: current.parent });
|
|
1264
|
+
// 生成唯一组件名 依赖element.view
|
|
1265
|
+
if (!current.node.name) {
|
|
1266
|
+
current.node.initElementName();
|
|
1267
|
+
}
|
|
1240
1268
|
}, { node: element, parent });
|
|
1241
1269
|
return element;
|
|
1242
1270
|
}
|
|
@@ -1257,6 +1285,14 @@ class Element extends __1.Vertex {
|
|
|
1257
1285
|
return element;
|
|
1258
1286
|
}
|
|
1259
1287
|
}
|
|
1288
|
+
/**
|
|
1289
|
+
* 标签名前缀
|
|
1290
|
+
*/
|
|
1291
|
+
Element.TAG_NAME_REG = /^([lieu]|van)[-_]/;
|
|
1292
|
+
/**
|
|
1293
|
+
* 忽略命名的标签
|
|
1294
|
+
*/
|
|
1295
|
+
Element.ignoreTag = ['div', 'span'];
|
|
1260
1296
|
__decorate([
|
|
1261
1297
|
decorators_1.immutable()
|
|
1262
1298
|
], Element.prototype, "level", void 0);
|
|
@@ -1349,6 +1385,12 @@ __decorate([
|
|
|
1349
1385
|
__decorate([
|
|
1350
1386
|
decorators_1.action('删除组件指令')
|
|
1351
1387
|
], Element.prototype, "deleteDirective", null);
|
|
1388
|
+
__decorate([
|
|
1389
|
+
decorators_1.immutable()
|
|
1390
|
+
], Element, "TAG_NAME_REG", void 0);
|
|
1391
|
+
__decorate([
|
|
1392
|
+
decorators_1.immutable()
|
|
1393
|
+
], Element, "ignoreTag", void 0);
|
|
1352
1394
|
exports.Element = Element;
|
|
1353
1395
|
exports.default = Element;
|
|
1354
1396
|
//# sourceMappingURL=Element.js.map
|