@lcap/nasl 3.7.3-beta.1 → 3.8.0-beta.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/.mocharc.js +0 -1
- package/out/automate/engine/utils.js +6 -1
- package/out/automate/engine/utils.js.map +1 -1
- package/out/bak/translator.js +37 -0
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/shared/utils.d.ts +1 -0
- package/out/breakpoint/shared/utils.js +1 -1
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/common/BaseNode.d.ts +11 -0
- package/out/common/BaseNode.js +101 -5
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/Annotatable__.d.ts +109 -0
- package/out/concepts/Annotatable__.js +161 -0
- package/out/concepts/Annotatable__.js.map +1 -0
- package/out/concepts/AnnotationProperty__.d.ts +48 -0
- package/out/concepts/AnnotationProperty__.js +74 -0
- package/out/concepts/AnnotationProperty__.js.map +1 -0
- package/out/concepts/Annotation__.d.ts +128 -0
- package/out/concepts/Annotation__.js +248 -0
- package/out/concepts/Annotation__.js.map +1 -0
- package/out/concepts/App__.d.ts +14 -26
- package/out/concepts/App__.js +50 -20
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/ApplyAnnotation__.d.ts +87 -0
- package/out/concepts/ApplyAnnotation__.js +140 -0
- package/out/concepts/ApplyAnnotation__.js.map +1 -0
- package/out/concepts/Argument__.d.ts +19 -0
- package/out/concepts/Argument__.js +126 -0
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/AssigneeV2__.d.ts +169 -0
- package/out/concepts/AssigneeV2__.js +176 -1
- package/out/concepts/AssigneeV2__.js.map +1 -1
- package/out/concepts/AuthLogicForCallInterface__.js +1 -1
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/AuthLogic__.js +1 -1
- package/out/concepts/AuthLogic__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +1 -0
- package/out/concepts/BooleanLiteral__.js +9 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/BusinessLogic__.js +1 -1
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallFunction__.js +1 -1
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +15 -0
- package/out/concepts/CallLogic__.js +149 -17
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/ConnectorLogic__.js +1 -1
- package/out/concepts/ConnectorLogic__.js.map +1 -1
- package/out/concepts/DatabaseTypeAnnotation__.d.ts +0 -2
- package/out/concepts/DatabaseTypeAnnotation__.js +0 -20
- package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
- package/out/concepts/DepartmentManagerV2__.d.ts +29 -0
- package/out/concepts/DepartmentManagerV2__.js +56 -0
- package/out/concepts/DepartmentManagerV2__.js.map +1 -0
- package/out/concepts/DepartmentV2__.d.ts +33 -0
- package/out/concepts/DepartmentV2__.js +63 -0
- package/out/concepts/DepartmentV2__.js.map +1 -0
- package/out/concepts/DirectManagerV2__.d.ts +25 -0
- package/out/concepts/DirectManagerV2__.js +53 -0
- package/out/concepts/DirectManagerV2__.js.map +1 -0
- package/out/concepts/End__.js +9 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +0 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +2 -2
- package/out/concepts/Entity__.js +4 -7
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +1 -12
- package/out/concepts/EnumItem__.js +17 -49
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/EnumSelectSetter__.d.ts +4 -0
- package/out/concepts/EnumSelectSetter__.js +7 -0
- package/out/concepts/EnumSelectSetter__.js.map +1 -1
- package/out/concepts/Enum__.js +1 -4
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +1 -1
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +52 -48
- package/out/concepts/FrontendLibrary__.js +45 -36
- package/out/concepts/FrontendLibrary__.js.map +1 -1
- package/out/concepts/FrontendType__.d.ts +4 -0
- package/out/concepts/FrontendType__.js +7 -0
- package/out/concepts/FrontendType__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +2 -0
- package/out/concepts/Frontend__.js +21 -2
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/HistoryProcessV2__.js +4 -1
- package/out/concepts/HistoryProcessV2__.js.map +1 -1
- package/out/concepts/I18nInfo__.d.ts +0 -1
- package/out/concepts/I18nInfo__.js +0 -7
- package/out/concepts/I18nInfo__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +2 -0
- package/out/concepts/Identifier__.js +31 -0
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +2 -2
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.js +1 -4
- package/out/concepts/Interface__.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 +16 -1
- package/out/concepts/Logic__.js +133 -15
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/ManagerV2__.d.ts +34 -0
- package/out/concepts/ManagerV2__.js +61 -0
- package/out/concepts/ManagerV2__.js.map +1 -0
- package/out/concepts/MatchCase__.d.ts +2 -2
- package/out/concepts/MatchCase__.js +7 -7
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +1 -0
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +88 -0
- package/out/concepts/Module__.js +85 -0
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/OperatePermissionV2__.d.ts +1 -1
- package/out/concepts/OperatePermissionV2__.js.map +1 -1
- package/out/concepts/Param__.d.ts +4 -0
- package/out/concepts/Param__.js +13 -21
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElementV2__.d.ts +6 -1
- package/out/concepts/ProcessElementV2__.js +20 -0
- package/out/concepts/ProcessElementV2__.js.map +1 -1
- package/out/concepts/ProcessElement__.d.ts +7 -0
- package/out/concepts/ProcessElement__.js +47 -0
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessV2__.d.ts +1 -34
- package/out/concepts/ProcessV2__.js +3 -70
- package/out/concepts/ProcessV2__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +2 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +2 -2
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/StaticString__.d.ts +0 -4
- package/out/concepts/StaticString__.js +0 -11
- package/out/concepts/StaticString__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +1 -0
- package/out/concepts/StructureProperty__.js +14 -5
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +4 -0
- package/out/concepts/Structure__.js +6 -9
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SubLogic__.d.ts +418 -0
- package/out/concepts/SubLogic__.js +992 -0
- package/out/concepts/SubLogic__.js.map +1 -0
- package/out/concepts/Theme__.d.ts +9 -0
- package/out/concepts/Theme__.js +10 -0
- package/out/concepts/Theme__.js.map +1 -1
- package/out/concepts/Transactional__.d.ts +0 -1
- package/out/concepts/Transactional__.js +0 -7
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +18 -0
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +1 -0
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +6 -1
- package/out/concepts/ValidationRule__.js +6 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +8 -2
- package/out/concepts/ViewElement__.js +213 -32
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +10 -2
- package/out/concepts/View__.js +129 -17
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.processV2.js +50 -4
- package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -1
- package/out/concepts/basics/types/index.js +2 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +9 -0
- package/out/concepts/index__.js +9 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/concepts/utils/asserts.d.ts +409 -0
- package/out/concepts/utils/asserts.js +564 -14
- package/out/concepts/utils/asserts.js.map +1 -1
- package/out/concepts/utils/types.d.ts +33 -2
- package/out/generator/genBundleFiles.d.ts +13 -9
- package/out/generator/genBundleFiles.js +383 -63
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.js +2 -0
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/release-body/body.js +1 -0
- package/out/generator/release-body/body.js.map +1 -1
- package/out/generator/release-body/utils.d.ts +15 -7
- package/out/generator/release-body/utils.js +50 -7
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/natural/genNaturalTS.js +2 -4
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/index.js +0 -2
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.d.ts +1 -1
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +9 -0
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getLogics.js +10 -6
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +6 -0
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcessesV2.d.ts +3 -2
- package/out/server/getProcessesV2.js +15 -6
- package/out/server/getProcessesV2.js.map +1 -1
- package/out/server/naslServer.d.ts +5 -1
- package/out/server/naslServer.js +120 -30
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +4 -0
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.d.ts +2 -1
- package/out/service/storage/init.js +28 -71
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.d.ts +6 -2
- package/out/templator/genCreateBlock.js +25 -8
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.d.ts +22 -0
- package/out/templator/genCurdEditMultipleKeyBlock.js +60 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.d.ts +13 -3
- package/out/templator/genCurdMultipleKeyBlock.js +29 -23
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.d.ts +1 -1
- package/out/templator/genGetBlock.js +3 -2
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genListViewBlock.d.ts +1 -1
- package/out/templator/genListViewBlock.js +3 -2
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.d.ts +1 -1
- package/out/templator/genSelectBlock.js +3 -2
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.d.ts +9 -4
- package/out/templator/genTableBlock.js +31 -17
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.d.ts +2 -2
- package/out/templator/genUpdateBlock.js +11 -11
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/translator/types.d.ts +0 -4
- package/out/translator/utils.d.ts +0 -1
- package/out/translator/utils.js +1 -6
- package/out/translator/utils.js.map +1 -1
- package/out/utils/delay/index.d.ts +0 -0
- package/out/utils/delay/index.js +1 -0
- package/out/utils/delay/index.js.map +1 -0
- package/out/utils/env.d.ts +0 -4
- package/out/utils/env.js +3 -6
- package/out/utils/env.js.map +1 -1
- package/out/utils/index.d.ts +3 -2
- package/out/utils/index.js +18 -14
- package/out/utils/index.js.map +1 -1
- package/out/utils/time-slicing/controller.js.map +1 -1
- package/out/utils/types.d.ts +0 -17
- package/package.json +27 -20
- package/sandbox/stdlib/extension.component.ts +29 -0
- package/sandbox/stdlib/nasl.process.ts +17 -0
- package/sandbox/stdlib/nasl.processV2.ts +10 -5
- package/sandbox/stdlib/nasl.util.ts +3 -1
- package/src/automate/engine/utils.js +7 -2
- package/src/bak/translator.js +42 -1
- package/src/breakpoint/shared/utils.ts +2 -1
- package/src/common/BaseNode.ts +117 -5
- package/src/concepts/Annotatable__.ts +263 -0
- package/src/concepts/AnnotationProperty__.ts +102 -0
- package/src/concepts/Annotation__.ts +344 -0
- package/src/concepts/App__.ts +917 -26
- package/src/concepts/ApplyAnnotation__.ts +198 -0
- package/src/concepts/Argument__.ts +145 -1
- package/src/concepts/AssigneeV2__.ts +387 -1
- package/src/concepts/AuthLogicForCallInterface__.ts +1 -1
- package/src/concepts/AuthLogic__.ts +1 -1
- package/src/concepts/BooleanLiteral__.ts +9 -1
- package/src/concepts/BusinessLogic__.ts +1 -1
- package/src/concepts/CallFunction__.ts +1 -1
- package/src/concepts/CallLogic__.ts +153 -16
- package/src/concepts/ConnectorLogic__.ts +1 -1
- package/src/concepts/DatabaseTypeAnnotation__.ts +0 -11
- package/src/concepts/DepartmentManagerV2__.ts +70 -0
- package/src/concepts/DepartmentV2__.ts +75 -0
- package/src/concepts/DirectManagerV2__.ts +65 -0
- package/src/concepts/End__.ts +10 -1
- package/src/concepts/EntityProperty__.ts +0 -5
- package/src/concepts/Entity__.ts +5 -9
- package/src/concepts/EnumItem__.ts +16 -65
- package/src/concepts/EnumSelectSetter__.ts +6 -0
- package/src/concepts/Enum__.ts +1 -6
- package/src/concepts/ForEachStatement__.ts +1 -1
- package/src/concepts/FrontendLibrary__.ts +88 -80
- package/src/concepts/FrontendType__.ts +6 -0
- package/src/concepts/Frontend__.ts +26 -3
- package/src/concepts/HistoryProcessV2__.ts +5 -0
- package/src/concepts/I18nInfo__.ts +0 -5
- package/src/concepts/Identifier__.ts +32 -0
- package/src/concepts/IfStatement__.ts +2 -2
- package/src/concepts/Interface__.ts +1 -6
- package/src/concepts/LogicItem__.ts +1 -0
- package/src/concepts/Logic__.ts +140 -17
- package/src/concepts/ManagerV2__.ts +78 -0
- package/src/concepts/MatchCase__.ts +9 -8
- package/src/concepts/MemberExpression__.ts +1 -0
- package/src/concepts/Module__.ts +194 -0
- package/src/concepts/OperatePermissionV2__.ts +1 -1
- package/src/concepts/Param__.ts +17 -20
- package/src/concepts/ProcessElementV2__.ts +23 -0
- package/src/concepts/ProcessElement__.ts +18 -0
- package/src/concepts/ProcessV2__.ts +4 -70
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/QueryJoinExpression__.ts +2 -2
- package/src/concepts/StaticString__.ts +0 -13
- package/src/concepts/StructureProperty__.ts +16 -7
- package/src/concepts/Structure__.ts +10 -11
- package/src/concepts/SubLogic__.ts +1516 -0
- package/src/concepts/Theme__.ts +9 -0
- package/src/concepts/Transactional__.ts +0 -5
- package/src/concepts/TriggerLauncher__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +17 -0
- package/src/concepts/TypeParam__.ts +3 -0
- package/src/concepts/ValidationRule__.ts +6 -1
- package/src/concepts/ViewElement__.ts +224 -34
- package/src/concepts/View__.ts +135 -22
- package/src/concepts/basics/stdlib/nasl.processV2.ts +56 -3
- package/src/concepts/basics/types/index.ts +1 -1
- package/src/concepts/index__.ts +9 -0
- package/src/concepts/utils/asserts.ts +595 -0
- package/src/concepts/utils/types.ts +53 -0
- package/src/generator/genBundleFiles.ts +408 -68
- package/src/generator/genMetaData.ts +3 -0
- package/src/generator/release-body/body.ts +1 -0
- package/src/generator/release-body/utils.ts +159 -55
- package/src/natural/genNaturalTS.ts +3 -5
- package/src/natural/getContext/index.ts +0 -2
- package/src/natural/transformTS2UI.ts +5 -2
- package/src/natural/transformTSCode.ts +2 -2
- package/src/server/extendBaseNode.ts +11 -2
- package/src/server/getLogics.ts +9 -7
- package/src/server/getMemberIdentifier.ts +7 -0
- package/src/server/getProcessesV2.ts +16 -6
- package/src/server/naslServer.ts +133 -30
- package/src/server/translator.ts +4 -0
- package/src/service/storage/init.ts +52 -97
- package/src/templator/genCreateBlock.ts +35 -14
- package/src/templator/genCurdEditMultipleKeyBlock.ts +65 -1
- package/src/templator/genCurdMultipleKeyBlock.ts +42 -23
- package/src/templator/genGetBlock.ts +4 -3
- package/src/templator/genListViewBlock.ts +3 -3
- package/src/templator/genSelectBlock.ts +4 -2
- package/src/templator/genTableBlock.ts +32 -17
- package/src/templator/genUpdateBlock.ts +21 -18
- package/src/translator/types.ts +0 -4
- package/src/translator/utils.ts +0 -6
- package/src/utils/delay/index.ts +0 -0
- package/src/utils/env.ts +4 -5
- package/src/utils/index.ts +16 -4
- package/src/utils/time-slicing/controller.ts +1 -0
- package/src/utils/types.ts +0 -20
- package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +2 -1
- package/ts-worker/bundle.js +1 -1
- package/ts-worker/src/index.js +1 -0
- package/out/utils/language-cache/constant.d.ts +0 -18
- package/out/utils/language-cache/constant.js +0 -35
- package/out/utils/language-cache/constant.js.map +0 -1
- package/out/utils/language-cache/index.d.ts +0 -2
- package/out/utils/language-cache/index.js +0 -19
- package/out/utils/language-cache/index.js.map +0 -1
- package/out/utils/language-cache/nasl.d.ts +0 -10
- package/out/utils/language-cache/nasl.js +0 -98
- package/out/utils/language-cache/nasl.js.map +0 -1
- package/out/utils/language-cache/types.d.ts +0 -44
- package/out/utils/language-cache/types.js +0 -4
- package/out/utils/language-cache/types.js.map +0 -1
- package/src/utils/language-cache/constant.ts +0 -37
- package/src/utils/language-cache/index.ts +0 -2
- package/src/utils/language-cache/nasl.ts +0 -83
- package/src/utils/language-cache/types.ts +0 -48
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as JSON5 from 'json5';
|
|
2
|
-
import * as UglifyJS from 'uglify-js-export';
|
|
3
2
|
import * as utils from '../utils';
|
|
4
3
|
import { config as globalConfig } from '../config'
|
|
5
4
|
|
|
@@ -12,12 +11,18 @@ import { compileComponent } from './compileComponent';
|
|
|
12
11
|
import { genMetaData } from './genMetaData';
|
|
13
12
|
import { integrateMicroApp } from './microApp';
|
|
14
13
|
import type { Asset } from './release-body/internal';
|
|
14
|
+
// @ts-ignore FIXME wudengke 类型在构建前找不到的问题
|
|
15
|
+
import { compileNASLToReactDist } from '@lcap/nasl-unified-frontend-generator';
|
|
15
16
|
|
|
16
17
|
export interface Route {
|
|
17
18
|
path?: string;
|
|
18
19
|
component?: RawOptions; // ExtendedVue<Vue, unknown, unknown, unknown, Record<never, any>>;
|
|
19
20
|
children?: Array<Route>;
|
|
20
21
|
redirect?: string;
|
|
22
|
+
lazyPath?: string;
|
|
23
|
+
meta?: {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
interface Config {
|
|
@@ -38,6 +43,7 @@ interface Config {
|
|
|
38
43
|
devDnsAddr: string;
|
|
39
44
|
miniEnable: boolean;
|
|
40
45
|
isPreviewFe?: boolean;
|
|
46
|
+
framework?: "vue" | "react";
|
|
41
47
|
previewVersion?: string;
|
|
42
48
|
assets: Array<Asset>;
|
|
43
49
|
assetsMap: Map<string, Asset>;
|
|
@@ -90,6 +96,108 @@ function genComponetCode(component: RawOptions) {
|
|
|
90
96
|
})()`;
|
|
91
97
|
}
|
|
92
98
|
|
|
99
|
+
// 生成导入组件代码
|
|
100
|
+
function genImportComponetCode(componentPath: string) {
|
|
101
|
+
return `() => importComponent('${componentPath}')`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 生成导出组件代码
|
|
105
|
+
function genExportComponetCode(component: RawOptions) {
|
|
106
|
+
return `var componentOptions = ${component.script ? `(function(){\n${component.script.trim().replace(/export default |module\.exports +=/, 'return ')}\n})()` : '{}'
|
|
107
|
+
};
|
|
108
|
+
Object.assign(componentOptions, {
|
|
109
|
+
template: \`${component.template.replace(/[`$]/g, (m) => `\\${m}`)}\`,
|
|
110
|
+
});
|
|
111
|
+
return componentOptions;`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 获取文件路径
|
|
115
|
+
// name 或者 文件 至少有一个必填
|
|
116
|
+
const getCompletePath = (name: string, fileContent: string) => {
|
|
117
|
+
let fileName = '';
|
|
118
|
+
if (name) {
|
|
119
|
+
fileName += `${name}.`;
|
|
120
|
+
}
|
|
121
|
+
if (fileContent) {
|
|
122
|
+
fileName += `${genHash(fileContent)}.`;
|
|
123
|
+
}
|
|
124
|
+
fileName += `min.js`;
|
|
125
|
+
|
|
126
|
+
return fileName;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
function genRouterFileContent(routes: Route[], defaultRoute: string) {
|
|
131
|
+
function routeToString(route: Route): string {
|
|
132
|
+
let content = `{
|
|
133
|
+
path: '${route.path}',\n`;
|
|
134
|
+
if (route?.lazyPath) {
|
|
135
|
+
const routeLazyPath = route.lazyPath;
|
|
136
|
+
content += `lazyPath: '${routeLazyPath}',\n`;
|
|
137
|
+
content += `component: ${genImportComponetCode(route.lazyPath)},\n`;
|
|
138
|
+
}
|
|
139
|
+
if (route?.meta) {
|
|
140
|
+
content += `meta: ${stringifyMetaData(route.meta)},`;
|
|
141
|
+
}
|
|
142
|
+
if (route?.children?.length) {
|
|
143
|
+
content += `children: [
|
|
144
|
+
${route.children.map(routeToString).join(',\n')}
|
|
145
|
+
],\n`;
|
|
146
|
+
}
|
|
147
|
+
if (route?.redirect) {
|
|
148
|
+
content += `redirect: '${route?.redirect}',\n`;
|
|
149
|
+
}
|
|
150
|
+
content += '}';
|
|
151
|
+
return content;
|
|
152
|
+
}
|
|
153
|
+
// 生成路由配置
|
|
154
|
+
let routesStr = `const routers = [`;
|
|
155
|
+
routes.forEach((route) => {
|
|
156
|
+
routesStr += `${routeToString(route)},\n`;
|
|
157
|
+
});
|
|
158
|
+
if (defaultRoute) {
|
|
159
|
+
routesStr += `{
|
|
160
|
+
path: '*',
|
|
161
|
+
redirect: '${defaultRoute}',
|
|
162
|
+
}\n`;
|
|
163
|
+
}
|
|
164
|
+
routesStr += `];
|
|
165
|
+
return routers;`;
|
|
166
|
+
return routesStr;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// 生成路由文件
|
|
170
|
+
function genRouteFiles(routes: Route[], defaultRoute: string) {
|
|
171
|
+
// 生成路由文件列表
|
|
172
|
+
const routeFiles: any[] = [];
|
|
173
|
+
function routeToFile(route: Route) {
|
|
174
|
+
console.log(route, 'route');
|
|
175
|
+
if (route?.component?.script) {
|
|
176
|
+
const content = genExportComponetCode(route.component);
|
|
177
|
+
const lazyPath = getCompletePath(null, content);
|
|
178
|
+
route.lazyPath = lazyPath;
|
|
179
|
+
routeFiles.push({
|
|
180
|
+
name: lazyPath,
|
|
181
|
+
content,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (route?.children?.length) {
|
|
185
|
+
route.children.map(routeToFile);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
routes.forEach((route) => {
|
|
189
|
+
routeToFile(route);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
let routerPath = getCompletePath('router', null);
|
|
193
|
+
|
|
194
|
+
routeFiles.push({
|
|
195
|
+
name: routerPath,
|
|
196
|
+
isRouterFile: true,
|
|
197
|
+
content: genRouterFileContent(routes, defaultRoute),
|
|
198
|
+
});
|
|
199
|
+
return routeFiles;
|
|
200
|
+
}
|
|
93
201
|
export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
94
202
|
// 获取端类型
|
|
95
203
|
const frontendType = frontend.getAncestor('FrontendType') as FrontendType;
|
|
@@ -147,6 +255,22 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
147
255
|
config?.debug && clearBreakpoints(app);
|
|
148
256
|
}
|
|
149
257
|
|
|
258
|
+
const getBundleFileName = () => {
|
|
259
|
+
if (config.isPreviewFe && config.previewVersion) {
|
|
260
|
+
return `mockBundle-${config.previewVersion}`;
|
|
261
|
+
} else {
|
|
262
|
+
return 'bundle';
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
let baseUrl = `${config.STATIC_URL}/${config.tenant}/${app.id}/${config.env}`;
|
|
266
|
+
let { basePath } = frontend;
|
|
267
|
+
|
|
268
|
+
if (config.isExport as any) {
|
|
269
|
+
baseUrl = '';
|
|
270
|
+
// basePath = '';
|
|
271
|
+
}
|
|
272
|
+
let completePath = `${baseUrl}${basePath || ''}/`;
|
|
273
|
+
|
|
150
274
|
/**
|
|
151
275
|
* vue.config.js page options
|
|
152
276
|
*/
|
|
@@ -186,6 +310,7 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
186
310
|
path: routePath,
|
|
187
311
|
component: compileComponent(componentMap[view.id]),
|
|
188
312
|
children: [],
|
|
313
|
+
meta: view.getRouteMeta(),
|
|
189
314
|
};
|
|
190
315
|
const viewChildren = view.children;
|
|
191
316
|
if (Array.isArray(viewChildren) && viewChildren.length) {
|
|
@@ -196,7 +321,7 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
196
321
|
if (subView.isIndex) {
|
|
197
322
|
route.children.push({
|
|
198
323
|
path: '',
|
|
199
|
-
redirect:
|
|
324
|
+
redirect: subView.name,
|
|
200
325
|
});
|
|
201
326
|
}
|
|
202
327
|
}
|
|
@@ -221,14 +346,14 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
221
346
|
if (view.isIndex) {
|
|
222
347
|
routes.push({
|
|
223
348
|
path: frontend.prefixPath ? frontend.prefixPath : '/',
|
|
224
|
-
redirect:
|
|
349
|
+
redirect: `${frontend.prefixPath}/${view.name}`,
|
|
225
350
|
});
|
|
226
351
|
}
|
|
227
352
|
});
|
|
228
353
|
if (frontend.prefixPath) {
|
|
229
354
|
routes.push({
|
|
230
355
|
path: '/',
|
|
231
|
-
redirect:
|
|
356
|
+
redirect: frontend.prefixPath,
|
|
232
357
|
});
|
|
233
358
|
}
|
|
234
359
|
const authResourcePathMap: any = {};
|
|
@@ -255,35 +380,16 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
255
380
|
});
|
|
256
381
|
}
|
|
257
382
|
const authResourcePaths: string[] = Object.keys(authResourcePathMap);
|
|
258
|
-
function routeToString(route: Route): string {
|
|
259
|
-
let content = `{
|
|
260
|
-
path: '${route.path}',\n`;
|
|
261
|
-
if (route?.component?.script) {
|
|
262
|
-
content += `component: ${genComponetCode(route.component)},\n`;
|
|
263
|
-
}
|
|
264
|
-
if (route?.children?.length) {
|
|
265
|
-
content += `children: [
|
|
266
|
-
${route.children.map(routeToString).join(',\n')}
|
|
267
|
-
],\n`;
|
|
268
|
-
}
|
|
269
|
-
if (route?.redirect) {
|
|
270
|
-
content += `redirect: ${route?.redirect},\n`;
|
|
271
|
-
}
|
|
272
|
-
content += '}';
|
|
273
|
-
return content;
|
|
274
|
-
}
|
|
275
383
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
routesStr += ']';
|
|
384
|
+
const routerFiles = genRouteFiles(routes, defaultRoute);
|
|
385
|
+
routerFiles.forEach(item => {
|
|
386
|
+
item.name = completePath + item.name;
|
|
387
|
+
// 在路由文件上存入端的信息,后续页面维度发布时候做标识
|
|
388
|
+
if (item.isRouterFile) {
|
|
389
|
+
item.frontendName = frontend.name;
|
|
390
|
+
item.baseUrl = baseUrl;
|
|
391
|
+
}
|
|
392
|
+
})
|
|
287
393
|
|
|
288
394
|
let fileI18nInfo: any = {
|
|
289
395
|
enabled: false,
|
|
@@ -373,11 +479,12 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
373
479
|
);
|
|
374
480
|
const metaData = genMetaData(app, frontend, config);
|
|
375
481
|
const metaDataStr = stringifyMetaData(metaData);
|
|
376
|
-
|
|
377
|
-
const assetsInfo = app.genAllAssetsInfo(STATIC_URL, frontend.type);
|
|
482
|
+
|
|
483
|
+
const assetsInfo = app.genAllAssetsInfo(STATIC_URL, frontend.type, frontendType.frameworkKind);
|
|
378
484
|
const customNames = JSON5.stringify(assetsInfo.custom.names);
|
|
379
485
|
|
|
380
|
-
|
|
486
|
+
|
|
487
|
+
let content = `(async function(){
|
|
381
488
|
`;
|
|
382
489
|
if (frontend.globalScaleEnabled) {
|
|
383
490
|
content += `{
|
|
@@ -464,8 +571,81 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
464
571
|
content += `
|
|
465
572
|
var platformConfig = ${platformConfig};
|
|
466
573
|
var metaData = ${metaDataStr};
|
|
467
|
-
var routes = ${routesStr};
|
|
468
574
|
|
|
575
|
+
var getCompletePath = (path) => {
|
|
576
|
+
return '${completePath}' + path;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// 低版本
|
|
580
|
+
function importXMLHttpRequestComponent (scriptUrl) {
|
|
581
|
+
return new Promise(function(resolve, reject) {
|
|
582
|
+
var xhr = new XMLHttpRequest();
|
|
583
|
+
xhr.open('GET', scriptUrl, true);
|
|
584
|
+
xhr.onreadystatechange = function() {
|
|
585
|
+
if (xhr.readyState === 4) {
|
|
586
|
+
if (xhr.status === 200) {
|
|
587
|
+
var scriptContent = xhr.responseText;
|
|
588
|
+
try {
|
|
589
|
+
var func = new Function(scriptContent);
|
|
590
|
+
var result = func();
|
|
591
|
+
resolve(result);
|
|
592
|
+
} catch (error) {
|
|
593
|
+
reject(error);
|
|
594
|
+
}
|
|
595
|
+
} else {
|
|
596
|
+
reject(new Error('Failed to fetch script'));
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
xhr.send();
|
|
601
|
+
});
|
|
602
|
+
};
|
|
603
|
+
function importFetchComponent(scriptUrl) {
|
|
604
|
+
return fetch(scriptUrl)
|
|
605
|
+
.then(function(response) {
|
|
606
|
+
if (!response.ok) {
|
|
607
|
+
throw new Error('Network response was not ok');
|
|
608
|
+
}
|
|
609
|
+
return response.text();
|
|
610
|
+
}).then(function(scriptText) {
|
|
611
|
+
var func = new Function(scriptText);
|
|
612
|
+
var result = func();
|
|
613
|
+
return result;
|
|
614
|
+
})
|
|
615
|
+
.catch(error => {
|
|
616
|
+
console.error('Error loading script:', error);
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
window.importComponent = (scriptUrl) => {
|
|
620
|
+
scriptUrl = getCompletePath(scriptUrl);
|
|
621
|
+
// 浏览器支持fetch,直接使用fetch
|
|
622
|
+
if (window.fetch) {
|
|
623
|
+
return importFetchComponent(scriptUrl);
|
|
624
|
+
}
|
|
625
|
+
return importXMLHttpRequestComponent(scriptUrl);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
var routes = await importComponent('${getCompletePath('router', null)}?t=' + Date.now());
|
|
629
|
+
`;
|
|
630
|
+
// 按页面维度发布先不考虑鉴权,页面维度新增的页面都算是不鉴权的数组中
|
|
631
|
+
// 只有完全页面维度新增的才会进入到这个数组中
|
|
632
|
+
if (config.env === 'dev') {
|
|
633
|
+
content += `
|
|
634
|
+
function iterateRouters(routers, parentPath = '') {
|
|
635
|
+
routers.forEach(function(route) {
|
|
636
|
+
var fullPath = parentPath + route.path;
|
|
637
|
+
if (fullPath === '*') return;
|
|
638
|
+
if (!(platformConfig.authResourcePaths.includes(fullPath) || platformConfig.baseResourcePaths.includes(fullPath))) {
|
|
639
|
+
platformConfig.baseResourcePaths.push(fullPath);
|
|
640
|
+
}
|
|
641
|
+
if (route.children) {
|
|
642
|
+
iterateRouters(route.children, fullPath + '/');
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
iterateRouters(routes);`;
|
|
647
|
+
}
|
|
648
|
+
content += `
|
|
469
649
|
window.createLcapApp = () => {
|
|
470
650
|
appVM = window.cloudAdminDesigner.init(platformConfig.appConfig, platformConfig, routes, metaData);
|
|
471
651
|
${compRegStr}
|
|
@@ -478,7 +658,7 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
478
658
|
|
|
479
659
|
return window.appVM = appVM;
|
|
480
660
|
};
|
|
481
|
-
window.createLcapApp()
|
|
661
|
+
window.createLcapApp();`;
|
|
482
662
|
if (frontend.globalScaleEnabled) {
|
|
483
663
|
content += `
|
|
484
664
|
// 同步逻辑仅在 iframe 内部执行
|
|
@@ -629,21 +809,67 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
629
809
|
`;
|
|
630
810
|
content += str;
|
|
631
811
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
812
|
+
let annoDep = app?.dependencies?.filter(dep=>dep?.annotations?.length>0)
|
|
813
|
+
annoDep?.map(dep=>{
|
|
814
|
+
dep?.annotations?.filter(anno=>anno.applyTo.includes('ViewElement'))
|
|
815
|
+
.map(anno=>{
|
|
816
|
+
let depName = dep.name;
|
|
817
|
+
let annoName =anno.name;
|
|
818
|
+
let annoStr= `
|
|
819
|
+
const ${annoName} = {
|
|
820
|
+
async handle(el, binding, vnode, oldVnode) {
|
|
821
|
+
if(window.Vue.prototype.$library && window.Vue.prototype.$library['${depName}']){
|
|
822
|
+
window.Vue.prototype.$library['${depName}'].${annoName}(el, binding, vnode, oldVnode)
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
bind(el, binding, vnode, oldVnode) {
|
|
826
|
+
${annoName}.handle(el, binding, vnode, oldVnode);
|
|
827
|
+
},
|
|
828
|
+
update(el, binding, vnode, oldVnode) {
|
|
829
|
+
${annoName}.handle(el, binding, vnode, oldVnode);
|
|
830
|
+
},
|
|
831
|
+
};
|
|
832
|
+
window.Vue.directive('${annoName}', ${annoName});`
|
|
833
|
+
content += annoStr;
|
|
834
|
+
})
|
|
835
|
+
})
|
|
836
|
+
let hasViewElementAnno = annoDep?.filter(dep=>dep?.annotations?.filter(anno=>anno.applyTo.includes('ViewElement'))?.length>0)?.length>0
|
|
837
|
+
if(hasViewElementAnno){
|
|
838
|
+
const fetchAnnoData = `
|
|
839
|
+
function fetchAnnoData() {
|
|
840
|
+
return new Promise(async (resolve, reject) => {
|
|
841
|
+
if (window.annotationAllData) {
|
|
842
|
+
resolve(window.annotationAllData);
|
|
843
|
+
} else {
|
|
844
|
+
let urlEntity = '/api/system/annotation/entityAll'
|
|
845
|
+
let urlLogic = '/api/system/annotation/logicAll'
|
|
846
|
+
Promise.all([
|
|
847
|
+
fetch(urlEntity).then(response => response.json()),
|
|
848
|
+
fetch(urlLogic).then(response => response.json())
|
|
849
|
+
])
|
|
850
|
+
.then(([entityAll, logicAll]) => {
|
|
851
|
+
window.annotationAllData = {
|
|
852
|
+
entityAll,
|
|
853
|
+
logicAll
|
|
854
|
+
};
|
|
855
|
+
resolve(window.annotationAllData);
|
|
856
|
+
}).catch(err => {
|
|
857
|
+
console.log('err: ', err);
|
|
858
|
+
})
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
};
|
|
862
|
+
fetchAnnoData();
|
|
863
|
+
`
|
|
864
|
+
content += fetchAnnoData;
|
|
640
865
|
|
|
641
|
-
if ((config.isExport) as any){
|
|
642
|
-
baseUrl = '';
|
|
643
|
-
// basePath = '';
|
|
644
866
|
}
|
|
645
867
|
|
|
646
|
-
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
console.time('genHash')
|
|
871
|
+
let bundleMinPath = completePath + getCompletePath(getBundleFileName(), content);
|
|
872
|
+
console.timeEnd('genHash');
|
|
647
873
|
|
|
648
874
|
const otherJsList = (frontend as any)?.appletsConfig?.enable ? ['//res.wx.qq.com/open/js/jweixin-1.3.2.js'] : [];
|
|
649
875
|
|
|
@@ -653,7 +879,6 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
653
879
|
otherJsList.push(`${STATIC_URL}/packages/@lcap/breakpoint-client@1.0.0/dist/index.js?time=${Date.now()}`);
|
|
654
880
|
}
|
|
655
881
|
let jsAssetsList = assetsInfo.basic.js.concat(assetsInfo.custom.js, otherJsList).concat([bundleMinPath])
|
|
656
|
-
|
|
657
882
|
let cssAssetsList = assetsInfo.basic.css.concat(assetsInfo.custom.css)
|
|
658
883
|
if(config.isPreviewFe){
|
|
659
884
|
const changeToRelativePath =(str:any)=>{
|
|
@@ -774,7 +999,7 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
774
999
|
// 导出源码才处理
|
|
775
1000
|
if (config.isExport && Array.isArray(assets) && assets.length) {
|
|
776
1001
|
const assetsMap = config.assetsMap;
|
|
777
|
-
const regex = new RegExp(assets.map((asset) => asset.fileUrl?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join(
|
|
1002
|
+
const regex = new RegExp(assets.map((asset) => asset.fileUrl?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'), 'g');
|
|
778
1003
|
content = content.replace(regex, (url) => {
|
|
779
1004
|
const asset = assetsMap.get(url);
|
|
780
1005
|
if (asset) {
|
|
@@ -796,29 +1021,19 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
796
1021
|
return url;
|
|
797
1022
|
});
|
|
798
1023
|
}
|
|
799
|
-
|
|
800
|
-
// 开发环境加上sourceMap
|
|
801
|
-
if (config.env === 'dev') {
|
|
802
|
-
minifyObj.code = content;
|
|
803
|
-
} else {
|
|
804
|
-
minifyObj = UglifyJS.minify(content, {
|
|
805
|
-
compress: {
|
|
806
|
-
// @ts-ignore
|
|
807
|
-
awaits: false,
|
|
808
|
-
},
|
|
809
|
-
});
|
|
810
|
-
}
|
|
1024
|
+
|
|
811
1025
|
const outputs = [
|
|
812
1026
|
{
|
|
813
1027
|
name: bundleMinPath,
|
|
814
|
-
content
|
|
1028
|
+
content,
|
|
815
1029
|
},
|
|
816
1030
|
{
|
|
817
1031
|
name: basePath ? `${baseUrl}${basePath}/client.js` : `${baseUrl}/client.js`,
|
|
818
1032
|
content: assetsContent,
|
|
819
1033
|
},
|
|
1034
|
+
...routerFiles,
|
|
820
1035
|
];
|
|
821
|
-
|
|
1036
|
+
console.log('outputs', outputs)
|
|
822
1037
|
return outputs;
|
|
823
1038
|
}
|
|
824
1039
|
|
|
@@ -827,10 +1042,135 @@ export async function genFrontendBundleFiles(app: App, frontends: Array<Frontend
|
|
|
827
1042
|
|
|
828
1043
|
// 这里逐个处理并且中间还要等待,是为了腾出时间给主线程做垃圾回收
|
|
829
1044
|
for (const frontend of frontends) {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
1045
|
+
if(frontend.frameworkKind === 'react'){
|
|
1046
|
+
const files: {path: string, content: string}[] = await compileNASLToReactDist(app, frontend, config);
|
|
1047
|
+
result.push(
|
|
1048
|
+
...files.map((x) => {
|
|
1049
|
+
return { name: x.path, content: x.content };
|
|
1050
|
+
})
|
|
1051
|
+
);
|
|
1052
|
+
}else{
|
|
1053
|
+
const data = await genBundleFiles(app, frontend, config);
|
|
1054
|
+
result.push(...data);
|
|
1055
|
+
await utils.delay(1000);
|
|
1056
|
+
}
|
|
833
1057
|
}
|
|
834
1058
|
|
|
835
1059
|
return result;
|
|
836
1060
|
}
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
export function getOneFiles(options: { view: View; action: string; cacheRouterData: any }) {
|
|
1064
|
+
const { view, action, cacheRouterData } = options;
|
|
1065
|
+
const routesStr = cacheRouterData.content;
|
|
1066
|
+
const func = new Function(routesStr);
|
|
1067
|
+
const cacheRouters = func();
|
|
1068
|
+
const frontend = view.frontend;
|
|
1069
|
+
/**
|
|
1070
|
+
* 几种情况
|
|
1071
|
+
* 1.完全新增了页面从顶层到下面都是新的页面, 发顶层 (仅自己 和 )
|
|
1072
|
+
* 2.完全新增了页面从顶层到下面都是新的页面, 发中间某层
|
|
1073
|
+
* 3.完全新增了页面从顶层到下面都是新的页面, 发底层
|
|
1074
|
+
* 4.替换中间的单页
|
|
1075
|
+
*/
|
|
1076
|
+
// 传递当前节点过来,需要找到顶层节点,然后在下面路由表中查找
|
|
1077
|
+
|
|
1078
|
+
function changeItem(view: View) {
|
|
1079
|
+
const viewOption = view.toVueOptions();
|
|
1080
|
+
const isRootView = view.parentNode.concept !== 'View';
|
|
1081
|
+
// 路由地址
|
|
1082
|
+
const viewName = view.name;
|
|
1083
|
+
let routePath = viewName;
|
|
1084
|
+
if (isRootView) {
|
|
1085
|
+
routePath = `${frontend.prefixPath}/${viewName}`;
|
|
1086
|
+
}
|
|
1087
|
+
const route: Route = {
|
|
1088
|
+
path: routePath,
|
|
1089
|
+
component: compileComponent(viewOption),
|
|
1090
|
+
children: [],
|
|
1091
|
+
meta: view.getRouteMeta(),
|
|
1092
|
+
};
|
|
1093
|
+
return route;
|
|
1094
|
+
}
|
|
1095
|
+
let currentView: any = view;
|
|
1096
|
+
let currentRoute: Route = null;
|
|
1097
|
+
while (currentView?.concept === 'View') {
|
|
1098
|
+
if (currentRoute) {
|
|
1099
|
+
const child = currentRoute;
|
|
1100
|
+
currentRoute = changeItem(currentView);
|
|
1101
|
+
currentRoute.children.push(child);
|
|
1102
|
+
} else {
|
|
1103
|
+
// 当前点击发布的节点,也就是树的最后一层
|
|
1104
|
+
currentRoute = changeItem(currentView);
|
|
1105
|
+
if (action === 'all') {
|
|
1106
|
+
// 生成子页面所有内容
|
|
1107
|
+
function traverseChildren(currentView: View, currentRoute: Route) {
|
|
1108
|
+
currentView.children.forEach((childView: View) => {
|
|
1109
|
+
const childRoute = changeItem(childView);
|
|
1110
|
+
currentRoute.children.push(childRoute);
|
|
1111
|
+
traverseChildren(childView, childRoute);
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
traverseChildren(currentView, currentRoute);
|
|
1115
|
+
}
|
|
1116
|
+
// 如果当前发布的节点没有子集,那么将子集置空,后续在合并中遇到null,就表示真的没有子集,会直接把缓存的子路径置空
|
|
1117
|
+
if (!currentView.children.length) {
|
|
1118
|
+
currentRoute.children = null;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
currentView = currentView.parentNode;
|
|
1122
|
+
}
|
|
1123
|
+
console.log(currentRoute);
|
|
1124
|
+
|
|
1125
|
+
function addOrUpdateRoute(routes: Route[], newRoute: Route) {
|
|
1126
|
+
const existingRoute = routes.find((route) => route.path === newRoute.path);
|
|
1127
|
+
|
|
1128
|
+
if (existingRoute) {
|
|
1129
|
+
// 如果找到了现有路由,更新 component 和 meta
|
|
1130
|
+
existingRoute.component = newRoute.component;
|
|
1131
|
+
existingRoute.meta = newRoute.meta;
|
|
1132
|
+
|
|
1133
|
+
// 递归合并子路由
|
|
1134
|
+
if (newRoute.children) {
|
|
1135
|
+
existingRoute.children = existingRoute.children || [];
|
|
1136
|
+
newRoute.children?.forEach((newChild) => {
|
|
1137
|
+
addOrUpdateRoute(existingRoute.children, newChild);
|
|
1138
|
+
});
|
|
1139
|
+
} else {
|
|
1140
|
+
existingRoute.children = [];
|
|
1141
|
+
}
|
|
1142
|
+
} else {
|
|
1143
|
+
// 如果没有找到,直接推入新路由
|
|
1144
|
+
routes.unshift(newRoute);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
function coverUpdateRoute(routes: Route[], newRoute: Route) {
|
|
1148
|
+
const findIndex = routes.findIndex((route) => route.path === newRoute.path);
|
|
1149
|
+
if (findIndex !== -1) {
|
|
1150
|
+
// 如果找到了现有路由,就删除掉 后面新推入
|
|
1151
|
+
routes.splice(findIndex, 1);
|
|
1152
|
+
}
|
|
1153
|
+
// 直接推入新路由
|
|
1154
|
+
routes.unshift(newRoute);
|
|
1155
|
+
}
|
|
1156
|
+
if (action === 'all') {
|
|
1157
|
+
coverUpdateRoute(cacheRouters, currentRoute);
|
|
1158
|
+
} else {
|
|
1159
|
+
addOrUpdateRoute(cacheRouters, currentRoute);
|
|
1160
|
+
}
|
|
1161
|
+
console.log(cacheRouters, 111);
|
|
1162
|
+
const routerFiles = genRouteFiles(cacheRouters, null);
|
|
1163
|
+
const completePath = `${cacheRouterData.baseUrl}${frontend.basePath || ''}/`;
|
|
1164
|
+
const outputs = routerFiles;
|
|
1165
|
+
routerFiles.forEach((item) => {
|
|
1166
|
+
item.name = completePath + item.name;
|
|
1167
|
+
// 在路由文件上存入端的信息,后续页面维度发布时候做标识
|
|
1168
|
+
if (item.isRouterFile) {
|
|
1169
|
+
item.frontendName = cacheRouterData.frontendName;
|
|
1170
|
+
item.baseUrl = cacheRouterData.baseUrl;
|
|
1171
|
+
item.ideVersion = cacheRouterData.ideVersion;
|
|
1172
|
+
}
|
|
1173
|
+
});
|
|
1174
|
+
console.log('outputs: ', outputs);
|
|
1175
|
+
return outputs;
|
|
1176
|
+
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
uiStructures,
|
|
9
9
|
collectionStructures,
|
|
10
10
|
configurationEnums,
|
|
11
|
+
processV2Enums,
|
|
11
12
|
interfaceStructures,
|
|
12
13
|
processStructures,
|
|
13
14
|
processV2Structures,
|
|
@@ -98,6 +99,8 @@ export function genMetaData(app: App, frontend: Frontend, config: any) {
|
|
|
98
99
|
|
|
99
100
|
// 内置国际化枚举
|
|
100
101
|
enums.push(...configurationEnums)
|
|
102
|
+
// 内置流程枚举
|
|
103
|
+
enums.push(...processV2Enums)
|
|
101
104
|
app.interfaces.forEach(it=>{
|
|
102
105
|
it && interfaces.push(it as Interface);
|
|
103
106
|
})
|