fix: add createcomponents and add doc
This commit is contained in:
		| @@ -21,3 +21,30 @@ export class ComponentItemFactory implements ComponentItem { | ||||
| 		public remoteConfig: ComponentItem['remoteConfig'] = {} | ||||
| 	) {} | ||||
| } | ||||
| export interface IPluginConfig { | ||||
| 	name: ComponentItemFactory['name']; | ||||
| 	display: ComponentItemFactory['display']; | ||||
| 	props: ComponentItemFactory['props']; | ||||
| 	initData: ComponentItemFactory['initData']; | ||||
| 	render: ComponentItem['render']; | ||||
| 	resize?: ComponentItem['resize']; | ||||
| 	needPosition?: ComponentItem['needPosition']; | ||||
| 	init?: ComponentItem['init']; | ||||
| 	destroy?: ComponentItem['destroy']; | ||||
| 	remoteConfig?: ComponentItem['remoteConfig']; | ||||
| } | ||||
|  | ||||
| export function createComponent(config: IPluginConfig) { | ||||
| 	return new ComponentItemFactory( | ||||
| 		config.name, | ||||
| 		config.display, | ||||
| 		config.props, | ||||
| 		config.initData, | ||||
| 		config.render, | ||||
| 		config.resize, | ||||
| 		config.needPosition, | ||||
| 		config.init, | ||||
| 		config.destroy, | ||||
| 		config.remoteConfig | ||||
| 	); | ||||
| } | ||||
|   | ||||
| @@ -7,20 +7,6 @@ import { specialCoList } from './special'; | ||||
| import deepCopys from 'deepcopy'; | ||||
| import { FunctionDataMap } from '../functionCenter/config'; | ||||
| import UserConfig from '../../config'; | ||||
| import { IPluginConfig } from './types'; | ||||
| import { ComponentItemFactory } from '../components/abstract'; | ||||
|  | ||||
| // 创建插件 | ||||
| export const createPlugin = (config: IPluginConfig) => { | ||||
| 	return new ComponentItemFactory( | ||||
| 		config.key, | ||||
| 		config.name, | ||||
| 		{}, | ||||
| 		config.attr, | ||||
| 		config.render, | ||||
| 		config.attr.resize | ||||
| 	); | ||||
| }; | ||||
|  | ||||
| export function deepCopy<T = any>(obj: T): T { | ||||
| 	return deepCopys(obj); | ||||
|   | ||||
| @@ -1,7 +0,0 @@ | ||||
| export interface IPluginConfig { | ||||
| 	key: string; | ||||
| 	name: string; | ||||
| 	attr: any; | ||||
| 	render: (props: any) => JSX.Element; | ||||
| 	resize?: boolean; | ||||
| } | ||||
| @@ -40,7 +40,7 @@ export { scaleFn } from './core/scale/index'; | ||||
|  | ||||
| // 以下导出用于制作插件 | ||||
| // 用于制作组件的函数 | ||||
| export { ComponentItemFactory } from './core/components/abstract'; | ||||
| export { ComponentItemFactory, createComponent } from './core/components/abstract'; | ||||
| // 用于菜单拖拽的函数 | ||||
| export { dragEventResolve } from './core/crossDrag/index'; | ||||
| // 用于制作组件配置项的函数 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 hufeixiong
					hufeixiong