import React from 'react'; import Notification from 'rc-notification'; import Icon from '../icon'; let defaultDuration = 1.5; let defaultTop; let messageInstance; let key = 1; function getMessageInstance() { messageInstance = messageInstance || Notification.newInstance({ prefixCls: 'ant-message', transitionName: 'move-up', style: { defaultTop }, // 覆盖原来的样式 }); return messageInstance; } function notice(content, duration = defaultDuration, type, onClose) { let iconClass = ({ info: 'ant-message-info', success: 'ant-message-success', error: 'ant-message-error', warn: 'ant-message-warn', loading: 'ant-message-loading' })[type]; let iconType = ({ info: 'info-circle', success: 'check-circle', error: 'exclamation-circle', warn: 'exclamation-circle', loading: 'loading' })[type]; let instance = getMessageInstance(); instance.notice({ key, duration, style: {}, content: