wlzboy
2026-04-01 c459808efab29dc1b8439fbb90556bdb16f4c88b
app/utils/request.js
@@ -39,6 +39,10 @@
        }
        const code = res.data.code || 200
        const msg = errorCode[code] || res.data.msg || errorCode['default']
        // 特殊处理:checkDuplicate 接口即使返回错误码也要进入 then 分支
        const isCheckDuplicateApi = config.url && config.url.includes('/task/checkDuplicate')
        if (code === 401) {
          showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
            if (res.confirm) {
@@ -49,10 +53,26 @@
          })
          reject('无效的会话,或者会话已过期,请重新登录。')
        } else if (code === 500) {
          toast(msg)
          // checkDuplicate 接口不显示 toast,让业务代码自己处理
          // if (!isCheckDuplicateApi) {
          //   toast(msg)
          // }
          // checkDuplicate 接口返回完整响应,不 reject
          if (isCheckDuplicateApi) {
            resolve(res.data)
            return
          }
          reject('500')
        } else if (code !== 200) {
          toast(msg)
          // checkDuplicate 接口不显示 toast,让业务代码自己处理
          // if (!isCheckDuplicateApi) {
          //   toast(msg)
          // }
          // checkDuplicate 接口返回完整响应,不 reject
          if (isCheckDuplicateApi) {
            resolve(res.data)
            return
          }
          reject(code)
        }
        resolve(res.data)
@@ -66,7 +86,7 @@
        } else if (message.includes('Request failed with status code')) {
          message = '系统接口' + message.substr(message.length - 3) + '异常'
        }
        toast(message)
        // toast(message)
        reject(error)
      })
  })