|
@ -10,6 +10,10 @@ import { resize } from '../../actions/global'; |
|
|
import * as NProgress from 'nprogress'; |
|
|
import * as NProgress from 'nprogress'; |
|
|
import PerfectScrollbar from 'perfect-scrollbar'; |
|
|
import PerfectScrollbar from 'perfect-scrollbar'; |
|
|
import { useLocation } from "react-router"; |
|
|
import { useLocation } from "react-router"; |
|
|
|
|
|
import { RouteTable } from '$utils'; |
|
|
|
|
|
import { RouteRequest } from '@peace/utils'; |
|
|
|
|
|
import Cookie from 'js-cookie'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NProgress.configure({ |
|
|
NProgress.configure({ |
|
|
template: ` |
|
|
template: ` |
|
@ -23,6 +27,7 @@ NProgress.configure({ |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
let scrollbar |
|
|
let scrollbar |
|
|
|
|
|
let requestUser = true |
|
|
// const location111 = useLocation(); |
|
|
// const location111 = useLocation(); |
|
|
const LayoutContainer = props => { |
|
|
const LayoutContainer = props => { |
|
|
const { |
|
|
const { |
|
@ -165,7 +170,8 @@ const LayoutContainer = props => { |
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
NProgress.done(); |
|
|
NProgress.done(); |
|
|
if ((!user || !user.authorized)) { |
|
|
if ((!user || !user.authorized)) { |
|
|
history.push('/signin'); |
|
|
// history.push('/signin'); |
|
|
|
|
|
getUserInfoByToken() |
|
|
} |
|
|
} |
|
|
if (msg) { |
|
|
if (msg) { |
|
|
if (msg.done) { |
|
|
if (msg.done) { |
|
@ -195,6 +201,60 @@ const LayoutContainer = props => { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const getUserInfoByToken = () => { |
|
|
|
|
|
if (requestUser) { |
|
|
|
|
|
requestUser = false; |
|
|
|
|
|
RouteRequest.get(RouteTable.getDomain).then(res => { |
|
|
|
|
|
console.log(res); |
|
|
|
|
|
let token = Cookie.get('pepToken', { domain: res.root }); |
|
|
|
|
|
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)) |
|
|
|
|
|
dispatch(actions.layout.initWebSocket({ ioUrl: apiRoot, token: data.token, hrUserId: data.hrUserInfo && hrUserInfo.id })) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// 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); |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 使用测试 |
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|