1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import 'kit_utils/lib/format';
import React, { forwardRef, useEffect, useRef, useState } from 'react';
import { params } from 'kit_utils';
import { connect } from 'react-redux';
import { useHistory, withRouter } from '@wisdom-utils/runtime';
import { actionCreators } from '@/containers/App/store';
import LoginAction from './login';
const Login = forwardRef((props, _ref) => {
const history = useHistory();
const [action, setAction] = useState(
() => new LoginAction(Object.assign({}, props, {history}), () => {}, true),
);
useEffect(() => {
action.globalConfig = props.global;
}, [props.global]);
useEffect(() => {
action &&
action.events.on('loginSuccess', event => {
//http://127.0.0.1:8080/civbase/civweb4/
// props.updateConfig(Object.assign({}, props.global, {
// homepage: params.getParams('redirect')
// }));
// props.history.push('/' + params.getParams('redirect'))
props.history.push(`/?client=${props.global.client}`);
window.share.event.emit('triggerMicro', props.global);
});
}, [props.globalConfig && props.globalConfig.userInfo])
// action &&
// action.events.on('loginError', event => {
// // setVisible(false);
// // setSubmitting(false);
// });
return <div>{props.children}</div>;
});
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']),
loginMode: state.getIn(['global', 'loginMode']),
});
const mapDispatchToProps = dispatch => ({
updateConfig(config) {
dispatch(actionCreators.getConfig(config));
},
createContext(data) {
dispatch(actionCreators.createContext(data));
},
updateLoginMode(mode) {
dispatch(actionCreators.changeLoginMode(mode));
},
updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index));
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(Login);