fix: 更改生成 id 的规则, 否则命中 recore 解析 id 的一个限制

This commit is contained in:
力皓 2020-06-17 15:34:31 +08:00
parent 21d4f64780
commit 5adff447c1
3 changed files with 42 additions and 42 deletions

View File

@ -58,7 +58,7 @@ const demoData: IProjectSchema = {
componentsTree: [ componentsTree: [
{ {
componentName: 'Page', componentName: 'Page',
id: 'node$1', id: 'node_1',
meta: { meta: {
title: '测试', title: '测试',
router: '/', router: '/',
@ -74,7 +74,7 @@ const demoData: IProjectSchema = {
children: [ children: [
{ {
componentName: 'Form', componentName: 'Form',
id: 'node$2', id: 'node_2',
props: { props: {
labelCol: 4, labelCol: 4,
style: {}, style: {},
@ -83,7 +83,7 @@ const demoData: IProjectSchema = {
children: [ children: [
{ {
componentName: 'Form.Item', componentName: 'Form.Item',
id: 'node$3', id: 'node_3',
props: { props: {
label: '姓名:', label: '姓名:',
name: 'name', name: 'name',
@ -92,7 +92,7 @@ const demoData: IProjectSchema = {
children: [ children: [
{ {
componentName: 'Input', componentName: 'Input',
id: 'node$4', id: 'node_4',
props: { props: {
placeholder: '请输入', placeholder: '请输入',
size: 'medium', size: 'medium',
@ -105,7 +105,7 @@ const demoData: IProjectSchema = {
}, },
{ {
componentName: 'Form.Item', componentName: 'Form.Item',
id: 'node$5', id: 'node_5',
props: { props: {
label: '年龄:', label: '年龄:',
name: 'age', name: 'age',
@ -114,7 +114,7 @@ const demoData: IProjectSchema = {
children: [ children: [
{ {
componentName: 'NumberPicker', componentName: 'NumberPicker',
id: 'node$6', id: 'node_6',
props: { props: {
size: 'medium', size: 'medium',
type: 'normal', type: 'normal',
@ -124,7 +124,7 @@ const demoData: IProjectSchema = {
}, },
{ {
componentName: 'Form.Item', componentName: 'Form.Item',
id: 'node$7', id: 'node_7',
props: { props: {
label: '职业:', label: '职业:',
name: 'profession', name: 'profession',
@ -132,7 +132,7 @@ const demoData: IProjectSchema = {
children: [ children: [
{ {
componentName: 'Select', componentName: 'Select',
id: 'node$8', id: 'node_8',
props: { props: {
dataSource: [ dataSource: [
{ {
@ -154,7 +154,7 @@ const demoData: IProjectSchema = {
}, },
{ {
componentName: 'Div', componentName: 'Div',
id: 'node$9', id: 'node_9',
props: { props: {
style: { style: {
textAlign: 'center', textAlign: 'center',
@ -163,12 +163,12 @@ const demoData: IProjectSchema = {
children: [ children: [
{ {
componentName: 'Button.Group', componentName: 'Button.Group',
id: 'node$a', id: 'node_a',
props: {}, props: {},
children: [ children: [
{ {
componentName: 'Button', componentName: 'Button',
id: 'node$b', id: 'node_b',
props: { props: {
type: 'primary', type: 'primary',
style: { style: {
@ -180,7 +180,7 @@ const demoData: IProjectSchema = {
}, },
{ {
componentName: 'Button', componentName: 'Button',
id: 'node$d', id: 'node_d',
props: { props: {
type: 'normal', type: 'normal',
style: { style: {

View File

@ -1,6 +1,6 @@
{ {
"componentName": "Page", "componentName": "Page",
"id": "node$1", "id": "node_1",
"props": { "props": {
"ref": "outterView", "ref": "outterView",
"autoLoading": true, "autoLoading": true,
@ -23,7 +23,7 @@
"children": [ "children": [
{ {
"componentName": "Steps", "componentName": "Steps",
"id": "node$1i", "id": "node_1i",
"props": { "props": {
"dataSource": [ "dataSource": [
{ {
@ -87,7 +87,7 @@
}, },
{ {
"componentName": "Title", "componentName": "Title",
"id": "node$b", "id": "node_b",
"props": { "props": {
"text": "请填写以下人员信息表单", "text": "请填写以下人员信息表单",
"type": "primary", "type": "primary",
@ -98,7 +98,7 @@
}, },
{ {
"componentName": "Paragraph", "componentName": "Paragraph",
"id": "node$e", "id": "node_e",
"props": { "props": {
"content": "人最宝贵的是生命。它给予我们只有一次。人的一生应当这样度过:当他回首往事时不因虚度年华而悔恨,也不因碌碌无为而羞耻。这样在他临死的时侯就能够说:我已把我整个的生命和全部精力都献给最壮丽的事业——为人类的解放而斗争。", "content": "人最宝贵的是生命。它给予我们只有一次。人的一生应当这样度过:当他回首往事时不因虚度年华而悔恨,也不因碌碌无为而羞耻。这样在他临死的时侯就能够说:我已把我整个的生命和全部精力都献给最壮丽的事业——为人类的解放而斗争。",
"size": "medium", "size": "medium",
@ -109,7 +109,7 @@
}, },
{ {
"componentName": "ColumnsLayout", "componentName": "ColumnsLayout",
"id": "node$r", "id": "node_r",
"props": { "props": {
"layout": "6:6", "layout": "6:6",
"columnGap": "16px", "columnGap": "16px",
@ -122,7 +122,7 @@
"children": [ "children": [
{ {
"componentName": "Column", "componentName": "Column",
"id": "node$s", "id": "node_s",
"props": { "props": {
"fieldId": "column_kadcb0o9", "fieldId": "column_kadcb0o9",
"__style__": {} "__style__": {}
@ -130,7 +130,7 @@
"children": [ "children": [
{ {
"componentName": "Card", "componentName": "Card",
"id": "node$n", "id": "node_n",
"props": { "props": {
"title": "基本信息", "title": "基本信息",
"subTitle": { "subTitle": {
@ -144,7 +144,7 @@
"value": [ "value": [
{ {
"componentName": "Icon", "componentName": "Icon",
"id": "node$q", "id": "node_q",
"props": { "props": {
"type": { "type": {
"useType": true, "useType": true,
@ -168,12 +168,12 @@
"children": [ "children": [
{ {
"componentName": "CardContent", "componentName": "CardContent",
"id": "node$o", "id": "node_o",
"props": {}, "props": {},
"children": [ "children": [
{ {
"componentName": "Form", "componentName": "Form",
"id": "node$f", "id": "node_f",
"props": { "props": {
"labelAlign": "top", "labelAlign": "top",
"size": "medium", "size": "medium",
@ -190,7 +190,7 @@
"children": [ "children": [
{ {
"componentName": "TextField", "componentName": "TextField",
"id": "node$g", "id": "node_g",
"props": { "props": {
"__category__": "form", "__category__": "form",
"__useMediator": "value", "__useMediator": "value",
@ -256,7 +256,7 @@
}, },
{ {
"componentName": "RadioField", "componentName": "RadioField",
"id": "node$14", "id": "node_14",
"props": { "props": {
"__category__": "form", "__category__": "form",
"__useMediator": "value", "__useMediator": "value",
@ -324,7 +324,7 @@
}, },
{ {
"componentName": "SelectField", "componentName": "SelectField",
"id": "node$h", "id": "node_h",
"props": { "props": {
"__category__": "form", "__category__": "form",
"__useMediator": "value", "__useMediator": "value",
@ -404,7 +404,7 @@
}, },
{ {
"componentName": "Div", "componentName": "Div",
"id": "node$i", "id": "node_i",
"props": { "props": {
"behavior": "NORMAL", "behavior": "NORMAL",
"__style__": {}, "__style__": {},
@ -413,7 +413,7 @@
"children": [ "children": [
{ {
"componentName": "Button", "componentName": "Button",
"id": "node$j", "id": "node_j",
"props": { "props": {
"content": { "content": {
"type": "i18n", "type": "i18n",
@ -449,7 +449,7 @@
}, },
{ {
"componentName": "Button", "componentName": "Button",
"id": "node$k", "id": "node_k",
"props": { "props": {
"content": { "content": {
"type": "i18n", "type": "i18n",
@ -495,7 +495,7 @@
}, },
{ {
"componentName": "Column", "componentName": "Column",
"id": "node$t", "id": "node_t",
"props": { "props": {
"fieldId": "column_kadcb0oa", "fieldId": "column_kadcb0oa",
"__style__": {} "__style__": {}
@ -503,7 +503,7 @@
"children": [ "children": [
{ {
"componentName": "Card", "componentName": "Card",
"id": "node$u", "id": "node_u",
"props": { "props": {
"title": { "title": {
"type": "JSSlot", "type": "JSSlot",
@ -511,7 +511,7 @@
"value": [ "value": [
{ {
"componentName": "Icon", "componentName": "Icon",
"id": "node$18", "id": "node_18",
"props": { "props": {
"type": { "type": {
"useType": true, "useType": true,
@ -525,7 +525,7 @@
}, },
{ {
"componentName": "Link", "componentName": "Link",
"id": "node$19", "id": "node_19",
"props": { "props": {
"content": { "content": {
"type": "i18n", "type": "i18n",
@ -559,7 +559,7 @@
"value": [ "value": [
{ {
"componentName": "Icon", "componentName": "Icon",
"id": "node$1a", "id": "node_1a",
"props": { "props": {
"type": { "type": {
"useType": true, "useType": true,
@ -583,12 +583,12 @@
"children": [ "children": [
{ {
"componentName": "CardContent", "componentName": "CardContent",
"id": "node$v", "id": "node_v",
"props": {}, "props": {},
"children": [ "children": [
{ {
"componentName": "Form", "componentName": "Form",
"id": "node$x", "id": "node_x",
"props": { "props": {
"labelAlign": "top", "labelAlign": "top",
"size": "medium", "size": "medium",
@ -605,7 +605,7 @@
"children": [ "children": [
{ {
"componentName": "TextField", "componentName": "TextField",
"id": "node$y", "id": "node_y",
"props": { "props": {
"__category__": "form", "__category__": "form",
"__useMediator": "value", "__useMediator": "value",
@ -671,7 +671,7 @@
}, },
{ {
"componentName": "DateField", "componentName": "DateField",
"id": "node$15", "id": "node_15",
"props": { "props": {
"__category__": "form", "__category__": "form",
"__useMediator": "value", "__useMediator": "value",
@ -716,7 +716,7 @@
}, },
{ {
"componentName": "SelectField", "componentName": "SelectField",
"id": "node$z", "id": "node_z",
"props": { "props": {
"__category__": "form", "__category__": "form",
"__useMediator": "value", "__useMediator": "value",
@ -796,7 +796,7 @@
}, },
{ {
"componentName": "Div", "componentName": "Div",
"id": "node$10", "id": "node_10",
"props": { "props": {
"behavior": "NORMAL", "behavior": "NORMAL",
"__style__": {}, "__style__": {},
@ -805,7 +805,7 @@
"children": [ "children": [
{ {
"componentName": "Button", "componentName": "Button",
"id": "node$11", "id": "node_11",
"props": { "props": {
"content": { "content": {
"type": "i18n", "type": "i18n",
@ -841,7 +841,7 @@
}, },
{ {
"componentName": "Button", "componentName": "Button",
"id": "node$12", "id": "node_12",
"props": { "props": {
"content": { "content": {
"type": "i18n", "type": "i18n",

View File

@ -144,7 +144,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
constructor(readonly document: DocumentModel, nodeSchema: Schema) { constructor(readonly document: DocumentModel, nodeSchema: Schema) {
const { componentName, id, children, props, ...extras } = nodeSchema; const { componentName, id, children, props, ...extras } = nodeSchema;
this.id = id || `node$${document.nextId()}`; this.id = id || `node_${document.nextId()}`;
this.componentName = componentName; this.componentName = componentName;
if (this.componentName === 'Leaf') { if (this.componentName === 'Leaf') {
this.props = new Props(this, { this.props = new Props(this, {