mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-05 09:47:20 +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 {
|
import {
|
||||||
BuilderComponentPlugin,
|
BuilderComponentPlugin,
|
||||||
@ -24,6 +24,14 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
|||||||
...pre,
|
...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({
|
next.chunks.push({
|
||||||
type: ChunkType.STRING,
|
type: ChunkType.STRING,
|
||||||
fileType: cfg.fileType,
|
fileType: cfg.fileType,
|
||||||
@ -67,6 +75,9 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
|||||||
get props() {
|
get props() {
|
||||||
return self.props;
|
return self.props;
|
||||||
},
|
},
|
||||||
|
get constants() {
|
||||||
|
return __$$constants;
|
||||||
|
},
|
||||||
...this._methods,
|
...this._methods,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { COMMON_CHUNK_NAME } from '../../const/generator';
|
import { COMMON_CHUNK_NAME } from '../../const/generator';
|
||||||
import { generateCompositeType } from '../../utils/compositeType';
|
import { generateUnknownType } from '../../utils/compositeType';
|
||||||
import {
|
import {
|
||||||
BuilderComponentPlugin,
|
BuilderComponentPlugin,
|
||||||
BuilderComponentPluginFactory,
|
BuilderComponentPluginFactory,
|
||||||
@ -16,40 +16,39 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ir = next.ir as IProjectInfo;
|
const ir = next.ir as IProjectInfo;
|
||||||
if (ir.constants) {
|
|
||||||
const [, constantStr] = generateCompositeType(ir.constants);
|
|
||||||
|
|
||||||
next.chunks.push({
|
const constantStr = generateUnknownType(ir.constants || {});
|
||||||
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,
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
next.chunks.push({
|
next.chunks.push({
|
||||||
type: ChunkType.STRING,
|
type: ChunkType.STRING,
|
||||||
fileType: FileType.JS,
|
fileType: FileType.JS,
|
||||||
name: COMMON_CHUNK_NAME.FileExport,
|
name: COMMON_CHUNK_NAME.FileVarDefine,
|
||||||
content: `
|
content: `
|
||||||
export default constantConfig;
|
const __$$constants = (${constantStr});
|
||||||
`,
|
`,
|
||||||
linkAfter: [
|
linkAfter: [
|
||||||
COMMON_CHUNK_NAME.ExternalDepsImport,
|
COMMON_CHUNK_NAME.ExternalDepsImport,
|
||||||
COMMON_CHUNK_NAME.InternalDepsImport,
|
COMMON_CHUNK_NAME.InternalDepsImport,
|
||||||
COMMON_CHUNK_NAME.ImportAliasDefine,
|
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.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;
|
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 { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||||
|
|
||||||
|
import __$$constants from '../../constants';
|
||||||
|
|
||||||
import __$$projectUtils from '../../utils';
|
import __$$projectUtils from '../../utils';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
@ -69,6 +71,9 @@ class Home$$Page extends Component {
|
|||||||
get props() {
|
get props() {
|
||||||
return self.props;
|
return self.props;
|
||||||
},
|
},
|
||||||
|
get constants() {
|
||||||
|
return __$$constants;
|
||||||
|
},
|
||||||
...this._methods,
|
...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 { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||||
|
|
||||||
|
import __$$constants from '../../constants';
|
||||||
|
|
||||||
import __$$projectUtils from '../../utils';
|
import __$$projectUtils from '../../utils';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
@ -162,6 +164,9 @@ class Home$$Page extends Component {
|
|||||||
get props() {
|
get props() {
|
||||||
return self.props;
|
return self.props;
|
||||||
},
|
},
|
||||||
|
get constants() {
|
||||||
|
return __$$constants;
|
||||||
|
},
|
||||||
...this._methods,
|
...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 { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||||
|
|
||||||
|
import __$$constants from '../../constants';
|
||||||
|
|
||||||
import __$$projectUtils from '../../utils';
|
import __$$projectUtils from '../../utils';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
@ -80,6 +82,9 @@ class Detail$$Page extends Component {
|
|||||||
get props() {
|
get props() {
|
||||||
return self.props;
|
return self.props;
|
||||||
},
|
},
|
||||||
|
get constants() {
|
||||||
|
return __$$constants;
|
||||||
|
},
|
||||||
...this._methods,
|
...this._methods,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,8 @@ import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-en
|
|||||||
|
|
||||||
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||||
|
|
||||||
|
import __$$constants from '../../constants';
|
||||||
|
|
||||||
import __$$projectUtils from '../../utils';
|
import __$$projectUtils from '../../utils';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
@ -80,6 +82,9 @@ class Home$$Page extends Component {
|
|||||||
get props() {
|
get props() {
|
||||||
return self.props;
|
return self.props;
|
||||||
},
|
},
|
||||||
|
get constants() {
|
||||||
|
return __$$constants;
|
||||||
|
},
|
||||||
...this._methods,
|
...this._methods,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,8 @@ import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-en
|
|||||||
|
|
||||||
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||||
|
|
||||||
|
import __$$constants from '../../constants';
|
||||||
|
|
||||||
import __$$projectUtils from '../../utils';
|
import __$$projectUtils from '../../utils';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
@ -83,6 +85,9 @@ class List$$Page extends Component {
|
|||||||
get props() {
|
get props() {
|
||||||
return self.props;
|
return self.props;
|
||||||
},
|
},
|
||||||
|
get constants() {
|
||||||
|
return __$$constants;
|
||||||
|
},
|
||||||
...this._methods,
|
...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 { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||||
|
|
||||||
|
import __$$constants from '../../constants';
|
||||||
|
|
||||||
import __$$projectUtils from '../../utils';
|
import __$$projectUtils from '../../utils';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
@ -77,6 +79,9 @@ class Home$$Page extends Component {
|
|||||||
get props() {
|
get props() {
|
||||||
return self.props;
|
return self.props;
|
||||||
},
|
},
|
||||||
|
get constants() {
|
||||||
|
return __$$constants;
|
||||||
|
},
|
||||||
...this._methods,
|
...this._methods,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user