yangfeng
2023-07-10 8e7cd003414ea4ca8f42fb3171de18f8839ece17
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
34
35
36
// import { wsCache } from "@/common/untils/wsCache"
import { Message } from "element-ui"
import i18n from "@/i18n"
const durationTime = 2000
 
export function responseHandler(res) {
  const status = res.data.status.toString()
  // if (status.toString() === ) {
 
  // }
  const message = res.data.message || i18n.t(`businessStatusCode.${status}`)
  Message({
    message: message,
    offset: 70,
    type: "error",
    duration: durationTime
  })
}
 
export function errorResponseHandler(error) {
  let msg = ""
  if (error && error.response && error.response.status) {
    const status = error.response.status.toString()
    msg = error.response.message || i18n.t(`statusCode.${status}`)
  } else if (error.message === "Cancel") {
    return
  } else {
    msg = i18n.t(`statusCode.netErr`)
  }
  Message({
    message: msg,
    offset: 70,
    type: "error",
    duration: durationTime
  })
}