import { h } from 'vue'
import { ElMessage } from 'element-plus'
import Icon from '@/components/Icon/index.vue'
import 'element-plus/es/components/message/style/index'

const successTip = (msg: string, html = false) => {
  ElMessage({
    dangerouslyUseHTMLString: html,
    message: msg,
    type: 'success',
    customClass: 'success_messageBox',
    icon: h(Icon, { name: 'tip_success', size: 42 }),
  })
}

const errorTip = (msg: string, html = false) => {
  ElMessage({
    dangerouslyUseHTMLString: html,
    message: msg,
    type: 'error',
    customClass: 'error_messageBox',
    icon: h(Icon, { name: 'tip_error', size: 42 }),
  })
}

const infoTip = (msg: string, html = false) => {
  ElMessage({
    dangerouslyUseHTMLString: html,
    message: msg,
    type: 'info',
    customClass: 'info_messageBox',
  })
}

export const XMessage = {
  success: successTip,
  error: errorTip,
  info: infoTip,
}
