@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
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;
|
package/src/types/page/View.ts
CHANGED
|
@@ -16,6 +16,7 @@ import * as babel from '@babel/core';
|
|
|
16
16
|
import view from '@/service/page/view';
|
|
17
17
|
import Entity from '../data/Entity';
|
|
18
18
|
import { postServiceType } from '../../service/common/preprocess';
|
|
19
|
+
import { catchFn } from './Page';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* 子页面类,前端路由控制
|
|
@@ -127,6 +128,12 @@ export class View extends Block {
|
|
|
127
128
|
*/
|
|
128
129
|
@immutable()
|
|
129
130
|
public readonly moreChildrenFields: Array<string> = ['$def.params', '$def.variables', '$def.logics'];
|
|
131
|
+
/**
|
|
132
|
+
* 当前View中所有组件名的缓存
|
|
133
|
+
*/
|
|
134
|
+
@immutable()
|
|
135
|
+
public readonly elementNameSet: Set<string> = new Set();
|
|
136
|
+
|
|
130
137
|
/**
|
|
131
138
|
* @param source 需要合并的部分参数
|
|
132
139
|
*/
|
|
@@ -199,26 +206,36 @@ export class View extends Block {
|
|
|
199
206
|
} catch (err) { }
|
|
200
207
|
})().finally(() => this.contentPromise = undefined);
|
|
201
208
|
}
|
|
202
|
-
loadAll() {
|
|
209
|
+
loadAll(enableCache = true) {
|
|
203
210
|
// 如果有正在进行的 Promise,则直接返回它
|
|
204
211
|
if (this.contentPromise)
|
|
205
212
|
return this.contentPromise;
|
|
206
213
|
|
|
207
214
|
return this.contentPromise = (async () => {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
215
|
+
const result: View = await viewService.load({
|
|
216
|
+
path: {
|
|
217
|
+
id: this.id,
|
|
218
|
+
},
|
|
219
|
+
query: {
|
|
220
|
+
enableCache,
|
|
221
|
+
},
|
|
222
|
+
config: { noErrorTip: true },
|
|
223
|
+
});
|
|
224
|
+
const oldLogics = this.$def.logics;
|
|
225
|
+
Object.assign(result, {
|
|
226
|
+
children: this.children,
|
|
227
|
+
});
|
|
228
|
+
const temp = View.from(result, this.parent, this.page, this);
|
|
229
|
+
const newLogics = temp.$def.logics;
|
|
230
|
+
oldLogics.forEach((logic) => {
|
|
231
|
+
if (!newLogics.find((item) => item.id === logic.id))
|
|
232
|
+
logic.destroy();
|
|
233
|
+
});
|
|
234
|
+
this.assign(temp);
|
|
235
|
+
utils.traverse((current) => {
|
|
236
|
+
current.node.attachNodePath(true);
|
|
237
|
+
}, { node: this });
|
|
238
|
+
return this;
|
|
222
239
|
})().finally(() => this.contentPromise = undefined);
|
|
223
240
|
}
|
|
224
241
|
isContentLoaded() {
|
|
@@ -325,7 +342,7 @@ export class View extends Block {
|
|
|
325
342
|
operationDesc: actionOptions?.actionDesc || `添加子页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
326
343
|
},
|
|
327
344
|
body,
|
|
328
|
-
});
|
|
345
|
+
}).catch(catchFn());
|
|
329
346
|
this.deepPick(result.view, ['id']);
|
|
330
347
|
// 添加数据
|
|
331
348
|
this.addData(result);
|
|
@@ -406,21 +423,16 @@ export class View extends Block {
|
|
|
406
423
|
if (!this.parent)
|
|
407
424
|
throw Error('该子页面为根节点!');
|
|
408
425
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
});
|
|
420
|
-
} catch (err) {
|
|
421
|
-
await config.defaultApp?.history.load();
|
|
422
|
-
throw err;
|
|
423
|
-
}
|
|
426
|
+
await viewService.delete({
|
|
427
|
+
headers: {
|
|
428
|
+
appId: config.defaultApp?.id,
|
|
429
|
+
operationAction: actionOptions?.actionName || 'View.delete',
|
|
430
|
+
operationDesc: actionOptions?.actionDesc || `删除子页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
431
|
+
},
|
|
432
|
+
path: {
|
|
433
|
+
id: this.id,
|
|
434
|
+
},
|
|
435
|
+
}).catch(catchFn());
|
|
424
436
|
|
|
425
437
|
const index = this.parent.children.indexOf(this);
|
|
426
438
|
~index && this.parent.children.splice(index, 1);
|
|
@@ -452,7 +464,7 @@ export class View extends Block {
|
|
|
452
464
|
operationDesc: actionOptions?.actionDesc || `修改子页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
453
465
|
},
|
|
454
466
|
body,
|
|
455
|
-
});
|
|
467
|
+
}).catch(catchFn());
|
|
456
468
|
|
|
457
469
|
await then?.();
|
|
458
470
|
await config.defaultApp?.history.load();
|
|
@@ -901,6 +913,40 @@ export class View extends Block {
|
|
|
901
913
|
// config.defaultApp?.emit('saved');
|
|
902
914
|
}
|
|
903
915
|
|
|
916
|
+
// 遍历页面缓存所有组件名
|
|
917
|
+
traverseAllElementName(): void {
|
|
918
|
+
this.elementNameSet.clear();
|
|
919
|
+
utils.traverse(({ node }) => {
|
|
920
|
+
node && this.elementNameSet.add(node.name);
|
|
921
|
+
}, { node: this.$html });
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// 组件名是否有效
|
|
925
|
+
isValidElementName(name: string): boolean {
|
|
926
|
+
if (name) {
|
|
927
|
+
return !this.elementNameSet.has(name);
|
|
928
|
+
}
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// 保存组件名至缓存
|
|
933
|
+
addElementName(nameOrElement: string | Element) {
|
|
934
|
+
let name: string = nameOrElement as string;
|
|
935
|
+
if (nameOrElement instanceof Element) {
|
|
936
|
+
name = nameOrElement.name;
|
|
937
|
+
}
|
|
938
|
+
return this.elementNameSet.add(name);
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
// 在缓存中移除组件名
|
|
942
|
+
removeElementName(nameOrElement: string | Element): void {
|
|
943
|
+
let name: string = nameOrElement as string;
|
|
944
|
+
if (nameOrElement instanceof Element) {
|
|
945
|
+
name = nameOrElement.name;
|
|
946
|
+
}
|
|
947
|
+
this.elementNameSet.delete(name);
|
|
948
|
+
}
|
|
949
|
+
|
|
904
950
|
_removeDef($def: View['$def']) {
|
|
905
951
|
const removedParams = this.$def.params.filter((param) => $def.params?.find((item) => param.id === item.id));
|
|
906
952
|
this.$def.params = this.$def.params.filter((param) => !$def.params?.find((item) => param.id === item.id));
|
|
@@ -5,6 +5,25 @@ import { getBasicTypeDefaultValue } from '../data/basicTypes';
|
|
|
5
5
|
import { viewService } from '../../service/page';
|
|
6
6
|
import { View } from './View';
|
|
7
7
|
import { schemaService } from '../../service/common';
|
|
8
|
+
import { refreshPages, refreshView } from '../cache';
|
|
9
|
+
import { BusinessCode } from '../enum';
|
|
10
|
+
|
|
11
|
+
export function catchFn(view: View) {
|
|
12
|
+
return async (err: any) => {
|
|
13
|
+
const code = err?.code;
|
|
14
|
+
// 节点已存在; 节点不存在
|
|
15
|
+
if([BusinessCode.ElementExist, BusinessCode.ElementNotExist].includes(code)) {
|
|
16
|
+
await refreshView(view);
|
|
17
|
+
} else if(code === BusinessCode.ParentElementNotExist) { // 父节点不存在。视图添加变量,发现视图不存在
|
|
18
|
+
await refreshPages();
|
|
19
|
+
} else
|
|
20
|
+
config.defaultApp?.emit('saved', err);
|
|
21
|
+
|
|
22
|
+
config.defaultApp?.history.load();
|
|
23
|
+
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
8
27
|
|
|
9
28
|
/**
|
|
10
29
|
* 页面输入参数
|
|
@@ -56,7 +75,7 @@ export class ViewParam extends Param {
|
|
|
56
75
|
operationDesc: actionOptions?.actionDesc || `添加页面"${this.view.name}"输入参数"${this.name}"`,
|
|
57
76
|
},
|
|
58
77
|
body,
|
|
59
|
-
});
|
|
78
|
+
}).catch(catchFn(this.view));
|
|
60
79
|
// convert2RefType(result.schema);
|
|
61
80
|
this.deepPick(result, ['id']);
|
|
62
81
|
this.assign({ code: this.genCode() });
|
|
@@ -88,7 +107,7 @@ export class ViewParam extends Param {
|
|
|
88
107
|
query: {
|
|
89
108
|
id: this.id,
|
|
90
109
|
},
|
|
91
|
-
});
|
|
110
|
+
}).catch(catchFn(this.view));
|
|
92
111
|
} catch(err) {
|
|
93
112
|
await config.defaultApp?.history.load();
|
|
94
113
|
throw err;
|
|
@@ -129,7 +148,7 @@ export class ViewParam extends Param {
|
|
|
129
148
|
operationDesc: actionOptions?.actionDesc || `修改页面"${this.view.name}"输入参数"${this.name}"`,
|
|
130
149
|
},
|
|
131
150
|
body,
|
|
132
|
-
});
|
|
151
|
+
}).catch(catchFn(this.view));
|
|
133
152
|
// convert2RefType(result.schema);
|
|
134
153
|
// this.plainAssign(result);
|
|
135
154
|
|
|
@@ -5,6 +5,7 @@ import { viewService } from '../../service/page';
|
|
|
5
5
|
import { convert2RefType, convert2SchemaType } from '../data/dataTypeUtils';
|
|
6
6
|
import { getBasicTypeDefaultValue } from '../data/basicTypes';
|
|
7
7
|
import { schemaService } from '../../service/common';
|
|
8
|
+
import { catchFn } from './ViewParam';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* 页面局部变量
|
|
@@ -51,7 +52,7 @@ export class ViewVariable extends Variable {
|
|
|
51
52
|
operationDesc: actionOptions?.actionDesc || `添加页面"${this.view.name}"局部变量"${this.name}"`,
|
|
52
53
|
},
|
|
53
54
|
body,
|
|
54
|
-
});
|
|
55
|
+
}).catch(catchFn(this.view));
|
|
55
56
|
// convert2RefType(result.schema);
|
|
56
57
|
this.deepPick(result, ['id']);
|
|
57
58
|
this.assign({ code: this.genCode() });
|
|
@@ -73,7 +74,6 @@ export class ViewVariable extends Variable {
|
|
|
73
74
|
config.defaultApp?.emit('saving');
|
|
74
75
|
|
|
75
76
|
if (this.id) {
|
|
76
|
-
try {
|
|
77
77
|
await viewService.deleteViewVariable({
|
|
78
78
|
headers: {
|
|
79
79
|
appId: config.defaultApp?.id,
|
|
@@ -83,11 +83,7 @@ export class ViewVariable extends Variable {
|
|
|
83
83
|
query: {
|
|
84
84
|
id: this.id,
|
|
85
85
|
},
|
|
86
|
-
});
|
|
87
|
-
} catch (err) {
|
|
88
|
-
await config.defaultApp?.history.load();
|
|
89
|
-
throw err;
|
|
90
|
-
}
|
|
86
|
+
}).catch(catchFn(this.view));
|
|
91
87
|
}
|
|
92
88
|
|
|
93
89
|
const { variables } = this.view.$def;
|
|
@@ -122,7 +118,7 @@ export class ViewVariable extends Variable {
|
|
|
122
118
|
operationDesc: actionOptions?.actionDesc || `修改页面"${this.view.name}"局部变量"${this.name}"`,
|
|
123
119
|
},
|
|
124
120
|
body,
|
|
125
|
-
});
|
|
121
|
+
}).catch(catchFn(this.view));
|
|
126
122
|
// convert2RefType(result.schema);
|
|
127
123
|
// this.plainAssign(result);
|
|
128
124
|
|