From 435951f6c5efc836870a78c9d8dec0c3cb7c5230 Mon Sep 17 00:00:00 2001 From: sin <2943460818@qq.com> Date: Mon, 11 Mar 2019 22:45:30 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E6=B7=BB=E5=8A=A0=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E9=87=8D=E5=AE=9A=E5=90=91=E7=99=BB=E9=99=86=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-web/src/utils/request.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/admin-web/src/utils/request.js b/admin-web/src/utils/request.js index f1b7d5b8f..d991a914e 100644 --- a/admin-web/src/utils/request.js +++ b/admin-web/src/utils/request.js @@ -4,6 +4,7 @@ import router from 'umi/router'; import hash from 'hash.js'; import { isAntdPro } from './utils'; import { getLoginToken } from './cache'; +import { setAuthority } from './authority'; const codeMessage = { 200: '服务器成功返回请求的数据。', @@ -23,6 +24,14 @@ const codeMessage = { 504: '网关超时。', }; +// 需要调整 login 界面的 code +const redirectLoginCode = { + 1002001011: true, + 1002001012: true, + 1002001013: true, + 1002001015: true, +}; + function checkStatus(response) { if (response.status >= 200 && response.status < 300) { return response; @@ -43,11 +52,17 @@ function checkCode(result) { if (result.code === undefined || result.code === 0) { return result; } - notification.warning({ message: `请求错误 ${result.code}`, description: result.message, }); + + // 重定向到登录界面 + if (redirectLoginCode[result.code]) { + setAuthority(''); + window.location.reload(); + } + const error = new Error(result.message); error.result = result; throw error;