import { showSuccessToast, showFailToast, showToast } from 'vant'

const toastCommonOptions = {
  duration: 2000,
  className: 'loading-toast',
  iconSize: '36px'
}
// 注册全局方法
export default {
  install: app => {
    // 注册提示
    app.config.globalProperties.$showToast = (message, options = {}) => {
      return showToast({
        message,
        ...toastCommonOptions,
        ...options
      })
    }

    // 注册成功提示
    app.config.globalProperties.$showSuccessToast = (message, options = {}) => {
      return showSuccessToast({
        message,
        ...toastCommonOptions,
        ...options
      })
    }

    // 注册失败提示
    app.config.globalProperties.$showFailToast = (message, options = {}) => {
      return showFailToast({
        message,
        ...toastCommonOptions,
        ...options
      })
    }
  }
}
