mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-01 05:30:40 +00:00
feat: 🎸 Rax 出码支持 constants 常量定义
This commit is contained in:
parent
35fcdd955b
commit
fcf6c32e76
@ -1,4 +1,4 @@
|
||||
import { CLASS_DEFINE_CHUNK_NAME } from '../../../const/generator';
|
||||
import { CLASS_DEFINE_CHUNK_NAME, COMMON_CHUNK_NAME } from '../../../const/generator';
|
||||
|
||||
import {
|
||||
BuilderComponentPlugin,
|
||||
@ -24,6 +24,14 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
||||
...pre,
|
||||
};
|
||||
|
||||
next.chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
fileType: cfg.fileType,
|
||||
name: COMMON_CHUNK_NAME.InternalDepsImport,
|
||||
content: `import __$$constants from '../../constants';`,
|
||||
linkAfter: [COMMON_CHUNK_NAME.ExternalDepsImport],
|
||||
});
|
||||
|
||||
next.chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
fileType: cfg.fileType,
|
||||
@ -67,6 +75,9 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
||||
get props() {
|
||||
return self.props;
|
||||
},
|
||||
get constants() {
|
||||
return __$$constants;
|
||||
},
|
||||
...this._methods,
|
||||
};
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { COMMON_CHUNK_NAME } from '../../const/generator';
|
||||
import { generateCompositeType } from '../../utils/compositeType';
|
||||
import { generateUnknownType } from '../../utils/compositeType';
|
||||
import {
|
||||
BuilderComponentPlugin,
|
||||
BuilderComponentPluginFactory,
|
||||
@ -16,40 +16,39 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
};
|
||||
|
||||
const ir = next.ir as IProjectInfo;
|
||||
if (ir.constants) {
|
||||
const [, constantStr] = generateCompositeType(ir.constants);
|
||||
|
||||
next.chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
fileType: FileType.JS,
|
||||
name: COMMON_CHUNK_NAME.FileVarDefine,
|
||||
content: `
|
||||
const constantConfig = ${constantStr};
|
||||
`,
|
||||
linkAfter: [
|
||||
COMMON_CHUNK_NAME.ExternalDepsImport,
|
||||
COMMON_CHUNK_NAME.InternalDepsImport,
|
||||
COMMON_CHUNK_NAME.ImportAliasDefine,
|
||||
],
|
||||
});
|
||||
const constantStr = generateUnknownType(ir.constants || {});
|
||||
|
||||
next.chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
fileType: FileType.JS,
|
||||
name: COMMON_CHUNK_NAME.FileExport,
|
||||
content: `
|
||||
export default constantConfig;
|
||||
`,
|
||||
linkAfter: [
|
||||
COMMON_CHUNK_NAME.ExternalDepsImport,
|
||||
COMMON_CHUNK_NAME.InternalDepsImport,
|
||||
COMMON_CHUNK_NAME.ImportAliasDefine,
|
||||
COMMON_CHUNK_NAME.FileVarDefine,
|
||||
COMMON_CHUNK_NAME.FileUtilDefine,
|
||||
COMMON_CHUNK_NAME.FileMainContent,
|
||||
],
|
||||
});
|
||||
}
|
||||
next.chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
fileType: FileType.JS,
|
||||
name: COMMON_CHUNK_NAME.FileVarDefine,
|
||||
content: `
|
||||
const __$$constants = (${constantStr});
|
||||
`,
|
||||
linkAfter: [
|
||||
COMMON_CHUNK_NAME.ExternalDepsImport,
|
||||
COMMON_CHUNK_NAME.InternalDepsImport,
|
||||
COMMON_CHUNK_NAME.ImportAliasDefine,
|
||||
],
|
||||
});
|
||||
|
||||
next.chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
fileType: FileType.JS,
|
||||
name: COMMON_CHUNK_NAME.FileExport,
|
||||
content: `
|
||||
export default __$$constants;
|
||||
`,
|
||||
linkAfter: [
|
||||
COMMON_CHUNK_NAME.ExternalDepsImport,
|
||||
COMMON_CHUNK_NAME.InternalDepsImport,
|
||||
COMMON_CHUNK_NAME.ImportAliasDefine,
|
||||
COMMON_CHUNK_NAME.FileVarDefine,
|
||||
COMMON_CHUNK_NAME.FileUtilDefine,
|
||||
COMMON_CHUNK_NAME.FileMainContent,
|
||||
],
|
||||
});
|
||||
|
||||
return next;
|
||||
};
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
const __$$constants = {};
|
||||
|
||||
export default __$$constants;
|
||||
@ -11,6 +11,8 @@ import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-en
|
||||
|
||||
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||
|
||||
import __$$constants from '../../constants';
|
||||
|
||||
import __$$projectUtils from '../../utils';
|
||||
|
||||
import './index.css';
|
||||
@ -69,6 +71,9 @@ class Home$$Page extends Component {
|
||||
get props() {
|
||||
return self.props;
|
||||
},
|
||||
get constants() {
|
||||
return __$$constants;
|
||||
},
|
||||
...this._methods,
|
||||
};
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
const __$$constants = {};
|
||||
|
||||
export default __$$constants;
|
||||
@ -13,6 +13,8 @@ import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-en
|
||||
|
||||
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||
|
||||
import __$$constants from '../../constants';
|
||||
|
||||
import __$$projectUtils from '../../utils';
|
||||
|
||||
import './index.css';
|
||||
@ -162,6 +164,9 @@ class Home$$Page extends Component {
|
||||
get props() {
|
||||
return self.props;
|
||||
},
|
||||
get constants() {
|
||||
return __$$constants;
|
||||
},
|
||||
...this._methods,
|
||||
};
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
const __$$constants = {};
|
||||
|
||||
export default __$$constants;
|
||||
@ -15,6 +15,8 @@ import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-en
|
||||
|
||||
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||
|
||||
import __$$constants from '../../constants';
|
||||
|
||||
import __$$projectUtils from '../../utils';
|
||||
|
||||
import './index.css';
|
||||
@ -80,6 +82,9 @@ class Detail$$Page extends Component {
|
||||
get props() {
|
||||
return self.props;
|
||||
},
|
||||
get constants() {
|
||||
return __$$constants;
|
||||
},
|
||||
...this._methods,
|
||||
};
|
||||
|
||||
|
||||
@ -15,6 +15,8 @@ import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-en
|
||||
|
||||
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||
|
||||
import __$$constants from '../../constants';
|
||||
|
||||
import __$$projectUtils from '../../utils';
|
||||
|
||||
import './index.css';
|
||||
@ -80,6 +82,9 @@ class Home$$Page extends Component {
|
||||
get props() {
|
||||
return self.props;
|
||||
},
|
||||
get constants() {
|
||||
return __$$constants;
|
||||
},
|
||||
...this._methods,
|
||||
};
|
||||
|
||||
|
||||
@ -15,6 +15,8 @@ import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-en
|
||||
|
||||
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||
|
||||
import __$$constants from '../../constants';
|
||||
|
||||
import __$$projectUtils from '../../utils';
|
||||
|
||||
import './index.css';
|
||||
@ -83,6 +85,9 @@ class List$$Page extends Component {
|
||||
get props() {
|
||||
return self.props;
|
||||
},
|
||||
get constants() {
|
||||
return __$$constants;
|
||||
},
|
||||
...this._methods,
|
||||
};
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
const __$$constants = {};
|
||||
|
||||
export default __$$constants;
|
||||
@ -15,6 +15,8 @@ import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-en
|
||||
|
||||
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||
|
||||
import __$$constants from '../../constants';
|
||||
|
||||
import __$$projectUtils from '../../utils';
|
||||
|
||||
import './index.css';
|
||||
@ -77,6 +79,9 @@ class Home$$Page extends Component {
|
||||
get props() {
|
||||
return self.props;
|
||||
},
|
||||
get constants() {
|
||||
return __$$constants;
|
||||
},
|
||||
...this._methods,
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user