import { createSignal, For, JSX, onMount, Show } from "solid-js" import { useClassList } from "../utils/useProps"; import { Icon } from "../Icon"; import { NoticeConfig } from "."; import usezIndex from "../utils/usezIndex"; type NoticesProps = { data?: any, onClose?: Function, docker?: string } function NoticePanel (props: any) { const [visible, setVisible] = createSignal(false); const [closed, setClosed] = createSignal(false); let wrap: any; const data: NoticeConfig = props.data; let { style, icon, btn, theme, title, content } = data; const classList = () => useClassList(props, 'cm-notification-item', { 'cm-notification-item-width-icon': icon, 'cm-notification-item-open': visible(), 'cm-notification-item-close': closed(), [`cm-notification-item-${theme}`]: theme, }); onMount(() => { setTimeout(()=>{ setVisible(true); }); if (data.duration) { setTimeout(() => { hide(); }, data.duration * 1000); } }); const hide = () => { // 隐藏效果 if (!closed()) { setClosed(true); setTimeout(() => { close() }, 250); } } const close = () => { props.onClose(data.key, data.dock); data.onClose && data.onClose(); } return
} export function NoticeBox (props: NoticesProps): JSX.Element { const data = () => props.data; const zindex = usezIndex(); return