mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-21 08:28:16 +00:00
fix: demo data
This commit is contained in:
parent
237b86656b
commit
b4a27fc055
@ -1,8 +1,9 @@
|
|||||||
import { IResultDir, IResultFile } from '../types';
|
import { IResultDir, IResultFile } from '../types';
|
||||||
|
|
||||||
import CodeGenerator from '../index';
|
import codeGenerator from '../index';
|
||||||
import { createDiskPublisher } from '../publisher/disk';
|
import { createDiskPublisher } from '../publisher/disk';
|
||||||
import demoSchema from './simpleDemo';
|
// import demoSchema from './simpleDemo';
|
||||||
|
import demoSchema from './recoreDemo';
|
||||||
|
|
||||||
function flatFiles(rootName: string | null, dir: IResultDir): IResultFile[] {
|
function flatFiles(rootName: string | null, dir: IResultDir): IResultFile[] {
|
||||||
const dirRoot: string = rootName ? `${rootName}/${dir.name}` : dir.name;
|
const dirRoot: string = rootName ? `${rootName}/${dir.name}` : dir.name;
|
||||||
@ -40,13 +41,18 @@ async function writeResultToDisk(root: IResultDir, path: string): Promise<any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
const createIceJsProjectBuilder = CodeGenerator.solutions.icejs;
|
// const createIceJsProjectBuilder = codeGenerator.solutions.icejs;
|
||||||
const builder = createIceJsProjectBuilder();
|
// const builder = createIceJsProjectBuilder();
|
||||||
|
|
||||||
|
const createRecoreProjectBuilder = codeGenerator.solutions.recore;
|
||||||
|
const builder = createRecoreProjectBuilder();
|
||||||
|
|
||||||
builder.generateProject(demoSchema).then(result => {
|
builder.generateProject(demoSchema).then(result => {
|
||||||
// displayResultInConsole(result, '././src/routes.js');
|
displayResultInConsole(result);
|
||||||
writeResultToDisk(result, '/Users/armslave/lowcodeDemo').then(response =>
|
// writeResultToDisk(result, '/Users/armslave/lowcodeDemo').then(response =>
|
||||||
console.log('Write to disk: ', JSON.stringify(response)),
|
// console.log('Write to disk: ', JSON.stringify(response)),
|
||||||
);
|
// );
|
||||||
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
815
packages/code-generator/src/demo/recoreDemo.ts
Normal file
815
packages/code-generator/src/demo/recoreDemo.ts
Normal file
@ -0,0 +1,815 @@
|
|||||||
|
import { IProjectSchema } from '../types';
|
||||||
|
|
||||||
|
const demoData: IProjectSchema = {
|
||||||
|
version: '1.0.0',
|
||||||
|
componentsMap: [
|
||||||
|
{
|
||||||
|
componentName: 'Button',
|
||||||
|
'package': 'alife/next',
|
||||||
|
version: '1.0.0',
|
||||||
|
destructuring: true,
|
||||||
|
exportName: 'Select',
|
||||||
|
subName: 'Button',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
componentsTree: [
|
||||||
|
{
|
||||||
|
condition: true,
|
||||||
|
css: 'body{background-color:#f2f3f5}',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
condition: true,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
condition: true,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
condition: true,
|
||||||
|
componentName: 'TextField',
|
||||||
|
id: 'node_k1nd576k',
|
||||||
|
props: {
|
||||||
|
fieldName: 'name',
|
||||||
|
hasClear: false,
|
||||||
|
autoFocus: false,
|
||||||
|
tips: {
|
||||||
|
en_US: '',
|
||||||
|
zh_CN: '',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'this.utils.getLocale() === \'en_US\' ? \'\' : \'\'',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
trim: false,
|
||||||
|
labelTextAlign: 'right',
|
||||||
|
placeholder: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
en_US: 'please input',
|
||||||
|
zh_CN: '请输入',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"请输入"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
state: '',
|
||||||
|
behavior: 'NORMAL',
|
||||||
|
value: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
zh_CN: '',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '""',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
addonBefore: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
zh_CN: '',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '""',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
validation: [
|
||||||
|
{
|
||||||
|
type: 'required',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hasLimitHint: false,
|
||||||
|
cutString: false,
|
||||||
|
__style__: {},
|
||||||
|
fieldId: 'textField_k1nd576w',
|
||||||
|
htmlType: 'input',
|
||||||
|
autoHeight: false,
|
||||||
|
labelColOffset: 0,
|
||||||
|
label: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
en_US: 'TextField',
|
||||||
|
zh_CN: '活动名称',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"活动名称"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
__category__: 'form',
|
||||||
|
labelColSpan: 4,
|
||||||
|
wrapperColSpan: 0,
|
||||||
|
rows: 4,
|
||||||
|
addonAfter: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
zh_CN: '',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '""',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
wrapperColOffset: 0,
|
||||||
|
size: 'medium',
|
||||||
|
labelAlign: 'top',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
condition: true,
|
||||||
|
componentName: 'SelectField',
|
||||||
|
id: 'node_k1nd576l',
|
||||||
|
props: {
|
||||||
|
fieldName: 'type',
|
||||||
|
hasClear: false,
|
||||||
|
tips: {
|
||||||
|
en_US: '',
|
||||||
|
zh_CN: '',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'this.utils.getLocale() === \'en_US\' ? \'\' : \'\'',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
mode: 'single',
|
||||||
|
showSearch: false,
|
||||||
|
autoWidth: true,
|
||||||
|
labelTextAlign: 'right',
|
||||||
|
placeholder: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
en_US: 'please select',
|
||||||
|
zh_CN: '请选择',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"请选择"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
hasBorder: true,
|
||||||
|
behavior: 'NORMAL',
|
||||||
|
value: '',
|
||||||
|
validation: [
|
||||||
|
{
|
||||||
|
type: 'required',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
__style__: {},
|
||||||
|
fieldId: 'select_k1nd576x',
|
||||||
|
notFoundContent: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'null',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
labelColOffset: 0,
|
||||||
|
label: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
en_US: 'SelectField',
|
||||||
|
zh_CN: '活动类型',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"活动类型"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
__category__: 'form',
|
||||||
|
labelColSpan: 4,
|
||||||
|
wrapperColSpan: 0,
|
||||||
|
wrapperColOffset: 0,
|
||||||
|
hasSelectAll: false,
|
||||||
|
hasArrow: true,
|
||||||
|
size: 'medium',
|
||||||
|
labelAlign: 'top',
|
||||||
|
filterLocal: true,
|
||||||
|
dataSource: [
|
||||||
|
{
|
||||||
|
defaultChecked: false,
|
||||||
|
text: {
|
||||||
|
en_US: 'Option 1',
|
||||||
|
zh_CN: '虚拟',
|
||||||
|
type: 'JSExpression',
|
||||||
|
__sid__: 'param_k1nd5lrz',
|
||||||
|
value: 'this.utils.getLocale() === \'en_US\' ? \'Option 1\' : \'虚拟\'',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
__sid__: 'serial_k1nd576v',
|
||||||
|
value: '虚拟',
|
||||||
|
sid: 'opt_k1ofrjfz',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
defaultChecked: false,
|
||||||
|
text: {
|
||||||
|
en_US: 'Option 2',
|
||||||
|
zh_CN: '营销',
|
||||||
|
type: 'JSExpression',
|
||||||
|
__sid__: 'param_k1nd5ls3',
|
||||||
|
value: 'this.utils.getLocale() === \'en_US\' ? \'Option 2\' : \'营销\'',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
__sid__: 'serial_k1nd576w',
|
||||||
|
value: '营销',
|
||||||
|
sid: 'opt_k1ofrjg0',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
defaultChecked: false,
|
||||||
|
text: {
|
||||||
|
en_US: 'Option 3',
|
||||||
|
zh_CN: '线下',
|
||||||
|
type: 'JSExpression',
|
||||||
|
__sid__: 'param_k1nd5ls7',
|
||||||
|
value: 'this.utils.getLocale() === \'en_US\' ? \'Option 3\' : \'线下\'',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
__sid__: 'serial_k1nd576x',
|
||||||
|
value: '线下',
|
||||||
|
sid: 'opt_k1ofrjg1',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
componentName: 'Form',
|
||||||
|
id: 'node_k1nd576j',
|
||||||
|
props: {
|
||||||
|
size: 'medium',
|
||||||
|
labelAlign: 'top',
|
||||||
|
autoValidate: true,
|
||||||
|
scrollToFirstError: true,
|
||||||
|
autoUnmount: true,
|
||||||
|
behavior: 'NORMAL',
|
||||||
|
dataSource: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'state.formData',
|
||||||
|
extType: 'variable',
|
||||||
|
},
|
||||||
|
__style__: {},
|
||||||
|
fieldId: 'form',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
componentName: 'Dialog',
|
||||||
|
id: 'node_k1nd576i',
|
||||||
|
props: {
|
||||||
|
hasMask: true,
|
||||||
|
closeable: 'esc',
|
||||||
|
visible: false,
|
||||||
|
footer: true,
|
||||||
|
footerActions: 'ok,cancel',
|
||||||
|
footerAlign: 'right',
|
||||||
|
title: {
|
||||||
|
rawValue: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
zh_CN: '新增活动',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"新增活动"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '(state.formData ? \'编辑\' : \'新增\') + \'活动\'',
|
||||||
|
extType: 'variable',
|
||||||
|
},
|
||||||
|
fieldId: 'dialog',
|
||||||
|
onOk: {
|
||||||
|
rawType: 'events',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'this.utils.legaoBuiltin.execEventFlow.bind(this, [this.submit])',
|
||||||
|
events: [
|
||||||
|
{
|
||||||
|
name: 'submit',
|
||||||
|
id: 'submit',
|
||||||
|
params: {},
|
||||||
|
type: 'actionRef',
|
||||||
|
uuid: '1570937968144_0',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
condition: true,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
condition: true,
|
||||||
|
children: [],
|
||||||
|
componentName: 'PageHeader',
|
||||||
|
id: 'node_k1nd576c',
|
||||||
|
props: {
|
||||||
|
__slot__title: true,
|
||||||
|
extraContent: '',
|
||||||
|
__slot__extraContent: false,
|
||||||
|
__slot__action: false,
|
||||||
|
title: {
|
||||||
|
type: 'JSBlock',
|
||||||
|
value: {
|
||||||
|
condition: true,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
condition: true,
|
||||||
|
componentName: 'Text',
|
||||||
|
id: 'node_k1nd576e',
|
||||||
|
props: {
|
||||||
|
showTitle: false,
|
||||||
|
behavior: 'NORMAL',
|
||||||
|
content: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
en_US: 'Title',
|
||||||
|
zh_CN: '基础表格',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"基础表格"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
__style__: {},
|
||||||
|
fieldId: 'text_k1nd576t',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
componentName: 'Slot',
|
||||||
|
id: 'node_k1nd576d',
|
||||||
|
props: {
|
||||||
|
slotName: 'title',
|
||||||
|
slotTitle: '标题区域',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
content: '',
|
||||||
|
__slot__logo: false,
|
||||||
|
__slot__crumb: false,
|
||||||
|
crumb: '',
|
||||||
|
tab: '',
|
||||||
|
logo: '',
|
||||||
|
action: '',
|
||||||
|
__slot__tab: false,
|
||||||
|
__style__: {},
|
||||||
|
__slot__content: false,
|
||||||
|
fieldId: 'pageHeader_k1nd576s',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
componentName: 'RootHeader',
|
||||||
|
id: 'node_k1hjb043',
|
||||||
|
props: {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
condition: true,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
condition: true,
|
||||||
|
componentName: 'TablePc',
|
||||||
|
id: 'node_k1hjb046',
|
||||||
|
props: {
|
||||||
|
actionWidth: 0,
|
||||||
|
isTree: false,
|
||||||
|
showJump: true,
|
||||||
|
data: {
|
||||||
|
rawValue: {
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
contractDate: {
|
||||||
|
start: 1534942658570,
|
||||||
|
end: 1534944858570,
|
||||||
|
},
|
||||||
|
entryDate: 1534942658570,
|
||||||
|
name: '小王',
|
||||||
|
id: '1',
|
||||||
|
salary: 35000,
|
||||||
|
email: 'xw@abc.com',
|
||||||
|
moneyRange: {
|
||||||
|
lower: 108,
|
||||||
|
upper: 944,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
contractDate: {
|
||||||
|
start: 1534942658570,
|
||||||
|
end: 1534944858570,
|
||||||
|
},
|
||||||
|
entryDate: 1534942658570,
|
||||||
|
name: '小李',
|
||||||
|
id: '2',
|
||||||
|
salary: 25000,
|
||||||
|
email: 'xl@abc.com',
|
||||||
|
moneyRange: {
|
||||||
|
lower: 214,
|
||||||
|
upper: 1077,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
currentPage: 1,
|
||||||
|
totalCount: 2,
|
||||||
|
},
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'state.table_list_basic',
|
||||||
|
extType: 'variable',
|
||||||
|
},
|
||||||
|
actionTitle: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
en_US: 'Action',
|
||||||
|
zh_CN: '操作',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"操作"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
indent: 16,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
dataKey: 'name',
|
||||||
|
hidden: false,
|
||||||
|
dataType: 'text',
|
||||||
|
width: '300px',
|
||||||
|
lock: 'none',
|
||||||
|
sortable: false,
|
||||||
|
align: 'left',
|
||||||
|
title: {
|
||||||
|
en_US: 'Name',
|
||||||
|
use: 'zh_CN',
|
||||||
|
zh_CN: '活动名称',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"活动名称"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
timeFormatter: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataKey: 'type',
|
||||||
|
hidden: false,
|
||||||
|
dataType: 'text',
|
||||||
|
width: '150px',
|
||||||
|
lock: 'none',
|
||||||
|
sortable: false,
|
||||||
|
align: 'left',
|
||||||
|
title: {
|
||||||
|
en_US: 'Date',
|
||||||
|
use: 'zh_CN',
|
||||||
|
zh_CN: '活动类型',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"活动类型"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
timeFormatter: 'YYYY-MM-DD',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataKey: 'created_at',
|
||||||
|
hidden: false,
|
||||||
|
dataType: 'timestamp',
|
||||||
|
width: 200,
|
||||||
|
lock: 'none',
|
||||||
|
sortable: false,
|
||||||
|
align: 'left',
|
||||||
|
title: {
|
||||||
|
en_US: 'contractDate',
|
||||||
|
use: 'zh_CN',
|
||||||
|
zh_CN: '创建时间',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"创建时间"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
timeFormatter: 'YYYY-MM-DD',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
rowSelector: 'checkboxSelector',
|
||||||
|
pageSizeSelector: false,
|
||||||
|
pageSize: 10,
|
||||||
|
setLoadingComponent: false,
|
||||||
|
showRowSelector: false,
|
||||||
|
showLinkBar: true,
|
||||||
|
searchBarPlaceholder: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
en_US: 'Please Input',
|
||||||
|
zh_CN: '请搜索',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"请搜索"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
type: 'normal',
|
||||||
|
pageSizePosition: 'end',
|
||||||
|
pageSizeList: '5,10,20',
|
||||||
|
fixedHeader: false,
|
||||||
|
showActionBar: true,
|
||||||
|
showSearch: true,
|
||||||
|
stickyHeader: false,
|
||||||
|
theme: 'split',
|
||||||
|
setEmptyContent: false,
|
||||||
|
actionFixed: 'none',
|
||||||
|
fieldId: 'tablePc_k1hjb4dl',
|
||||||
|
isPagination: true,
|
||||||
|
actionColumn: [
|
||||||
|
{
|
||||||
|
pageMode: '',
|
||||||
|
callback: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'edit.bind(this)',
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
en_US: 'Detail',
|
||||||
|
use: 'zh_CN',
|
||||||
|
zh_CN: '编辑',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"编辑"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
option: 'callback',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pageMode: '',
|
||||||
|
callback: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'del.bind(this)',
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
use: 'zh_CN',
|
||||||
|
en_US: 'action',
|
||||||
|
zh_CN: '删除',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"删除"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
option: 'callback',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hasHeader: true,
|
||||||
|
hideOnlyOnePage: false,
|
||||||
|
shape: 'arrow-only',
|
||||||
|
paginationPosition: 'right',
|
||||||
|
actionBar: [
|
||||||
|
{
|
||||||
|
callback: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'add.bind(this)',
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
en_US: 'Action 1',
|
||||||
|
use: 'zh_CN',
|
||||||
|
zh_CN: '新增',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"新增"',
|
||||||
|
extType: 'i18n',
|
||||||
|
},
|
||||||
|
option: 'callback',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
actionType: 'link',
|
||||||
|
__router: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'this.utils.router',
|
||||||
|
},
|
||||||
|
linkBar: [],
|
||||||
|
size: 'medium',
|
||||||
|
onLoadData: {
|
||||||
|
rawType: 'events',
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'this.utils.legaoBuiltin.execEventFlow.bind(this, [this.onLoadData])',
|
||||||
|
events: [
|
||||||
|
{
|
||||||
|
name: 'onLoadData',
|
||||||
|
id: 'onLoadData',
|
||||||
|
params: {},
|
||||||
|
type: 'actionRef',
|
||||||
|
uuid: '1570938442689_4',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
actionHidden: false,
|
||||||
|
dataSourceType: 'data',
|
||||||
|
primaryKey: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
componentName: 'RootContent',
|
||||||
|
id: 'node_k1hjb044',
|
||||||
|
props: {
|
||||||
|
contentBgColor: 'white',
|
||||||
|
contentPadding: '20',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
condition: true,
|
||||||
|
children: [],
|
||||||
|
componentName: 'RootFooter',
|
||||||
|
id: 'node_k1hjb045',
|
||||||
|
props: {},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
methods: {
|
||||||
|
__initMethods__: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'function (exports, module) { \'use strict\';\n\nexports.__esModule = true;\nexports.hellGlobal = hellGlobal;\n/**\n* 全局函数,可以被应用内所有页面调用\n*/\nfunction hellGlobal() {\n console.log(\'hello, global\');\n}\'use strict\';\n\nexports.__esModule = true;\nexports.add = add;\nexports.submit = submit;\nexports.onLoadData = onLoadData;\nexports.edit = edit;\nexports.del = del;\n// 点击新增\nfunction add() {\n this.state.formData = null;\n this.$(\'dialog\').show();\n}\n\n/**\n* 点击弹框的“确认”\n*/\nfunction submit() {\n const _this = this;\n\n this.$(\'form\').submit(function (data, error) {\n if (data) {\n _this.dataSourceMap[\'table_submit\'].load(data).then(function (res) {\n _this.utils.toast({\n type: \'success\',\n title: \'提交成功\'\n });\n _this.$(\'dialog\').hide();\n _this.dataSourceMap[\'table_list_basic\'].load();\n });\n }\n });\n}\n\n/**\n* tablePc onLoadData\n* @param currentPage 当前页码\n* @param pageSize 每页显示条数\n* @param searchKey 搜索关键字\n* @param orderColumn 排序列\n* @param orderType 排序方式(desc,asc)\n* @param from 触发来源(order,search,pagination)\n*/\nfunction onLoadData(currentPage, pageSize, searchKey, orderColumn, orderType, from) {\n const tableParams = {\n currentPage: from === \'search\' ? 1 : currentPage,\n pageSize: pageSize,\n searchKey: searchKey,\n orderColumn: orderColumn,\n orderType: orderType\n };\n this.setState({ tableParams: tableParams });\n}\n\n// 点击编辑\nfunction edit(rowData) {\n this.state.formData = rowData;\n this.$(\'dialog\').show();\n}\n\n// 点击删除\nfunction del(rowData) {\n const _this2 = this;\n\n this.utils.dialog({\n method: \'confirm\',\n title: \'提示\',\n content: \'确认删除该条目吗?\',\n onOk: function onOk() {\n _this2.dataSourceMap[\'table_delete\'].load({ id: rowData.id }).then(function () {\n _this2.utils.toast({\n type: \'success\',\n title: \'删除成功\'\n });\n _this2.dataSourceMap[\'table_list_basic\'].load();\n });\n }\n });\n} }',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
componentName: 'Page',
|
||||||
|
fileName: 'page_index',
|
||||||
|
meta: {
|
||||||
|
title: '首页',
|
||||||
|
router: '/',
|
||||||
|
spmb: 'abef21',
|
||||||
|
},
|
||||||
|
id: 'node_k1hjb042',
|
||||||
|
state: {
|
||||||
|
urlParams: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'this.utils.legaoBuiltin.getUrlParams()',
|
||||||
|
},
|
||||||
|
designUrlPrefix: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '"https://pre-go.alibaba-inc.com/fusion_developer/0.1.0/design"',
|
||||||
|
},
|
||||||
|
tableParams: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dataSource: {
|
||||||
|
offline: [],
|
||||||
|
globalConfig: {
|
||||||
|
fit: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: '',
|
||||||
|
extType: 'function',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
online: [],
|
||||||
|
list: [
|
||||||
|
{
|
||||||
|
dataHandler: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'function(data, err) { this.setState({table_list_basic: data}); return data; }',
|
||||||
|
extType: 'function',
|
||||||
|
},
|
||||||
|
requestHandler: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'this.utils.legaoBuiltin.dataSourceHandler',
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
shouldFetch: true,
|
||||||
|
method: 'GET',
|
||||||
|
params: {
|
||||||
|
rawValue: [],
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'state.tableParams',
|
||||||
|
extType: 'variable',
|
||||||
|
},
|
||||||
|
isSync: false,
|
||||||
|
url: 'https://mocks.alibaba-inc.com/mock/legao_template/api/activity/list.json',
|
||||||
|
},
|
||||||
|
id: 'table_list_basic',
|
||||||
|
type: 'legao',
|
||||||
|
isInit: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataHandler: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'function(data, err) { this.setState({table_submit: data}); return data; }',
|
||||||
|
extType: 'function',
|
||||||
|
},
|
||||||
|
requestHandler: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'this.utils.legaoBuiltin.dataSourceHandler',
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
shouldFetch: true,
|
||||||
|
method: 'POST',
|
||||||
|
params: [],
|
||||||
|
isSync: false,
|
||||||
|
url: 'https://mocks.alibaba-inc.com/mock/legao_template/api/activity/update.json',
|
||||||
|
},
|
||||||
|
id: 'table_submit',
|
||||||
|
type: 'legao',
|
||||||
|
isInit: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataHandler: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'function(data, err) { this.setState({table_delete: data}); return data; }',
|
||||||
|
extType: 'function',
|
||||||
|
},
|
||||||
|
requestHandler: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'this.utils.legaoBuiltin.dataSourceHandler',
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
shouldFetch: true,
|
||||||
|
method: 'POST',
|
||||||
|
params: [],
|
||||||
|
isSync: true,
|
||||||
|
url: 'https://mocks.alibaba-inc.com/mock/legao_template/api/activity/delete.json',
|
||||||
|
},
|
||||||
|
id: 'table_delete',
|
||||||
|
type: 'legao',
|
||||||
|
isInit: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
sync: true,
|
||||||
|
},
|
||||||
|
lifeCycles: {
|
||||||
|
'init': {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'function constructor() {\nconst module = { exports: {} };\nconst _this = this;\nthis.__initMethods__(module.exports, module);\nObject.keys(module.exports).forEach(function(item) {\n if(typeof module.exports[item] === \'function\'){\n _this[item] = module.exports[item];\n }\n});\n\n}',
|
||||||
|
extType: 'function',
|
||||||
|
},
|
||||||
|
didMount: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'function main(){\n \'use strict\';\n\nconst __compiledFunc__ = function didMount() {\n // 页面节点加载渲染完毕\n console.log(\'这是个 function didMount\', this);\n};\n return __compiledFunc__.apply(this, arguments);\n}',
|
||||||
|
extType: 'function',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
extensions: {
|
||||||
|
'启用页头': true,
|
||||||
|
},
|
||||||
|
pageStyle: {
|
||||||
|
backgroundColor: '#f2f3f5',
|
||||||
|
},
|
||||||
|
containerStyle: {},
|
||||||
|
className: 'page_k1v3nkx7',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
utils: [
|
||||||
|
{
|
||||||
|
name: 'clone',
|
||||||
|
type: 'npm',
|
||||||
|
content: {
|
||||||
|
'package': 'lodash',
|
||||||
|
version: '0.0.1',
|
||||||
|
exportName: 'clone',
|
||||||
|
subName: '',
|
||||||
|
destructuring: false,
|
||||||
|
main: '/lib/clone',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'beforeRequestHandler',
|
||||||
|
type: 'function',
|
||||||
|
content: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'function(){\n ... \n}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
constants: {
|
||||||
|
ENV: 'prod',
|
||||||
|
DOMAIN: 'xxx.alibaba-inc.com',
|
||||||
|
},
|
||||||
|
css: 'body {font-size: 12px;} .table { width: 100px;}',
|
||||||
|
config: {
|
||||||
|
sdkVersion: '1.0.3',
|
||||||
|
historyMode: 'hash',
|
||||||
|
targetRootID: 'J_Container',
|
||||||
|
layout: {
|
||||||
|
componentName: 'BasicLayout',
|
||||||
|
props: {
|
||||||
|
navConfig: {
|
||||||
|
showLanguageChange: true,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
hidden: false,
|
||||||
|
navUuid: 'FORM-CP5669B1-3AW9DCLHZAY8EIY6WE6X1-GFZM3V1K-6',
|
||||||
|
children: [],
|
||||||
|
icon: '',
|
||||||
|
targetNew: false,
|
||||||
|
title: '测试基础表格',
|
||||||
|
inner: true,
|
||||||
|
relateUuid: 'FORM-CP5669B1-3AW9DCLHZAY8EIY6WE6X1-GFZM3V1K-6',
|
||||||
|
slug: 'qihfg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hidden: false,
|
||||||
|
navUuid: 'FORM-CP5669B1-8AW9XCUT4PCH15SMDWUM3-ZPQP3V1K-1',
|
||||||
|
children: [],
|
||||||
|
icon: '',
|
||||||
|
targetNew: false,
|
||||||
|
title: '测试查询表格',
|
||||||
|
inner: true,
|
||||||
|
relateUuid: 'zqhej',
|
||||||
|
slug: 'zqhej',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
systemLink: '/my_dev_center_code/0.1.0',
|
||||||
|
appName: '乐高转码测试',
|
||||||
|
isFoldHorizontal: 'n',
|
||||||
|
showAppTitle: true,
|
||||||
|
isFold: 'n',
|
||||||
|
searchBarType: 'icon',
|
||||||
|
singletons: {},
|
||||||
|
navTheme: 'default',
|
||||||
|
type: 'top_side_fold',
|
||||||
|
navStyle: 'orange',
|
||||||
|
layout: 'auto',
|
||||||
|
bgColor: 'white',
|
||||||
|
languageChangeUrl: '/common/account/changeAccountLanguage.json',
|
||||||
|
showSearch: 'n',
|
||||||
|
openSubMode: false,
|
||||||
|
showCrumb: true,
|
||||||
|
isFixed: 'y',
|
||||||
|
showIcon: false,
|
||||||
|
showNav: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
theme: {
|
||||||
|
'package': '@alife/theme-fusion',
|
||||||
|
version: '^0.1.0',
|
||||||
|
primary: '#ff9966',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
name: 'demo应用',
|
||||||
|
git_group: 'appGroup',
|
||||||
|
project_name: 'app_demo',
|
||||||
|
description: '这是一个测试应用',
|
||||||
|
spma: 'spa23d',
|
||||||
|
creator: '月飞',
|
||||||
|
gmt_create: '2020-02-11 00:00:00',
|
||||||
|
gmt_modified: '2020-02-11 00:00:00',
|
||||||
|
},
|
||||||
|
i18n: {
|
||||||
|
'zh-CN': {
|
||||||
|
'i18n-jwg27yo4': '你好',
|
||||||
|
'i18n-jwg27yo3': '中国',
|
||||||
|
},
|
||||||
|
'en-US': {
|
||||||
|
'i18n-jwg27yo4': 'Hello',
|
||||||
|
'i18n-jwg27yo3': 'China',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default demoData;
|
||||||
165
packages/code-generator/src/demo/recoreDemo1.ts
Normal file
165
packages/code-generator/src/demo/recoreDemo1.ts
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
import { IProjectSchema } from '../types';
|
||||||
|
|
||||||
|
const demoData: IProjectSchema = {
|
||||||
|
version: '1.0.0',
|
||||||
|
componentsMap: [
|
||||||
|
{
|
||||||
|
componentName: 'Button',
|
||||||
|
'package': 'alife/next',
|
||||||
|
version: '1.0.0',
|
||||||
|
destructuring: true,
|
||||||
|
exportName: 'Select',
|
||||||
|
subName: 'Button',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
componentsTree: [{
|
||||||
|
componentName: 'Page',
|
||||||
|
id: 'node$1',
|
||||||
|
props: {
|
||||||
|
ref: 'outterView',
|
||||||
|
autoLoading: true,
|
||||||
|
style: {
|
||||||
|
padding: 20,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fileName: 'test',
|
||||||
|
dataSource: {
|
||||||
|
list: [],
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
text: 'outter',
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
componentName: 'Button',
|
||||||
|
id: 'node$l',
|
||||||
|
props: {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
componentName: 'Button',
|
||||||
|
id: 'node$n',
|
||||||
|
props: {
|
||||||
|
type: 'secondary',
|
||||||
|
baseIcon: 'set',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
componentName: 'Calendar',
|
||||||
|
id: 'node$p',
|
||||||
|
props: {
|
||||||
|
shape: 'card',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
utils: [
|
||||||
|
{
|
||||||
|
name: 'clone',
|
||||||
|
type: 'npm',
|
||||||
|
content: {
|
||||||
|
'package': 'lodash',
|
||||||
|
version: '0.0.1',
|
||||||
|
exportName: 'clone',
|
||||||
|
subName: '',
|
||||||
|
destructuring: false,
|
||||||
|
main: '/lib/clone',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'beforeRequestHandler',
|
||||||
|
type: 'function',
|
||||||
|
content: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'function(){\n ... \n}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
constants: {
|
||||||
|
ENV: 'prod',
|
||||||
|
DOMAIN: 'xxx.alibaba-inc.com',
|
||||||
|
},
|
||||||
|
css: 'body {font-size: 12px;} .table { width: 100px;}',
|
||||||
|
config: {
|
||||||
|
sdkVersion: '1.0.3',
|
||||||
|
historyMode: 'hash',
|
||||||
|
targetRootID: 'J_Container',
|
||||||
|
layout: {
|
||||||
|
componentName: 'BasicLayout',
|
||||||
|
props: {
|
||||||
|
navConfig: {
|
||||||
|
showLanguageChange: true,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
hidden: false,
|
||||||
|
navUuid: 'FORM-CP5669B1-3AW9DCLHZAY8EIY6WE6X1-GFZM3V1K-6',
|
||||||
|
children: [],
|
||||||
|
icon: '',
|
||||||
|
targetNew: false,
|
||||||
|
title: '测试基础表格',
|
||||||
|
inner: true,
|
||||||
|
relateUuid: 'FORM-CP5669B1-3AW9DCLHZAY8EIY6WE6X1-GFZM3V1K-6',
|
||||||
|
slug: 'qihfg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hidden: false,
|
||||||
|
navUuid: 'FORM-CP5669B1-8AW9XCUT4PCH15SMDWUM3-ZPQP3V1K-1',
|
||||||
|
children: [],
|
||||||
|
icon: '',
|
||||||
|
targetNew: false,
|
||||||
|
title: '测试查询表格',
|
||||||
|
inner: true,
|
||||||
|
relateUuid: 'zqhej',
|
||||||
|
slug: 'zqhej',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
systemLink: '/my_dev_center_code/0.1.0',
|
||||||
|
appName: '乐高转码测试',
|
||||||
|
isFoldHorizontal: 'n',
|
||||||
|
showAppTitle: true,
|
||||||
|
isFold: 'n',
|
||||||
|
searchBarType: 'icon',
|
||||||
|
singletons: {},
|
||||||
|
navTheme: 'default',
|
||||||
|
type: 'top_side_fold',
|
||||||
|
navStyle: 'orange',
|
||||||
|
layout: 'auto',
|
||||||
|
bgColor: 'white',
|
||||||
|
languageChangeUrl: '/common/account/changeAccountLanguage.json',
|
||||||
|
showSearch: 'n',
|
||||||
|
openSubMode: false,
|
||||||
|
showCrumb: true,
|
||||||
|
isFixed: 'y',
|
||||||
|
showIcon: false,
|
||||||
|
showNav: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
theme: {
|
||||||
|
'package': '@alife/theme-fusion',
|
||||||
|
version: '^0.1.0',
|
||||||
|
primary: '#ff9966',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
name: 'demo应用',
|
||||||
|
git_group: 'appGroup',
|
||||||
|
project_name: 'app_demo',
|
||||||
|
description: '这是一个测试应用',
|
||||||
|
spma: 'spa23d',
|
||||||
|
creator: '月飞',
|
||||||
|
gmt_create: '2020-02-11 00:00:00',
|
||||||
|
gmt_modified: '2020-02-11 00:00:00',
|
||||||
|
},
|
||||||
|
i18n: {
|
||||||
|
'zh-CN': {
|
||||||
|
'i18n-jwg27yo4': '你好',
|
||||||
|
'i18n-jwg27yo3': '中国',
|
||||||
|
},
|
||||||
|
'en-US': {
|
||||||
|
'i18n-jwg27yo4': 'Hello',
|
||||||
|
'i18n-jwg27yo3': 'China',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default demoData;
|
||||||
@ -71,12 +71,21 @@ const demoData: IProjectSchema = {
|
|||||||
state: {
|
state: {
|
||||||
text: 'outter',
|
text: 'outter',
|
||||||
},
|
},
|
||||||
|
lifeCycles: {
|
||||||
|
componentDidMount: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'function() { this.utils.request(this.props.url); }',
|
||||||
|
},
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
componentName: 'Form',
|
componentName: 'Form',
|
||||||
id: 'node$2',
|
id: 'node$2',
|
||||||
props: {
|
props: {
|
||||||
labelCol: 4,
|
labelCol: {
|
||||||
|
type: 'JSExpression',
|
||||||
|
value: 'this.state.colNum',
|
||||||
|
},
|
||||||
style: {},
|
style: {},
|
||||||
ref: 'testForm',
|
ref: 'testForm',
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user