fix: 可以降级到历史的 JSBlock 格式

This commit is contained in:
mario.gk 2020-07-15 20:55:30 +08:00
parent 555824c9b7
commit af1746b0be
5 changed files with 8 additions and 2 deletions

View File

@ -86,6 +86,8 @@ export class Prop implements IPropParent {
type: 'JSSlot', type: 'JSSlot',
params: schema.params, params: schema.params,
value: schema.children, value: schema.children,
title: schema.title,
name: schema.name,
}; };
} }
@ -235,6 +237,7 @@ export class Prop implements IPropParent {
const slotSchema: SlotSchema = { const slotSchema: SlotSchema = {
componentName: 'Slot', componentName: 'Slot',
title: data.title, title: data.title,
name: data.name,
params: data.params, params: data.params,
children: data.value, children: data.value,
}; };

View File

@ -281,7 +281,7 @@ export function upgradePropConfig(config: OldPropConfig, collector: ConfigCollec
let initialFn = (slotName ? null : initial) || initialValue; let initialFn = (slotName ? null : initial) || initialValue;
if (slotName && initialValue === true) { if (slotName && initialValue === true) {
initialFn = (field: any, value: any) => { initialFn = (value: any, defaultValue: any) => {
if (isJSSlot(value)) { if (isJSSlot(value)) {
return { return {
title: slotTitle || title, title: slotTitle || title,

View File

@ -55,6 +55,7 @@ function upgradePropsReducer(props: any) {
val = { val = {
type: 'JSSlot', type: 'JSSlot',
title: (val.value.props as any)?.slotTitle, title: (val.value.props as any)?.slotTitle,
name: (val.value.props as any)?.slotName,
value: val.value.children value: val.value.children
}; };
} else { } else {
@ -138,7 +139,6 @@ function compatiableReducer(props: any) {
const newProps: any = {}; const newProps: any = {};
Object.entries<any>(props).forEach(([key, val]) => { Object.entries<any>(props).forEach(([key, val]) => {
if (isJSSlot(val)) { if (isJSSlot(val)) {
val.value
val = { val = {
type: 'JSBlock', type: 'JSBlock',
value: { value: {
@ -146,6 +146,7 @@ function compatiableReducer(props: any) {
children: val.value, children: val.value,
props: { props: {
slotTitle: val.title, slotTitle: val.title,
slotName: val.name,
}, },
}, },
} }

View File

@ -69,6 +69,7 @@ export interface BlockSchema extends NodeSchema {
componentName: 'Block'; componentName: 'Block';
} }
export interface SlotSchema extends NodeSchema { export interface SlotSchema extends NodeSchema {
name?: string;
componentName: 'Slot'; componentName: 'Slot';
params?: string[]; params?: string[];
} }

View File

@ -14,6 +14,7 @@ export interface JSExpression {
} }
export interface JSSlot { export interface JSSlot {
name?: string;
type: 'JSSlot'; type: 'JSSlot';
title?: string; title?: string;
// 函数的入参 // 函数的入参