diff --git a/web/client/src/layout/actions/global.js b/web/client/src/layout/actions/global.js index 4d019aa..4bbf599 100644 --- a/web/client/src/layout/actions/global.js +++ b/web/client/src/layout/actions/global.js @@ -38,6 +38,7 @@ export function initApiRoot () { type: INIT_API_ROOT, payload: { apiRoot: res.root, + webPepUrl:res.webPepUrl } }) }); diff --git a/web/client/src/layout/containers/layout/index.jsx b/web/client/src/layout/containers/layout/index.jsx index 37cb814..531d5bc 100644 --- a/web/client/src/layout/containers/layout/index.jsx +++ b/web/client/src/layout/containers/layout/index.jsx @@ -31,11 +31,12 @@ NProgress.configure({ let scrollbar let requestUser = true +let requestlogout = false; // const location111 = useLocation(); const LayoutContainer = props => { const { dispatch, actions, msg, user, copyright, children, sections, clientWidth, clientHeight, - location, match, routes, history, socket,apiRoot + location, match, routes, history, socket, apiRoot, webPepUrl } = props const [collapsed, setCollapsed] = useState(false) @@ -217,34 +218,18 @@ const LayoutContainer = props => { 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); + window.location.href = `${webPepUrl}/signin` } }, error => { - redirectToLogin(true); + window.location.href = `${webPepUrl}/signin` }) }, error => { 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 使用测试 @@ -371,6 +356,7 @@ function mapStateToProps (state) { user: auth.user, socket: webSocket.socket, apiRoot: global.apiRoot, + webPepUrl: global.webPepUrl }; } diff --git a/web/client/src/layout/reducers/global.js b/web/client/src/layout/reducers/global.js index 8187eb7..ed3552e 100644 --- a/web/client/src/layout/reducers/global.js +++ b/web/client/src/layout/reducers/global.js @@ -11,6 +11,7 @@ function global (state = { clientHeight: 768, clientWidth: 1024, apiRoot: '', + webPepUrl:'' }, action) { const payload = action.payload; switch (action.type) { @@ -30,6 +31,7 @@ function global (state = { case INIT_API_ROOT: return Immutable.fromJS(state).merge({ apiRoot: payload.apiRoot, + webPepUrl: payload.webPepUrl, }).toJS(); default: return state; diff --git a/web/config.js b/web/config.js index a7daada..232fca0 100644 --- a/web/config.js +++ b/web/config.js @@ -14,6 +14,7 @@ args.option(['p', 'port'], '启动端口'); args.option(['u', 'api-url'], 'webapi的URL'); args.option('apiHrUrl', 'webapi的URL 外网可访问'); args.option('apiEmisUrl', '企业管理 api'); +args.option('webPepUrl', '企业管理 web'); args.option(['d', 'domain'], 'web domain'); @@ -34,6 +35,7 @@ const API_URL = process.env.API_URL || flags.apiUrl; const API_HR_URL = process.env.API_HR_URL || flags.apiHrUrl; const FS_HR_DOMAIN = process.env.FS_HR_DOMAIN || flags.domain; const API_EMIS_URL = process.env.API_EMIS_URL || flags.apiEmisUrl; +const WEB_PEP_URL = process.env.WEB_PEP_URL || flags.webPepUrl; // 七牛 const ANXINCLOUD_QINIU_AK = process.env.ANXINCLOUD_QINIU_ACCESSKEY || flags.qnak; @@ -89,6 +91,7 @@ const product = { weekly: ANXINCLOUD_WEEKLY_SERVICES }, domain: FS_HR_DOMAIN, + webPepUrl: WEB_PEP_URL } }, { entry: require('./middlewares/proxy').entry, diff --git a/web/package.json b/web/package.json index 2cd5e61..6117917 100644 --- a/web/package.json +++ b/web/package.json @@ -7,7 +7,7 @@ "test": "mocha", "start-vite": "cross-env NODE_ENV=developmentVite npm run start-params", "start": "cross-env NODE_ENV=development npm run start-params", - "start-params": "node server -p 5700 -u http://localhost:4700 --apiHrUrl http://localhost:4700 -d localhost --apiEmisUrl http://localhost:4000 --qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5 --qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa --qnbkt dev-hr --qndmn http://rjkwed13l.hn-bkt.clouddn.com --wkys http://10.8.30.109:14000", + "start-params": "node server -p 5700 -u http://localhost:4700 --apiHrUrl http://localhost:4700 -d localhost --webPepUrl http://localhost:5300 --apiEmisUrl http://localhost:4000 --qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5 --qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa --qnbkt dev-hr --qndmn http://rjkwed13l.hn-bkt.clouddn.com --wkys http://10.8.30.109:14000", "deploy": "export NODE_ENV=production&& npm run build && node server", "build-dev": "cross-env NODE_ENV=development&&webpack --config webpack.config.js", "build": "cross-env NODE_ENV=production&&webpack --config webpack.config.prod.js" diff --git a/web/routes/attachment/index.js b/web/routes/attachment/index.js index d0876f7..efd79d0 100644 --- a/web/routes/attachment/index.js +++ b/web/routes/attachment/index.js @@ -20,11 +20,12 @@ module.exports = { entry: function (app, router, opts) { const getApiRoot = async function (ctx) { - const { apiUrl } = opts; + const { apiUrl, webPepUrl } = opts; ctx.status = 200; ctx.body = { root: apiUrl, + webPepUrl }; };