¶Ô±ÈÐÂÎļþ |
| | |
| | | import { Component, DefineComponent, h } from 'vue' |
| | | import Provider from './index.vue' |
| | | /** |
| | | * |
| | | * @param Widget ç»ä»¶ |
| | | * @param data notPage æ¯å¦ä¸ºç»ä»¶ | NestedComponents åµå¥ç»ä»¶ |
| | | * @param isFullyCover æ¯å¦éºæ»¡ |
| | | * @param defaultConfig é»è®¤æ ·å¼é
ç½®ï¼æ¯æwidth,height,padding,background |
| | | * @returns |
| | | */ |
| | | export function provider( |
| | | Widget: Component, |
| | | data: boolean | Component = false, |
| | | isFullyCover: boolean = false, |
| | | defaultConfig: Record<string, any> = {} |
| | | ) { |
| | | // const v = typeof notPage === 'boolean' ? notPage : |
| | | let notPage |
| | | let NestedComponents |
| | | if (typeof data === 'boolean') { |
| | | notPage === !!data |
| | | } |
| | | if (typeof data === 'object' || typeof data === 'function') { |
| | | NestedComponents = data |
| | | } |
| | | return (arg: any) => { |
| | | return h( |
| | | Provider, |
| | | { |
| | | widgetProps: arg, |
| | | widgetName: Widget.name, |
| | | isFullyCover, |
| | | notPage, |
| | | defaultConfig, |
| | | NestedComponents, |
| | | }, |
| | | { |
| | | default: !NestedComponents |
| | | ? (props) => { |
| | | return h(Widget, props) |
| | | } |
| | | : null, |
| | | nested: NestedComponents |
| | | ? (props: any) => { |
| | | return h(NestedComponents, props, { |
| | | default: (childProps) => { |
| | | return h(Widget, { ...props, ...childProps }) |
| | | }, |
| | | }) |
| | | } |
| | | : null, |
| | | } |
| | | ) |
| | | } |
| | | } |