import {ElMessage} from "element-plus";

export const xcMessage = {
    success: (msg, isHtml = false) => {
        return message(msg, 'success', isHtml)
    },
    danger: (msg, isHtml = false) => {
        return message(msg, 'danger', isHtml)
    },
    info: (msg, isHtml = false) => {
        return message(msg, 'info', isHtml)
    },
    warning: (msg, isHtml = false) => {
        return message(msg, 'warning', isHtml)
    },
    error: (msg, isHtml = false) => {
        return message(msg, 'error', isHtml)
    }
}

function message(msg, type, isHtml) {
    return ElMessage({
        type: type,
        duration: 2800,
        dangerouslyUseHTMLString: isHtml,
        message: msg,
        showClose: true,
        grouping: true,
    })
}
