import {MessagePlugin, loading} from 'tdesign-react'

export const show_message = (
    value: string,
    type: 'warning' | 'success' | 'info' | 'error' = 'warning',
    close: boolean = true
) => {
    if (close) {
        MessagePlugin.closeAll();
    }
    if (type == 'warning') {
        MessagePlugin.warning(value);
    } else if (type == 'success') {
        MessagePlugin.success(value);
    } else if (type == 'info') {
        MessagePlugin.info(value);
    } else if (type == 'error') {
        MessagePlugin.error(value);
    }
    // 类型报错-所以用上面的方法
    // MessagePlugin[type](value);
};

// 打开全局loading
export const open_loading = () => {
    return loading({
        size: '20px',
        loading: true,
    });
}
