峰峰执法平台简易案件程序板块 pad端
yang
2022-10-17 4107256a8d1fa9a2db0969122bfc760994b12421
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {Message } from 'element-ui'
let messageInstance= null;
const rewriteMessage = (options) => {
  console.log(options,'option')
  if(messageInstance) {
    messageInstance.close()
  }
  messageInstance= Message(options)
}
['error','success','info','warning'].forEach(type => {
  rewriteMessage [type] = options => {
    if(typeof options === 'string') {
      options = {
        message:options
      }
    }
    options.type = type
    return rewriteMessage (options)
  }
})
//错误提示中使用
export default function handleError(data){
  console.log(data,'data===')
  if(data instanceof Error){
    rewriteMessage.error(data.message)
  }else if(typeof data === 'string'){
    rewriteMessage.error(data)
  }else{
    rewriteMessage.error(data.data.msg)
  }
  return window.Promise.reject(data)
 
}