mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-14 04:43:14 +00:00
feat: add static field displayName for Component type
This commit is contained in:
parent
676e49ee2c
commit
a8ab86ebb5
@ -26,7 +26,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
|||||||
|
|
||||||
// 将模块名转换成 PascalCase 的格式,并添加特定后缀,防止命名冲突
|
// 将模块名转换成 PascalCase 的格式,并添加特定后缀,防止命名冲突
|
||||||
const componentClassName = ensureValidClassName(
|
const componentClassName = ensureValidClassName(
|
||||||
`${changeCase.pascalCase(ir.moduleName)}$$Page`,
|
`${changeCase.pascalCase(ir.moduleName)}$$${ir.containerType}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
next.chunks.push({
|
next.chunks.push({
|
||||||
@ -43,6 +43,18 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (ir.containerType === 'Component') {
|
||||||
|
next.chunks.push({
|
||||||
|
type: ChunkType.STRING,
|
||||||
|
fileType: FileType.JSX,
|
||||||
|
name: CLASS_DEFINE_CHUNK_NAME.InsVar,
|
||||||
|
content: `static displayName = '${changeCase.pascalCase(ir.moduleName)}';`,
|
||||||
|
linkAfter: [
|
||||||
|
CLASS_DEFINE_CHUNK_NAME.Start,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
next.chunks.push({
|
next.chunks.push({
|
||||||
type: ChunkType.STRING,
|
type: ChunkType.STRING,
|
||||||
fileType: FileType.JSX,
|
fileType: FileType.JSX,
|
||||||
|
|||||||
@ -35,4 +35,4 @@ export interface IDependency {
|
|||||||
main?: string; // 包导出组件入口文件路径 /lib/input
|
main?: string; // 包导出组件入口文件路径 /lib/input
|
||||||
dependencyType?: DependencyType; // 依赖类型 内/外
|
dependencyType?: DependencyType; // 依赖类型 内/外
|
||||||
componentName?: string; // 导入后名称
|
componentName?: string; // 导入后名称
|
||||||
}
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
import type { IPublicTypeJSExpression, IPublicTypeJSFunction } from '@alilc/lowcode-types';
|
import type { IPublicTypeJSExpression, IPublicTypeJSFunction } from '@alilc/lowcode-types';
|
||||||
import changeCase from 'change-case';
|
import changeCase from 'change-case';
|
||||||
import short from 'short-uuid';
|
import short from 'short-uuid';
|
||||||
|
import { DependencyType, IDependency, IExternalDependency, IInternalDependency } from '../types';
|
||||||
|
|
||||||
// Doc: https://www.npmjs.com/package/change-case
|
// Doc: https://www.npmjs.com/package/change-case
|
||||||
|
|
||||||
@ -43,4 +44,16 @@ export function getStaticExprValue<T>(expr: string): T {
|
|||||||
|
|
||||||
export function isJSExpressionFn(data: any): data is IPublicTypeJSFunction {
|
export function isJSExpressionFn(data: any): data is IPublicTypeJSFunction {
|
||||||
return data?.type === 'JSExpression' && data?.extType === 'function';
|
return data?.type === 'JSExpression' && data?.extType === 'function';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isInternalDependency(
|
||||||
|
dependency: IDependency,
|
||||||
|
): dependency is IInternalDependency {
|
||||||
|
return dependency.dependencyType === DependencyType.Internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isExternalDependency(
|
||||||
|
dependency: IDependency,
|
||||||
|
): dependency is IExternalDependency {
|
||||||
|
return dependency.dependencyType === DependencyType.External;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user