mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-04 17:27:09 +00:00
feat: 🎸 容器的模块名统一都用 PascalCase, 并为页面添加特定后缀防止与组件名冲突
This commit is contained in:
parent
965ef4a4ed
commit
42f7bdbe42
@ -2,7 +2,7 @@
|
|||||||
* 解析器是对输入的固定格式数据做拆解,使其符合引擎后续步骤预期,完成统一处理逻辑的步骤。
|
* 解析器是对输入的固定格式数据做拆解,使其符合引擎后续步骤预期,完成统一处理逻辑的步骤。
|
||||||
* 本解析器面向的是标准 schema 协议。
|
* 本解析器面向的是标准 schema 协议。
|
||||||
*/
|
*/
|
||||||
|
import changeCase from 'change-case';
|
||||||
import { SUPPORT_SCHEMA_VERSION_LIST } from '../const';
|
import { SUPPORT_SCHEMA_VERSION_LIST } from '../const';
|
||||||
|
|
||||||
import { handleChildren } from '../utils/nodeToJSX';
|
import { handleChildren } from '../utils/nodeToJSX';
|
||||||
@ -90,7 +90,7 @@ class SchemaParser implements ISchemaParser {
|
|||||||
const container: IContainerInfo = {
|
const container: IContainerInfo = {
|
||||||
...subRoot,
|
...subRoot,
|
||||||
containerType: subRoot.componentName,
|
containerType: subRoot.componentName,
|
||||||
moduleName: subRoot.fileName, // TODO: 驼峰化名称
|
moduleName: changeCase.pascalCase(subRoot.fileName),
|
||||||
};
|
};
|
||||||
return container;
|
return container;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import changeCase from 'change-case';
|
||||||
import { COMMON_CHUNK_NAME, CLASS_DEFINE_CHUNK_NAME } from '../../../const/generator';
|
import { COMMON_CHUNK_NAME, CLASS_DEFINE_CHUNK_NAME } from '../../../const/generator';
|
||||||
import { REACT_CHUNK_NAME } from './const';
|
import { REACT_CHUNK_NAME } from './const';
|
||||||
|
|
||||||
@ -18,11 +19,14 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
|||||||
|
|
||||||
const ir = next.ir as IContainerInfo;
|
const ir = next.ir as IContainerInfo;
|
||||||
|
|
||||||
|
// 将模块名转换成 PascalCase 的格式,并添加特定后缀,防止命名冲突
|
||||||
|
const componentClassName = `${changeCase.pascalCase(ir.moduleName)}$$Page`;
|
||||||
|
|
||||||
next.chunks.push({
|
next.chunks.push({
|
||||||
type: ChunkType.STRING,
|
type: ChunkType.STRING,
|
||||||
fileType: FileType.JSX,
|
fileType: FileType.JSX,
|
||||||
name: CLASS_DEFINE_CHUNK_NAME.Start,
|
name: CLASS_DEFINE_CHUNK_NAME.Start,
|
||||||
content: `class ${ir.moduleName} extends React.Component {`,
|
content: `class ${componentClassName} extends React.Component {`,
|
||||||
linkAfter: [
|
linkAfter: [
|
||||||
COMMON_CHUNK_NAME.ExternalDepsImport,
|
COMMON_CHUNK_NAME.ExternalDepsImport,
|
||||||
COMMON_CHUNK_NAME.InternalDepsImport,
|
COMMON_CHUNK_NAME.InternalDepsImport,
|
||||||
@ -86,7 +90,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
|||||||
type: ChunkType.STRING,
|
type: ChunkType.STRING,
|
||||||
fileType: FileType.JSX,
|
fileType: FileType.JSX,
|
||||||
name: COMMON_CHUNK_NAME.FileExport,
|
name: COMMON_CHUNK_NAME.FileExport,
|
||||||
content: `export default ${ir.moduleName};`,
|
content: `export default ${componentClassName};`,
|
||||||
linkAfter: [
|
linkAfter: [
|
||||||
COMMON_CHUNK_NAME.ExternalDepsImport,
|
COMMON_CHUNK_NAME.ExternalDepsImport,
|
||||||
COMMON_CHUNK_NAME.InternalDepsImport,
|
COMMON_CHUNK_NAME.InternalDepsImport,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user