GeezerVison is showing github.com — feat: add static field displayName for Component type · Juny0117/lowcode-engine@a8ab86e
File treeExpand file treeCollapse file tree Open diff view settings modules/code-generator/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/src/plugins/component/react/containerClass.ts +13-1Lines changed: 13 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,7 +26,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => { | 26 | 26 |
| 27 | 27 | // 将模块名转换成 PascalCase 的格式,并添加特定后缀,防止命名冲突 | 28 | 28 | const componentClassName = ensureValidClassName( | 29 | | - `${changeCase.pascalCase(ir.moduleName)}$$Page`, | | 29 | + `${changeCase.pascalCase(ir.moduleName)}$$${ir.containerType}`, | 30 | 30 | ); | 31 | 31 |
| 32 | 32 | next.chunks.push({ | @@ -43,6 +43,18 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => { | 43 | 43 | ], | 44 | 44 | }); | 45 | 45 |
| | 46 | + if (ir.containerType === 'Component') { | | 47 | + next.chunks.push({ | | 48 | + type: ChunkType.STRING, | | 49 | + fileType: FileType.JSX, | | 50 | + name: CLASS_DEFINE_CHUNK_NAME.InsVar, | | 51 | + content: `static displayName = '${changeCase.pascalCase(ir.moduleName)}';`, | | 52 | + linkAfter: [ | | 53 | + CLASS_DEFINE_CHUNK_NAME.Start, | | 54 | + ], | | 55 | + }); | | 56 | + } | | 57 | + | 46 | 58 | next.chunks.push({ | 47 | 59 | type: ChunkType.STRING, | 48 | 60 | fileType: FileType.JSX, | |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/src/types/deps.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -35,4 +35,4 @@ export interface IDependency { | 35 | 35 | main?: string; // 包导出组件入口文件路径 /lib/input | 36 | 36 | dependencyType?: DependencyType; // 依赖类型 内/外 | 37 | 37 | componentName?: string; // 导入后名称 | 38 | | -} | | 38 | +} |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/src/utils/common.ts +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import type { IPublicTypeJSExpression, IPublicTypeJSFunction } from '@alilc/lowcode-types'; | 2 | 2 | import changeCase from 'change-case'; | 3 | 3 | import short from 'short-uuid'; | | 4 | +import { DependencyType, IDependency, IExternalDependency, IInternalDependency } from '../types'; | 4 | 5 |
| 5 | 6 | // Doc: https://www.npmjs.com/package/change-case | 6 | 7 |
| @@ -43,4 +44,16 @@ export function getStaticExprValue<T>(expr: string): T { | 43 | 44 |
| 44 | 45 | export function isJSExpressionFn(data: any): data is IPublicTypeJSFunction { | 45 | 46 | return data?.type === 'JSExpression' && data?.extType === 'function'; | | 47 | +} | | 48 | + | | 49 | +export function isInternalDependency( | | 50 | + dependency: IDependency, | | 51 | +): dependency is IInternalDependency { | | 52 | + return dependency.dependencyType === DependencyType.Internal; | | 53 | +} | | 54 | + | | 55 | +export function isExternalDependency( | | 56 | + dependency: IDependency, | | 57 | +): dependency is IExternalDependency { | | 58 | + return dependency.dependencyType === DependencyType.External; | 46 | 59 | } |
|