refactor: moduleName of Component should not be converted

This commit is contained in:
LeoYuan 袁力皓 2023-05-04 17:03:37 +08:00 committed by 林熠
parent 9a68f0f27c
commit 5b68b860ac
3 changed files with 10 additions and 3 deletions

View File

@ -32,7 +32,7 @@ import {
import { SUPPORT_SCHEMA_VERSION_LIST } from '../const';
import { getErrorMessage } from '../utils/errors';
import { handleSubNodes, isValidContainerType } from '../utils/schema';
import { handleSubNodes, isValidContainerType, ContainerType } from '../utils/schema';
import { uniqueArray } from '../utils/common';
import { componentAnalyzer } from '../analyzer/componentAnalyzer';
import { ensureValidClassName } from '../utils/validate';
@ -161,7 +161,8 @@ export class SchemaParser implements ISchemaParser {
...subRoot,
componentName: getRootComponentName(subRoot.componentName, compDeps),
containerType: subRoot.componentName,
moduleName: ensureValidClassName(changeCase.pascalCase(subRoot.fileName)),
moduleName: ensureValidClassName(subRoot.componentName === ContainerType.Component ?
subRoot.fileName : changeCase.pascalCase(subRoot.fileName)),
};
return container;
});

View File

@ -48,7 +48,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
type: ChunkType.STRING,
fileType: FileType.JSX,
name: CLASS_DEFINE_CHUNK_NAME.InsVar,
content: `static displayName = '${changeCase.pascalCase(ir.moduleName)}';`,
content: `static displayName = '${ir.moduleName}';`,
linkAfter: [
CLASS_DEFINE_CHUNK_NAME.Start,
],

View File

@ -147,4 +147,10 @@ export function isValidContainerType(schema: IPublicTypeNodeSchema) {
'Component',
'Block',
].includes(schema.componentName);
}
export const enum ContainerType {
Page = 'Page',
Component = 'Component',
Block = 'Block',
}