type MatchOneType = CommonEditType & ( EditStringType | EditNumberType | EditColorType | EditImageType | EditBooleanType | EditSelectType | EditArrayType | EditObjectType | EditShareReadType | EditBookReviewSearchType | EditCardGroupType | EditBountySearchType | EditMusicType | EditBookSearchType | EditVideoType | EditNovelfestivalType | EditCouponSearchType | EditRevealListType | EditLinkType | EditProductSearchType | EditDateTimeType | EditPublishType ) /* 以下为各组件类型定义,可续可自行添加,顺序根据当前使用频率排序 */ type CommonEditType = { /** * Field to control */ field: string; /** * Label show text */ text?: string; /** * 关联实例类型 */ relate?: string; /** * 默认值 */ defaultValue?: any; } type EditStringType = { type: 'string'; placeholder?: string; } type EditNumberType = { type: 'number'; placeholder?: string; data?: { input?: number[]; /** * 滑块输入框步长 */ step?: number; /** * 是否使用滑块 */ useSlider?: boolean; /** * 输入范围 */ inputRange?: number[]; /** * 输出范围 */ outputRange?: number[]; /** * 数值精度 */ precision?: number; } } type EditColorType = { type: 'color'; } type EditImageType = { type: 'image'; placeholder?: string; /** * 图片宽度限制,单位像素 */ width?: number; /** * 图片高度限制,单位像素 */ height?: number; /** * 图片大小限制,单位B */ maxSize?: number; /** * 图片宽高比例限制,例:3/2 */ widthToHeight?: number; /** * 自定义function * 示例:customFun: (file: File): boolean => { * // 也可结合file.type, regex来限制图片类型 * if (file.size < 1024) { * message.error(`文件大小小于限制`); * return false; * } else return true; * } */ customFun?: Function; } type EditBooleanType = { type: 'boolean'; helper?: string; } type EditSelectType = { type: 'select'; data?: { text?: string; value?: string | number; disabled?: boolean; }[] } type EditArrayType = { type: 'array'; data?: Partial[]; /** * 用于在新增时给列表里的item赋初始值 * 示例:addItem: { * type: 5, * } */ addItem?: {}; } type EditObjectType = { type: 'object'; data: Partial[]; } type EditLinkType = { type: 'link'; } type EditBookReviewSearchType = { type: 'bookReviewSearch'; } type EditCardGroupType = { type: 'cardGroup'; } type EditBountySearchType = { type: 'bountySearch'; } type EditShareReadType = { type: 'shareRead'; } type EditMusicType = { type: 'music'; } type EditBookSearchType = { type: 'bookSearch'; } type EditVideoType = { type: 'video'; } type EditNovelfestivalType = { type: 'novelfestival'; } type EditCouponSearchType = { type: 'couponSearch' } type EditRevealListType = { type: 'reveal-list'; } type EditProductSearchType = { type: 'productSearch' } type EditDateTimeType = { type: 'datetime' } type EditPublishType = { type: 'publish' } type ComponentMenuType = 'common' | 'business' type CommonMenuType = 'lofter' | 'snail' type ComponentMenuArrayType = [ComponentMenuType, CommonMenuType] export type EditSetting = { /** * Unique key */ key?: string; /** * Custom show name */ name?: string; /** * Container can be dragged into component */ isContainer?: boolean; /** * 组件类型,如通用组件、业务组件 * common, business */ type?: ComponentMenuType | ComponentMenuArrayType; /** * 高度是否自适应父容器 */ isAutoHeight?: boolean; /** * 是否支持自由拖动 */ isFreeMove?: boolean; /** * 说明文档链接 */ help?: string | {}; /** * 组件初始位置 */ defaultPosition?: { top?: string; left?: string; }; /** * Edit infos */ editors?: Array< string | Partial >; } export class BasicProps { /** * 编辑栏schema配置项 */ editSetting: EditSetting; /** * 组件实例的唯一key */ instanceKey: string; /** * 父组件实例的唯一key */ parentInstanceKey: string; /** * h5 编辑器会自动注入style, * 需要把它放到你组件的最外层节点上 */ style?: any; /** * 编辑的时候会返回 true */ isEdit?: boolean; /** * BaseComponent所需,如果需要设置BaseComponent的样式,又方式props中其他style污染BaseComponent,可以使用本字段传给BaseComponent */ customStyle?: any; } export class BasicState { public htmlFontSize = 37.5; }