Newer
Older
KaiFengPC / src / plugins / modal.js
@zhangdeliang zhangdeliang on 23 May 1 KB 初始化项目
  1. import { ElMessage, ElMessageBox, ElNotification, ElLoading } from 'element-plus';
  2.  
  3. let loadingInstance;
  4.  
  5. export default {
  6. // 消息提示
  7. msg(content) {
  8. ElMessage.info(content);
  9. },
  10. // 错误消息
  11. msgError(content) {
  12. ElMessage.error(content);
  13. },
  14. // 成功消息
  15. msgSuccess(content) {
  16. ElMessage.success(content);
  17. },
  18. // 警告消息
  19. msgWarning(content) {
  20. ElMessage.warning(content);
  21. },
  22. // 弹出提示
  23. alert(content) {
  24. ElMessageBox.alert(content, '系统提示');
  25. },
  26. // 错误提示
  27. alertError(content) {
  28. ElMessageBox.alert(content, '系统提示', { type: 'error' });
  29. },
  30. // 成功提示
  31. alertSuccess(content) {
  32. ElMessageBox.alert(content, '系统提示', { type: 'success' });
  33. },
  34. // 警告提示
  35. alertWarning(content) {
  36. ElMessageBox.alert(content, '系统提示', { type: 'warning' });
  37. },
  38. // 通知提示
  39. notify(content) {
  40. ElNotification.info(content);
  41. },
  42. // 错误通知
  43. notifyError(content) {
  44. ElNotification.error(content);
  45. },
  46. // 成功通知
  47. notifySuccess(content) {
  48. ElNotification.success(content);
  49. },
  50. // 警告通知
  51. notifyWarning(content) {
  52. ElNotification.warning(content);
  53. },
  54. // 确认窗体
  55. confirm(content, confirmButtonText, cancelButtonText) {
  56. return ElMessageBox.confirm(content, '系统提示', {
  57. confirmButtonText: confirmButtonText || '确定',
  58. cancelButtonText: cancelButtonText || '取消',
  59. type: 'warning',
  60. });
  61. },
  62. // 提交内容
  63. prompt(content) {
  64. return ElMessageBox.prompt(content, '系统提示', {
  65. confirmButtonText: '确定',
  66. cancelButtonText: '取消',
  67. type: 'warning',
  68. });
  69. },
  70. // 打开遮罩层
  71. loading(content) {
  72. loadingInstance = ElLoading.service({
  73. lock: true,
  74. text: content,
  75. background: 'rgba(0, 0, 0, 0.7)',
  76. });
  77. },
  78. // 关闭遮罩层
  79. closeLoading() {
  80. loadingInstance.close();
  81. },
  82. };