import './index.less' import { getVueNode } from '../../utils' import type { WithFalse } from '../../types' import type { CSSProperties, PropType, Slot } from 'vue' import type { VueNodeOrRender } from '#/types' import { getPrefixCls } from '#/layout/RouteContext' type LinkInfo = { key?: string title: VueNodeOrRender href: string blankTarget?: boolean } export type Link = WithFalse export interface GlobalFooterProps { links: Link copyright?: WithFalse prefixCls?: string } function renderLinks(links: Link, linksSlot?: Slot) { if (Array.isArray(links)) { if (links.length === 0) { return null } return (links as LinkInfo[]).map(link => ( {link.title} )) } return getVueNode(links as WithFalse, linksSlot) } export default defineComponent({ name: 'GlobalFooter', props: { links: { type: [Object, Function, String, Boolean, Array] as PropType, default: () => { return undefined } }, copyright: { type: [Object, Function, String, Boolean] as PropType>, default: () => { return undefined } }, prefixCls: { type: String, default: 'pro-global-footer' } }, setup(props, { slots, attrs }) { return () => { const linksDom = renderLinks(props.links, slots.links) const copyrightDom = getVueNode(props.copyright, slots.copyright) if (linksDom && copyrightDom == null) { return null } const globalPrefixCls = getPrefixCls() const baseClassName = `${globalPrefixCls}-${props.prefixCls}` const clsString = [baseClassName, attrs.class] return (
{linksDom &&
{linksDom}
} {copyrightDom &&
{copyrightDom}
}
) } } })