|
@ -33,8 +33,8 @@ let requestlogout = false; |
|
|
// const location111 = useLocation(); |
|
|
// const location111 = useLocation(); |
|
|
const LayoutContainer = props => { |
|
|
const LayoutContainer = props => { |
|
|
const { |
|
|
const { |
|
|
dispatch,actions, msg, user, copyright, children, sections, clientWidth, clientHeight, |
|
|
dispatch, actions, msg, user, copyright, children, sections, clientWidth, clientHeight, |
|
|
location, match, routes, history, socket, apiRoot |
|
|
location, match, routes, history, socket, apiRoot, webPepUrl |
|
|
} = props |
|
|
} = props |
|
|
const [collapsed, setCollapsed] = useState(false) |
|
|
const [collapsed, setCollapsed] = useState(false) |
|
|
|
|
|
|
|
@ -206,10 +206,8 @@ const LayoutContainer = props => { |
|
|
const getUserInfoByToken = () => { |
|
|
const getUserInfoByToken = () => { |
|
|
if (requestUser) { |
|
|
if (requestUser) { |
|
|
requestUser = false; |
|
|
requestUser = false; |
|
|
console.log(RouteTable.apiRoot); |
|
|
|
|
|
RouteRequest.get(RouteTable.apiRoot).then(res => { |
|
|
RouteRequest.get(RouteTable.apiRoot).then(res => { |
|
|
let token = Cookie.get('pepToken', { domain: res.domain }); |
|
|
let token = Cookie.get('pepToken', { domain: res.domain }); |
|
|
console.log(token); |
|
|
|
|
|
dispatch(login({ token })).then(res => { |
|
|
dispatch(login({ token })).then(res => { |
|
|
console.log(res); |
|
|
console.log(res); |
|
|
if (res.type == 'LOGIN_SUCCESS') { |
|
|
if (res.type == 'LOGIN_SUCCESS') { |
|
@ -220,34 +218,18 @@ const LayoutContainer = props => { |
|
|
localStorage.setItem('word', JSON.stringify('')) //系统登录代码时候存的,不清楚意义 |
|
|
localStorage.setItem('word', JSON.stringify('')) //系统登录代码时候存的,不清楚意义 |
|
|
dispatch(actions.layout.initWebSocket({ ioUrl: apiRoot, token: data.token, hrUserId: data.hrUserInfo && hrUserInfo.id })) |
|
|
dispatch(actions.layout.initWebSocket({ ioUrl: apiRoot, token: data.token, hrUserId: data.hrUserInfo && hrUserInfo.id })) |
|
|
} else { |
|
|
} else { |
|
|
redirectToLogin(true); |
|
|
window.location.href = `${webPepUrl}/signin` |
|
|
} |
|
|
} |
|
|
}, error => { |
|
|
}, error => { |
|
|
redirectToLogin(true); |
|
|
window.location.href = `${webPepUrl}/signin` |
|
|
}) |
|
|
}) |
|
|
}, error => { |
|
|
}, error => { |
|
|
message.error('鉴权失败', 5); |
|
|
message.error('鉴权失败', 5); |
|
|
redirectToLogin(true); |
|
|
window.location.href = `${webPepUrl}/signin` |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const redirectToLogin = (toLogin = false) => { |
|
|
|
|
|
//重定位至大平台的登录页 |
|
|
|
|
|
if (!requestlogout) { |
|
|
|
|
|
requestlogout = true;//目的执行一遍。退出登录后,redirectToLogin执行两遍,注释window.location.href,可message.warning验证 |
|
|
|
|
|
RouteRequest.get(RouteTable.getPepWebUrl).then(res => { |
|
|
|
|
|
if (res.url) { |
|
|
|
|
|
if (toLogin) { |
|
|
|
|
|
window.location.href = `${res.url}/signin`; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
window.location.href = `${res.url}/signin?isLogout=true`; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// websocket 使用测试 |
|
|
// websocket 使用测试 |
|
@ -374,6 +356,7 @@ function mapStateToProps (state) { |
|
|
user: auth.user, |
|
|
user: auth.user, |
|
|
socket: webSocket.socket, |
|
|
socket: webSocket.socket, |
|
|
apiRoot: global.apiRoot, |
|
|
apiRoot: global.apiRoot, |
|
|
|
|
|
webPepUrl: global.webPepUrl, |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|