feat: 🎸 补充对数据源的一些处理

This commit is contained in:
牧毅 2020-08-12 14:32:17 +08:00
parent c3fdfe5af2
commit 4572b53f47
5 changed files with 19 additions and 13 deletions

View File

@ -16,6 +16,7 @@
},
"dependencies": {
"@ali/am-eslint-config": "*",
"@ali/lowcode-types": "^0.8.14",
"@ali/my-prettier": "^1.0.0",
"@babel/generator": "^7.9.5",
"@babel/parser": "^7.9.4",
@ -32,7 +33,7 @@
"ava": "^1.0.1",
"rimraf": "^3.0.2",
"ts-loader": "^6.2.2",
"ts-node": "^7.0.1",
"ts-node": "^8.10.2",
"tsconfig-paths": "^3.9.0"
},
"ava": {

View File

@ -34,7 +34,6 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
linkAfter: [CLASS_DEFINE_CHUNK_NAME.Start],
});
// TODO: 补充数据源的定义
next.chunks.push({
type: ChunkType.STRING,
fileType: cfg.fileType,

View File

@ -1,3 +1,5 @@
import { DataSourceConfig } from '@ali/lowcode-types';
import { CLASS_DEFINE_CHUNK_NAME, COMMON_CHUNK_NAME } from '../../../const/generator';
import {
@ -7,11 +9,12 @@ import {
FileType,
ICodeStruct,
} from '../../../types';
import { isContainerSchema } from '../../../utils/schema';
import { RAX_CHUNK_NAME } from './const';
type PluginConfig = {
fileType: string;
}
};
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
const cfg: PluginConfig = {
@ -51,23 +54,22 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
content: `
this._dataSourceEngine.reloadDataSource();
`,
linkAfter: [
RAX_CHUNK_NAME.ClassDidMountStart,
],
linkAfter: [RAX_CHUNK_NAME.ClassDidMountStart],
});
// TODO: 补充数据源的定义
const dataSource = isContainerSchema(pre.ir) ? pre.ir.dataSource : null;
const dataSourceItems: DataSourceConfig[] = dataSource && dataSource.list || [];
next.chunks.push({
type: ChunkType.STRING,
fileType: cfg.fileType,
name: CLASS_DEFINE_CHUNK_NAME.InsPrivateMethod,
// TODO: 下面的定义应该需要调用 @ali/lowcode-datasource-engine 的方法来搞:
content: `
_defineDataSourceList() {
return [];
return ${JSON.stringify(dataSourceItems)};
}`,
linkAfter: [
RAX_CHUNK_NAME.ClassRenderEnd
],
linkAfter: [RAX_CHUNK_NAME.ClassRenderEnd],
});
return next;

View File

@ -19,7 +19,8 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
const ir = next.ir as IProjectInfo;
const packageJson: IPackageJSON = {
name: '@ali/rax-component-demo',
name: '@ali/rax-app-demo',
private: true,
version: '1.0.0',
scripts: {
build:
@ -29,6 +30,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
lint: 'eslint --ext .js --ext .jsx ./',
},
dependencies: {
'@ali/lowcode-datasource-engine': '^0.1.0',
rax: '^1.1.0',
'rax-app': '^2.0.0',
'rax-document': '^0.1.0',

View File

@ -1,5 +1,6 @@
{
"name": "@ali/rax-component-demo",
"name": "@ali/rax-app-demo",
"private": true,
"version": "1.0.0",
"scripts": {
"build": "rm -f ./dist/miniapp.tar.gz && npm run build:miniapp && cd build/miniapp && tar czf ../../dist/miniapp.tar.gz *",
@ -8,6 +9,7 @@
"lint": "eslint --ext .js --ext .jsx ./"
},
"dependencies": {
"@ali/lowcode-datasource-engine": "^0.1.0",
"rax": "^1.1.0",
"rax-app": "^2.0.0",
"rax-document": "^0.1.0",