xiaochan-element-plus.ts 910 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { ElMessage, useNamespace } from "element-plus";
  2. import { ref } from "vue";
  3. function message(msg: string, type: string, isHtml: boolean) {
  4. return ElMessage({
  5. type: type,
  6. // @ts-ignore
  7. duration: 3500,
  8. dangerouslyUseHTMLString: isHtml,
  9. message: msg,
  10. showClose: true,
  11. grouping: true,
  12. });
  13. }
  14. export const xcMessage = {
  15. success: (msg: string, isHtml = false) => {
  16. return message(msg, "success", isHtml);
  17. },
  18. danger: (msg: string, isHtml = false) => {
  19. return message(msg, "error", isHtml);
  20. },
  21. info: (msg: string, isHtml = false) => {
  22. return message(msg, "info", isHtml);
  23. },
  24. warning: (msg: string, isHtml = false) => {
  25. return message(msg, "warning", isHtml);
  26. },
  27. error: (msg: string, isHtml = false) => {
  28. return message(msg, "error", isHtml);
  29. },
  30. };
  31. export function useCyNamespace(name: string) {
  32. return useNamespace(name, ref("cy"));
  33. }