import { define, WeElement, extractClass, h, render } from 'omi'
import * as css from './index.scss'
import '../icon'
//@ts-ignore
import '../theme.ts'
define('m-toast', class extends WeElement {
static defaultProps = {
show: false
}
static css = css
render(props) {
const cls = extractClass(props, 'm-toast')
const { type, show, children, iconSize, ...others } = props
return (
)
}
})
let toast: any = {},
dom
toast.showLoading = function (text) {
if (dom) {
document.body.removeChild(dom)
}
dom = render({text || '加载中'}, 'body')
}
toast.hideLoading = function () {
if (dom) {
document.body.removeChild(dom)
dom = null
}
}
toast.show = function ({path, text, rotate}) {
if (dom) {
document.body.removeChild(dom)
}
dom = render({text || ''}, 'body')
}
toast.hide = toast.hideLoading
export default toast