@lcap/nasl 3.6.0-alpha.1 → 3.6.0-alpha.2
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/bak/translator.js +119 -39
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/generator/BreakpointNode.d.ts +3 -0
- package/out/breakpoint/generator/BreakpointNode.js +9 -0
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
- package/out/breakpoint/shared/constants.js +1 -0
- package/out/breakpoint/shared/constants.js.map +1 -1
- package/out/breakpoint/shared/utils.js +12 -6
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/breakpoint/store/core.js +1 -1
- package/out/breakpoint/store/core.js.map +1 -1
- package/out/common/BaseNode.d.ts +1 -4
- package/out/common/BaseNode.js +23 -37
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +6 -1
- package/out/concepts/AnonymousFunction__.js +34 -16
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +55 -51
- package/out/concepts/App__.js +76 -80
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +10 -2
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +16 -6
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +1 -0
- package/out/concepts/BindDirective__.js +19 -4
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +3 -1
- package/out/concepts/BindEvent__.js +39 -14
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +641 -0
- package/out/concepts/BusinessComponent__.js +1921 -0
- package/out/concepts/BusinessComponent__.js.map +1 -0
- package/out/concepts/BusinessLogic__.d.ts +38 -0
- package/out/concepts/BusinessLogic__.js +358 -0
- package/out/concepts/BusinessLogic__.js.map +1 -0
- package/out/concepts/CallEvent__.d.ts +101 -0
- package/out/concepts/CallEvent__.js +280 -0
- package/out/concepts/CallEvent__.js.map +1 -0
- package/out/concepts/CallFunction__.d.ts +0 -1
- package/out/concepts/CallFunction__.js +10 -10
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +2 -0
- package/out/concepts/CallLogic__.js +38 -27
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Constant__.js +7 -6
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -1
- package/out/concepts/Destination__.js +7 -5
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +2 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/Event__.d.ts +14 -0
- package/out/concepts/Event__.js +61 -0
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/FrontendType__.d.ts +308 -0
- package/out/concepts/FrontendType__.js +605 -0
- package/out/concepts/FrontendType__.js.map +1 -0
- package/out/concepts/Frontend__.d.ts +0 -88
- package/out/concepts/Frontend__.js +1 -143
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +5 -0
- package/out/concepts/Identifier__.js +19 -9
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +3 -1
- package/out/concepts/Logic__.js +31 -21
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -1
- package/out/concepts/MemberExpression__.js +3 -3
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/ParamWithGroup__.d.ts +39 -0
- package/out/concepts/ParamWithGroup__.js +85 -0
- package/out/concepts/ParamWithGroup__.js.map +1 -0
- package/out/concepts/Param__.js +11 -3
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +9 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Return__.js +17 -9
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +2 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +17 -8
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +17 -1
- package/out/concepts/ViewElement__.js +145 -16
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +21 -20
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/index__.d.ts +5 -0
- package/out/concepts/index__.js +5 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/concepts/utils/asserts.d.ts +258 -3
- package/out/concepts/utils/asserts.js +351 -13
- package/out/concepts/utils/asserts.js.map +1 -1
- package/out/concepts/utils/types.d.ts +20 -3
- package/out/generator/genBundleFiles.js +25 -11
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.js +12 -3
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.js +3 -3
- package/out/generator/permission.js.map +1 -1
- package/out/natural/transformTSCode.js +1 -1
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +6 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getLogics.js +62 -27
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +6 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.js +3 -3
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +40 -19
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +6 -1
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +1 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -6
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +16 -16
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +36 -36
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +6 -5
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +12 -12
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +4 -4
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +3 -3
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +10 -10
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +10 -9
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- package/out/templator/utils.js.map +1 -1
- package/out/translator/utils.js +12 -1
- package/out/translator/utils.js.map +1 -1
- package/out/utils/i18nInfo.js +7 -2
- package/out/utils/i18nInfo.js.map +1 -1
- package/out/utils/index.d.ts +17 -0
- package/out/utils/index.js +184 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/bak/translator.js +121 -43
- package/src/breakpoint/generator/BreakpointNode.ts +12 -0
- package/src/breakpoint/shared/constants.ts +1 -0
- package/src/breakpoint/shared/utils.ts +13 -8
- package/src/breakpoint/store/core.ts +1 -1
- package/src/common/BaseNode.ts +22 -41
- package/src/concepts/AnonymousFunction__.ts +36 -18
- package/src/concepts/App__.ts +129 -130
- package/src/concepts/BackendVariable__.ts +10 -2
- package/src/concepts/BindAttribute__.ts +14 -6
- package/src/concepts/BindDirective__.ts +19 -4
- package/src/concepts/BindEvent__.ts +41 -13
- package/src/concepts/BusinessComponent__.ts +2693 -0
- package/src/concepts/BusinessLogic__.ts +376 -0
- package/src/concepts/CallEvent__.ts +351 -0
- package/src/concepts/CallFunction__.ts +10 -13
- package/src/concepts/CallLogic__.ts +45 -32
- package/src/concepts/Constant__.ts +5 -7
- package/src/concepts/Destination__.ts +7 -5
- package/src/concepts/End__.ts +1 -0
- package/src/concepts/Event__.ts +70 -0
- package/src/concepts/FrontendType__.ts +919 -0
- package/src/concepts/Frontend__.ts +3 -251
- package/src/concepts/Identifier__.ts +29 -13
- package/src/concepts/LogicItem__.ts +1 -0
- package/src/concepts/Logic__.ts +36 -23
- package/src/concepts/MemberExpression__.ts +3 -3
- package/src/concepts/NewComposite__.ts +4 -6
- package/src/concepts/ParamWithGroup__.ts +101 -0
- package/src/concepts/Param__.ts +11 -3
- package/src/concepts/ProcessElement__.ts +8 -1
- package/src/concepts/Return__.ts +15 -12
- package/src/concepts/ValidationRule__.ts +6 -1
- package/src/concepts/Variable__.ts +17 -9
- package/src/concepts/ViewElement__.ts +168 -33
- package/src/concepts/View__.ts +23 -20
- package/src/concepts/index__.ts +5 -0
- package/src/concepts/utils/asserts.ts +367 -4
- package/src/concepts/utils/types.ts +28 -0
- package/src/generator/genBundleFiles.ts +33 -15
- package/src/generator/genReleaseBody.ts +14 -3
- package/src/generator/permission.ts +8 -6
- package/src/natural/transformTSCode.ts +1 -1
- package/src/server/extendBaseNode.ts +22 -20
- package/src/server/getLogics.ts +79 -41
- package/src/server/getMemberIdentifier.ts +7 -1
- package/src/server/getProcesses.ts +3 -3
- package/src/server/naslServer.ts +44 -20
- package/src/server/translator.ts +7 -1
- package/src/service/storage/init.ts +1 -2
- package/src/templator/genCreateBlock.ts +6 -6
- package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -16
- package/src/templator/genCurdMultipleKeyBlock.ts +36 -36
- package/src/templator/genGetBlock.ts +6 -5
- package/src/templator/genGridViewBlock.ts +12 -12
- package/src/templator/genListViewBlock.ts +4 -4
- package/src/templator/genSelectBlock.ts +3 -3
- package/src/templator/genTableBlock.ts +10 -10
- package/src/templator/genUpdateBlock.ts +10 -9
- package/src/templator/utils.ts +2 -2
- package/src/translator/utils.ts +12 -1
- package/src/utils/i18nInfo.ts +7 -2
- package/src/utils/index.ts +211 -1
- package/test/concepts/call-function/fixtures/from-string.json +68 -59
- package/test/concepts/call-function/fixtures/to-string-global-tz.json +67 -58
- package/test/concepts/call-function/fixtures/to-string-no-tz.json +57 -48
- package/test/concepts/call-function/fixtures/to-string-user-tz.json +69 -60
- package/test/concepts/call-function/fixtures/to-string-utc-tz.json +69 -60
- package/test/concepts/call-interface/fixtures/only-interface.json +81 -72
- package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +223 -214
- package/test/concepts/call-interface/fixtures/with-body-no-argument.json +85 -76
- package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +100 -91
- package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +88 -79
- package/test/concepts/call-interface/fixtures/with-headers.json +90 -81
- package/test/concepts/call-interface/fixtures/with-query-no-argument.json +88 -79
- package/test/concepts/call-interface/fixtures/with-query.json +90 -81
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +4 -2
- package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +104 -95
- package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +209 -200
- package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +97 -88
- package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +124 -115
- package/test/concepts/call-logic/fixtures/json-deserialize.json +120 -111
- package/test/concepts/call-logic/fixtures/json-serialize-with-string.json +124 -115
- package/test/concepts/call-logic/fixtures/json-serialize.json +124 -115
- package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +91 -82
- package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +88 -79
- package/test/concepts/call-logic/fixtures/view-component-with-validation.json +144 -135
- package/test/concepts/identifier/fixtures/view-variable.json +145 -136
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/concepts/view-element/fixtures/default-login.json +221 -212
- package/test/concepts/view-element/fixtures/default-not-found.json +183 -174
- package/test/concepts/view-element/fixtures/with-role-auth.json +91 -82
- package/test/concepts/view-element/fixtures/with-table.json +1894 -1885
- package/test/concepts/view-element/toVue.spec.ts +1 -0
- package/ts-worker/package.json +1 -1
- package/ts-worker/src/index.js +1 -0
|
@@ -921,6 +921,9 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
921
921
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
922
922
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
923
923
|
//================================================================================
|
|
924
|
+
get likeComponent() {
|
|
925
|
+
return this.view || this?.getAncestor('BusinessComponent');
|
|
926
|
+
}
|
|
924
927
|
/* 主页面有没有权限 */
|
|
925
928
|
get parentAuth() {
|
|
926
929
|
const _nameSpace = this.view.getNamespace();
|
|
@@ -943,10 +946,10 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
943
946
|
return this.bindDirectives.find((directive) => directive.name === 'auth');
|
|
944
947
|
}
|
|
945
948
|
getViewElementUniqueName(name = 'viewElement1') {
|
|
946
|
-
return this.
|
|
949
|
+
return this.likeComponent?.getViewElementUniqueName(name);
|
|
947
950
|
}
|
|
948
951
|
getViewElementUniqueNameOld(name = 'viewElement1') {
|
|
949
|
-
return this.
|
|
952
|
+
return this.likeComponent?.getViewElementUniqueNameOld(name);
|
|
950
953
|
}
|
|
951
954
|
static from(source, parentNode, parentKey) {
|
|
952
955
|
const node = super.from(source, parentNode, parentKey);
|
|
@@ -983,8 +986,10 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
983
986
|
const self = this;
|
|
984
987
|
let code = '';
|
|
985
988
|
code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
|
|
986
|
-
|
|
987
|
-
|
|
989
|
+
if (self.isCorrespondingBusinessComponent) {
|
|
990
|
+
code += `${self.name}: ${self.correspondingBusinessComponentNamespace}.${self.tag.replace('bs-', '')};\n`;
|
|
991
|
+
}
|
|
992
|
+
else if (self.toHump(self.tag) === 'lcapLogin' || self.staticClass === 'login-form') { // 登录组件不翻译
|
|
988
993
|
code += `${self.name}: nasl.ui.div<any>;\n`;
|
|
989
994
|
}
|
|
990
995
|
else if (self.tag === 'u-table-view-column-dynamic') {
|
|
@@ -1068,7 +1073,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1068
1073
|
}
|
|
1069
1074
|
else {
|
|
1070
1075
|
let targetNode = _this;
|
|
1071
|
-
while (!targetNode.__tsVariableDataSourceTypeName && asserts.isViewElement(targetNode?.parentNode)) {
|
|
1076
|
+
while ((!targetNode.__tsVariableDataSourceTypeName || targetNode.__tsVariableDataSourceTypeName === 'any') && asserts.isViewElement(targetNode?.parentNode)) {
|
|
1072
1077
|
targetNode = targetNode.parentNode;
|
|
1073
1078
|
}
|
|
1074
1079
|
genericity += `<${targetNode.__tsVariableDataSourceTypeName ?? 'any'}>`;
|
|
@@ -1199,9 +1204,32 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1199
1204
|
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1200
1205
|
return code;
|
|
1201
1206
|
}
|
|
1207
|
+
// 获取端类型
|
|
1208
|
+
get frontendType() {
|
|
1209
|
+
return this.getAncestor('FrontendType');
|
|
1210
|
+
}
|
|
1211
|
+
// 对应业务组件
|
|
1212
|
+
get isCorrespondingBusinessComponent() {
|
|
1213
|
+
return this.tag.startsWith('bs-');
|
|
1214
|
+
}
|
|
1215
|
+
// 对应的业务组件的Namespace
|
|
1216
|
+
get correspondingBusinessComponentNamespace() {
|
|
1217
|
+
return `${this.frontendType?.getNamespace()}.${this.frontendType?.name}.businessComponents`;
|
|
1218
|
+
}
|
|
1219
|
+
// 获取对应的业务组件
|
|
1220
|
+
get correspondingBusinessComponent() {
|
|
1221
|
+
if (this.isCorrespondingBusinessComponent) {
|
|
1222
|
+
// 端下的业务组件
|
|
1223
|
+
const businessComponents = this.frontendType?.businessComponents;
|
|
1224
|
+
const businessComponent = businessComponents.find((businessComponent) => {
|
|
1225
|
+
return `bs-${businessComponent?.name}` === this.tag;
|
|
1226
|
+
});
|
|
1227
|
+
return businessComponent;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1202
1230
|
*toEmbeddedTS(state = (0, translator_1.createCompilerState)(), parentLevel) {
|
|
1203
1231
|
const self = this;
|
|
1204
|
-
const { parentNode, app, tag, staticClass, name,
|
|
1232
|
+
const { parentNode, app, tag, staticClass, name, bindRoles, bindEvents, children } = self;
|
|
1205
1233
|
const chineseTsName = (name) => {
|
|
1206
1234
|
let tsName = name;
|
|
1207
1235
|
// 匹配所有特殊字符都转为_
|
|
@@ -1268,8 +1296,12 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1268
1296
|
code += '},\n';
|
|
1269
1297
|
return code;
|
|
1270
1298
|
}
|
|
1299
|
+
let namespace = `nasl.ui.${self.toHump(tag)}`;
|
|
1300
|
+
if (self.isCorrespondingBusinessComponent) {
|
|
1301
|
+
namespace = `${self.correspondingBusinessComponentNamespace}.${self.tag.replace('bs-', '')}`;
|
|
1302
|
+
}
|
|
1271
1303
|
// 后面那个name是为了查找引用的时候用的
|
|
1272
|
-
let code = `new
|
|
1304
|
+
let code = `new ${namespace}${self.getTypeArgmentsStr(state)}({name: __elements.${name},\n`;
|
|
1273
1305
|
// 是否开启权限
|
|
1274
1306
|
// const hasAuth = Array.isArray(bindDirectives)
|
|
1275
1307
|
// ? !!bindDirectives.filter((directive) => directive.name === 'auth').length
|
|
@@ -1299,8 +1331,19 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1299
1331
|
if (Array.isArray(children)) {
|
|
1300
1332
|
code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
|
|
1301
1333
|
if (Array.isArray(self.bindAttrs)) {
|
|
1302
|
-
code += `bindAttr:
|
|
1334
|
+
code += `bindAttr: `;
|
|
1335
|
+
if (self.isCorrespondingBusinessComponent) {
|
|
1336
|
+
code += `{\n`;
|
|
1337
|
+
}
|
|
1338
|
+
else {
|
|
1339
|
+
code += `() => [\n`;
|
|
1340
|
+
}
|
|
1303
1341
|
yield* (0, time_slicing_1.wrapForEachToGenerator)(self.bindAttrs, function* warpForEachGenerator(attr) {
|
|
1342
|
+
// 过滤自由布局的key
|
|
1343
|
+
const shouldFilter = self.isCorrespondingBusinessComponent && (attr.name === 'key' && !attr.expression);
|
|
1344
|
+
if (shouldFilter) {
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1304
1347
|
code += (yield* attr.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 }))) + ',\n';
|
|
1305
1348
|
});
|
|
1306
1349
|
yield* (0, time_slicing_1.wrapForEachToGenerator)(self.bindDirectives, function* warpForEachGenerator(directive) {
|
|
@@ -1309,7 +1352,13 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1309
1352
|
yield* (0, time_slicing_1.wrapForEachToGenerator)(self.bindStyles, function* warpForEachGenerator(bindStyle) {
|
|
1310
1353
|
code += (yield* bindStyle.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: 1 }))) + ',\n';
|
|
1311
1354
|
});
|
|
1312
|
-
code += (0, translator_1.indent)((state?.tabSize || 0) + 2)
|
|
1355
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 2);
|
|
1356
|
+
if (self.isCorrespondingBusinessComponent) {
|
|
1357
|
+
code += '},\n';
|
|
1358
|
+
}
|
|
1359
|
+
else {
|
|
1360
|
+
code += '],\n';
|
|
1361
|
+
}
|
|
1313
1362
|
}
|
|
1314
1363
|
// 如果子集中有插槽的就
|
|
1315
1364
|
if (children.find((item) => item.tag === 'template' && item.slotTarget)) {
|
|
@@ -1363,7 +1412,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1363
1412
|
}
|
|
1364
1413
|
code += (0, translator_1.indent)(state?.tabSize || 0) + '})';
|
|
1365
1414
|
// 顶层元素是单独的表达式
|
|
1366
|
-
if (parentNode.concept === 'View') {
|
|
1415
|
+
if (parentNode.concept === 'View' || asserts.isBusinessComponent(parentNode)) {
|
|
1367
1416
|
code += ';\n';
|
|
1368
1417
|
}
|
|
1369
1418
|
else {
|
|
@@ -1454,9 +1503,17 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1454
1503
|
delete node.i18nKey;
|
|
1455
1504
|
}
|
|
1456
1505
|
}, { node: element }, { mode: 'anyObject', excludedKeySet: element.JSON_EXCLUDED_KEYS });
|
|
1457
|
-
this.
|
|
1506
|
+
this.likeComponent?.existingViewElement.clear();
|
|
1458
1507
|
return element;
|
|
1459
1508
|
}
|
|
1509
|
+
setTag(tag) {
|
|
1510
|
+
const object = {
|
|
1511
|
+
tag,
|
|
1512
|
+
};
|
|
1513
|
+
this.update({
|
|
1514
|
+
...object,
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1460
1517
|
// 递归遍历组件
|
|
1461
1518
|
traverseChildren(cb) {
|
|
1462
1519
|
utils.traverse((current) => {
|
|
@@ -1780,8 +1837,10 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1780
1837
|
* 转换成设计器中使用的 Vue 文件
|
|
1781
1838
|
* @param options
|
|
1782
1839
|
*/
|
|
1783
|
-
toDesignerVue() {
|
|
1840
|
+
toDesignerVue(options) {
|
|
1784
1841
|
return this.toVue({
|
|
1842
|
+
isRoot: options?.isRoot,
|
|
1843
|
+
asCompontent: options?.asCompontent,
|
|
1785
1844
|
finalCode: false,
|
|
1786
1845
|
nodePathAttr: true,
|
|
1787
1846
|
attrFormat: (attr, element, defaultResult) => {
|
|
@@ -1906,12 +1965,15 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1906
1965
|
isDev: true,
|
|
1907
1966
|
});
|
|
1908
1967
|
}
|
|
1968
|
+
isLikeComponent(node) {
|
|
1969
|
+
return ['View', 'BusinessComponent'].includes(node?.concept);
|
|
1970
|
+
}
|
|
1909
1971
|
// 获取currentList
|
|
1910
1972
|
getCurrentList() {
|
|
1911
1973
|
const argsList = [];
|
|
1912
1974
|
let parent = this.parentNode;
|
|
1913
1975
|
let index = 0;
|
|
1914
|
-
while (parent && parent
|
|
1976
|
+
while (parent && !this.isLikeComponent(parent)) {
|
|
1915
1977
|
if (parent.slotScope) {
|
|
1916
1978
|
argsList.push(index === 0 ? 'current' : 'current' + index);
|
|
1917
1979
|
index++;
|
|
@@ -1946,6 +2008,9 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1946
2008
|
}
|
|
1947
2009
|
return null;
|
|
1948
2010
|
}
|
|
2011
|
+
get businessComponent() {
|
|
2012
|
+
return this.getAncestor('BusinessComponent');
|
|
2013
|
+
}
|
|
1949
2014
|
/**
|
|
1950
2015
|
* 转换成 Vue 的模板格式
|
|
1951
2016
|
*/
|
|
@@ -1954,6 +2019,68 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1954
2019
|
if (options?.isDev && this?.tag === 'u-modal' && isLockField(this)) {
|
|
1955
2020
|
return ``;
|
|
1956
2021
|
}
|
|
2022
|
+
const { finalCode, asCompontent } = options || {};
|
|
2023
|
+
const parts = [];
|
|
2024
|
+
if (finalCode === false) {
|
|
2025
|
+
if (this.tag === 'slot') {
|
|
2026
|
+
if (asCompontent) {
|
|
2027
|
+
return `<div vusion-slot-name="${this.name}">
|
|
2028
|
+
<slot name="${this.name}">
|
|
2029
|
+
<div s-empty="true" bs-empty="true" style="background: #f7f8fa;
|
|
2030
|
+
border: 1px dashed #c3c3c3;
|
|
2031
|
+
text-align: center;
|
|
2032
|
+
color: #999;
|
|
2033
|
+
min-height: 32px;
|
|
2034
|
+
min-width: 32px;
|
|
2035
|
+
width: 100%;
|
|
2036
|
+
align-items: center;
|
|
2037
|
+
display: inline-flex;
|
|
2038
|
+
justify-content: center;">
|
|
2039
|
+
+
|
|
2040
|
+
</div>
|
|
2041
|
+
</slot>
|
|
2042
|
+
</div>`;
|
|
2043
|
+
}
|
|
2044
|
+
else {
|
|
2045
|
+
return `<div vusion-node-path="${this.nodePath}"
|
|
2046
|
+
style="background: linear-gradient(-45deg,#fff 25%,#f3f5fa 0,#f3f5fa 50%,#fff 0,#fff 75%,#f3f5fa 0);
|
|
2047
|
+
background-size: 45px 45px;
|
|
2048
|
+
background-repeat: repeat;
|
|
2049
|
+
line-height: 32px;
|
|
2050
|
+
min-height: 32px;
|
|
2051
|
+
color: var(--font-second-color);
|
|
2052
|
+
text-align: center;">
|
|
2053
|
+
组件占位,可在使用业务组件时插入任意组件
|
|
2054
|
+
</div>`;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
else if (this.businessComponent?.name === this.tag) {
|
|
2058
|
+
// 组件内部使用自身的情况
|
|
2059
|
+
return `<div vusion-node-path="${this.nodePath}"
|
|
2060
|
+
style="background: linear-gradient(-45deg,#fff 25%,#f3f5fa 0,#f3f5fa 50%,#fff 0,#fff 75%,#f3f5fa 0);
|
|
2061
|
+
background-size: 45px 45px;
|
|
2062
|
+
background-repeat: repeat;
|
|
2063
|
+
line-height: 32px;
|
|
2064
|
+
min-height: 32px;
|
|
2065
|
+
color: var(--font-second-color);
|
|
2066
|
+
text-align: center;">
|
|
2067
|
+
在组件内部使用自身可能会导致循环引用,请谨慎使用
|
|
2068
|
+
</div>`;
|
|
2069
|
+
}
|
|
2070
|
+
const isRoot = options.isRoot;
|
|
2071
|
+
if (isRoot && !options?.asCompontent) {
|
|
2072
|
+
parts.push('type="root"');
|
|
2073
|
+
if (this.frontendType?.kind === 'h5') {
|
|
2074
|
+
parts.push('class="l-root-h5"');
|
|
2075
|
+
}
|
|
2076
|
+
else {
|
|
2077
|
+
parts.push('style="height:100%; --custom-start: auto; min-height: 200px;"');
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
if (options) {
|
|
2082
|
+
options.isRoot = false;
|
|
2083
|
+
}
|
|
1957
2084
|
let currentList = [];
|
|
1958
2085
|
if (Array.isArray(options?.currentList)) {
|
|
1959
2086
|
currentList = [...options?.currentList];
|
|
@@ -1995,7 +2122,6 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
1995
2122
|
if (!content.length) {
|
|
1996
2123
|
shouldIndent = false;
|
|
1997
2124
|
}
|
|
1998
|
-
const parts = [];
|
|
1999
2125
|
if (newOptions.aslIdAttr) {
|
|
2000
2126
|
if (newOptions.aslIdAttr === true) {
|
|
2001
2127
|
newOptions.aslIdAttr = 'asl-id';
|
|
@@ -2050,6 +2176,9 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
2050
2176
|
['u-table-view', 'u-list-view', 'u-grid-view', 'u-list-components', 'u-form', 'u-select'].includes(this.tag)) {
|
|
2051
2177
|
this.name && parts.push(`key="${this.name}"`);
|
|
2052
2178
|
}
|
|
2179
|
+
if (this.tag === 'slot') {
|
|
2180
|
+
this.name && parts.push(`name="${this.name}"`);
|
|
2181
|
+
}
|
|
2053
2182
|
let partsLength = 0;
|
|
2054
2183
|
let partsString = '';
|
|
2055
2184
|
parts.forEach((part) => {
|
|
@@ -2077,7 +2206,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
2077
2206
|
super.delete();
|
|
2078
2207
|
if (this.parentNode) {
|
|
2079
2208
|
this.traverseChildren((ele) => {
|
|
2080
|
-
this.
|
|
2209
|
+
this.likeComponent?.removeExistingViewElement(ele);
|
|
2081
2210
|
});
|
|
2082
2211
|
}
|
|
2083
2212
|
}
|
|
@@ -2103,7 +2232,7 @@ let ViewElement = ViewElement_1 = class ViewElement extends BaseNode_1.default {
|
|
|
2103
2232
|
let current = 'current';
|
|
2104
2233
|
let parent = this.parentNode;
|
|
2105
2234
|
let index = 0;
|
|
2106
|
-
while (parent && parent
|
|
2235
|
+
while (parent && !this.isLikeComponent(parent)) {
|
|
2107
2236
|
if (parent.slotScope) {
|
|
2108
2237
|
index++;
|
|
2109
2238
|
}
|