xiaochan-element-plus.ts 972 B

12345678910111213141516171819202122232425262728293031323334353637
  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, 'danger', 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. }