import { ElMessageBox, ElMessageBoxOptions } from 'element-plus';

export const openMessageBox = (content: string, title: string, type: 'default' | ElMessageBoxOptions['type']) => {
  return ElMessageBox.confirm(content, title, {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    customClass: `customMessageBox--${type}`,
  })
    .then(() => {
      return true;
    })
    .catch(() => {
      return false;
    });
};

/** UI定制化样式的confirm方法，和elmessage.confirm一样的参数 */
export const msgConfirm = (content: string, title: string, options: ElMessageBoxOptions) => {
  const { type, ...otherOptions } = options;
  return ElMessageBox.confirm(content, title, {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    customClass: `customMessageBox--${type}`,
    ...otherOptions,
  });
};
