yapi/client/reducer/middlewares/message.js
2017-08-08 10:07:55 +08:00

17 lines
504 B
JavaScript

import process from 'process';
import { Message } from 'antd';
export default () => next => action => {
if (process.browser) {
if (action.error) {
Message.error('服务器错误');
} else if (action.payload && action.payload.res === false) {
const hasChinese = /[\u4E00-\u9FFF]+/g.test(action.payload.message);
const message = hasChinese ? action.payload.message : '服务器错误';
Message.error(message);
}
return next(action);
}
return next(action);
};