nsn-comp
Version:
NSN核心组件
62 lines (52 loc) • 2.18 kB
JavaScript
import "antd/es/modal/style";
import _Modal from "antd/es/modal";
import "antd/es/message/style";
import _message from "antd/es/message";
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { ExclamationCircleOutlined } from '@ant-design/icons';
import { NConst } from 'nsn-const';
import { NLocale } from 'nsn-util';
import React from 'react';
import { history } from 'umi';
var logout = function logout(dispatch) {
_message.loading(NLocale.getText('layout.logout.loading'));
if (dispatch) {
dispatch({
type: 'nsn_auth/logout',
callback: function callback(_ref) {
var success = _ref.success,
restProp = _objectWithoutProperties(_ref, ["success"]);
_message.destroy();
if (success) {
history.replace(NConst.URL_LOGIN);
} else {
_message.error(NLocale.getMsg(restProp));
}
}
});
}
};
/**
* 注销确认
* @param dispatch 请求转发
* @param silent 是否再次确认
*/
var confirm = function confirm(dispatch, silent) {
if (silent) {
logout(dispatch);
} else {
_Modal.confirm({
title: NLocale.getText('layout.logout.content'),
okText: NLocale.getText('operation.confirm'),
icon: React.createElement(ExclamationCircleOutlined, null),
onOk: function onOk() {
return logout(dispatch);
}
});
}
};
var Logout = {
confirm: confirm
};
export { Logout };