//引入官方组件

import { Message } from 'element-ui'

// 默认参数
const defaultOption = {
    duration: 3000,
    customClass: 'custom-notification',
}

const message = {}

const globalMessage = function (type, msg = '', customOption = {}) {
    return Message({
        ...Object.assign({}, defaultOption, customOption),
        type,
        dangerouslyUseHTMLString: true,
        message: `<p>${msg}</p>`,
    })
}

message.success = function (msg, cpt) {
    return globalMessage('success', msg, cpt)
}
message.error = function (msg, cpt) {
    return globalMessage('error', msg, cpt)
}
message.warning = function (msg, cpt) {
    return globalMessage('warning', msg, cpt)
}

export default message
