From 6470e034d19306b964a961a1c1f157ec38648173 Mon Sep 17 00:00:00 2001 From: nikogu <644506165@qq.com> Date: Mon, 18 Sep 2017 14:41:42 +0800 Subject: [PATCH] close: https://github.com/ant-design/test2/issues/11 --- src/components/GlobalFooter/index.less | 3 ++- src/utils/request.js | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/components/GlobalFooter/index.less b/src/components/GlobalFooter/index.less index 2483aa3f..df711c0b 100644 --- a/src/components/GlobalFooter/index.less +++ b/src/components/GlobalFooter/index.less @@ -1,7 +1,8 @@ @import "~antd/lib/style/themes/default.less"; .globalFooter { - margin: 32px 28px 16px; + padding: 16px; + margin: 32px 0 16px 0; text-align: center; .links { diff --git a/src/utils/request.js b/src/utils/request.js index 4d62c87f..5bc56370 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,13 +1,28 @@ import fetch from 'dva/fetch'; +import { notification } from 'antd'; function checkStatus(response) { if (response.status >= 200 && response.status < 300) { return response; } - const error = new Error(response.statusText); - error.response = response; - throw error; + return response.json().then((result) => { + if (result.code) { + notification.error({ + message: result.name, + description: result.message, + }); + } + if (result.stack) { + notification.error({ + message: '请求错误', + description: result.message, + }); + } + const error = new Error(result.message); + error.response = response; + throw error; + }); } /** -- GitLab