|
|
@ -13,6 +13,9 @@ import { useLocation } from "react-router"; |
|
|
|
import { RouteTable } from '$utils'; |
|
|
|
import { RouteRequest } from '@peace/utils'; |
|
|
|
import Cookie from 'js-cookie'; |
|
|
|
import { login, LOGIN_SUCCESS } from '../../../sections/auth/actions/auth'; |
|
|
|
import { error } from 'webpack-dev-server/lib/utils/colors'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NProgress.configure({ |
|
|
@ -31,8 +34,8 @@ let requestUser = true |
|
|
|
// const location111 = useLocation(); |
|
|
|
const LayoutContainer = props => { |
|
|
|
const { |
|
|
|
dispatch, msg, user, copyright, children, sections, clientWidth, clientHeight, |
|
|
|
location, match, routes, history, socket, |
|
|
|
dispatch, actions, msg, user, copyright, children, sections, clientWidth, clientHeight, |
|
|
|
location, match, routes, history, socket,apiRoot |
|
|
|
} = props |
|
|
|
const [collapsed, setCollapsed] = useState(false) |
|
|
|
|
|
|
@ -205,32 +208,20 @@ const LayoutContainer = props => { |
|
|
|
if (requestUser) { |
|
|
|
requestUser = false; |
|
|
|
RouteRequest.get(RouteTable.getDomain).then(res => { |
|
|
|
console.log(res); |
|
|
|
let token = Cookie.get('pepToken', { domain: res.root }); |
|
|
|
dispatch(login({ token })).then(res => { |
|
|
|
if (res.type == 'LOGIN_SUCCESS') { |
|
|
|
const data = res.payload?.user || {} |
|
|
|
history.push('/humanAffairs/archivesCenter/personnelArchives/personnelFiles') |
|
|
|
|
|
|
|
dispatch(login(values.username, values.password)).then(res => { |
|
|
|
const data = res.payload.user |
|
|
|
localStorage.setItem('word', JSON.stringify(values.password)) |
|
|
|
localStorage.setItem('poms_open_sider', JSON.stringify(["archivesCenter"])) |
|
|
|
localStorage.setItem('poms_selected_sider', JSON.stringify(["humanAffairs"])) |
|
|
|
dispatch(actions.layout.initWebSocket({ ioUrl: apiRoot, token: data.token, hrUserId: data.hrUserInfo && hrUserInfo.id })) |
|
|
|
} else { |
|
|
|
redirectToLogin(true); |
|
|
|
} |
|
|
|
}, error => { |
|
|
|
redirectToLogin(true); |
|
|
|
}) |
|
|
|
|
|
|
|
// dispatch(getUserInfoByTokenUrl(token)).then(userRes => { |
|
|
|
// if (userRes.success) { |
|
|
|
// sessionStorage.setItem('user', JSON.stringify(userRes.payload.data)); |
|
|
|
// dispatch({ |
|
|
|
// type: 'INIT_AUTH', |
|
|
|
// payload: { |
|
|
|
// user: userRes.payload.data |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// // window.location.href = window.location.href; |
|
|
|
// } else { |
|
|
|
// redirectToLogin(true); |
|
|
|
// } |
|
|
|
// }, error => { |
|
|
|
// redirectToLogin(true); |
|
|
|
// }) |
|
|
|
}, error => { |
|
|
|
message.error('鉴权失败', 5); |
|
|
|
redirectToLogin(true); |
|
|
@ -378,7 +369,8 @@ function mapStateToProps (state) { |
|
|
|
clientHeight: global.clientHeight, |
|
|
|
msg: ajaxResponse.msg, |
|
|
|
user: auth.user, |
|
|
|
socket: webSocket.socket |
|
|
|
socket: webSocket.socket, |
|
|
|
apiRoot: global.apiRoot, |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|