message.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { ElMessage, ElMessageBox, ElNotification } from 'element-plus'
  2. import { useI18n } from '@/hooks/web/useI18n'
  3. const { t } = useI18n() // 国际化
  4. const message = {
  5. // 消息提示
  6. msg(content: string) {
  7. ElMessage.info(content)
  8. },
  9. // 错误消息
  10. msgError(content: string) {
  11. ElMessage.error(content)
  12. },
  13. // 成功消息
  14. msgSuccess(content: string) {
  15. ElMessage.success(content)
  16. },
  17. // 警告消息
  18. msgWarning(content: string) {
  19. ElMessage.warning(content)
  20. },
  21. // 弹出提示
  22. alert(content: string) {
  23. ElMessageBox.alert(content, t('common.confirmTitle'))
  24. },
  25. // 错误提示
  26. alertError(content: string) {
  27. ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'error' })
  28. },
  29. // 成功提示
  30. alertSuccess(content: string) {
  31. ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'success' })
  32. },
  33. // 警告提示
  34. alertWarning(content: string) {
  35. ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'warning' })
  36. },
  37. // 通知提示
  38. notify(content: string) {
  39. ElNotification.info(content)
  40. },
  41. // 错误通知
  42. notifyError(content: string) {
  43. ElNotification.error(content)
  44. },
  45. // 成功通知
  46. notifySuccess(content: string) {
  47. ElNotification.success(content)
  48. },
  49. // 警告通知
  50. notifyWarning(content: string) {
  51. ElNotification.warning(content)
  52. },
  53. // 确认窗体
  54. confirm(content: string) {
  55. return ElMessageBox.confirm(content, t('common.confirmTitle'), {
  56. confirmButtonText: t('common.ok'),
  57. cancelButtonText: t('common.cancel'),
  58. type: 'warning'
  59. })
  60. },
  61. // 提交内容
  62. prompt(content: string) {
  63. return ElMessageBox.prompt(content, t('common.confirmTitle'), {
  64. confirmButtonText: t('common.ok'),
  65. cancelButtonText: t('common.cancel'),
  66. type: 'warning'
  67. })
  68. }
  69. }
  70. export default message