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 37e2634..31a1186 100644 --- a/web/client/src/layout/containers/layout/index.jsx +++ b/web/client/src/layout/containers/layout/index.jsx @@ -33,8 +33,8 @@ 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 + dispatch, actions, msg, user, copyright, children, sections, clientWidth, clientHeight, + location, match, routes, history, socket, apiRoot, webPepUrl } = props const [collapsed, setCollapsed] = useState(false) @@ -206,10 +206,8 @@ const LayoutContainer = props => { const getUserInfoByToken = () => { if (requestUser) { requestUser = false; - console.log(RouteTable.apiRoot); RouteRequest.get(RouteTable.apiRoot).then(res => { let token = Cookie.get('pepToken', { domain: res.domain }); - console.log(token); dispatch(login({ token })).then(res => { console.log(res); if (res.type == 'LOGIN_SUCCESS') { @@ -220,34 +218,18 @@ const LayoutContainer = props => { localStorage.setItem('word', JSON.stringify('')) //系统登录代码时候存的,不清楚意义 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 使用测试 @@ -374,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..4f52077 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 1e24a34..cc4aa5b 100644 --- a/web/config.js +++ b/web/config.js @@ -13,6 +13,8 @@ args.option(['p', 'port'], '启动端口'); args.option(['u', 'api-url'], 'webapi的URL'); args.option('apiHrUrl', 'webapi的URL 外网可访问'); args.option(['d', 'domain'], 'web domain'); +args.option('webPepUrl', '企业管理 web'); + // 七牛 @@ -27,6 +29,7 @@ const flags = args.parse(process.argv); const API_URL = process.env.API_URL || flags.apiUrl; const API_DC_URL = process.env.API_DC_URL || flags.apiHrUrl; const FS_REPORT_DOMAIN = process.FS_REPORT_DOMAIN || flags.domain; +const WEB_PEP_URL = process.env.WEB_PEP_URL || flags.webPepUrl; // 七牛 const ANXINCLOUD_QINIU_AK = process.env.ANXINCLOUD_QINIU_ACCESSKEY || flags.qnak; @@ -80,7 +83,8 @@ const product = { service: { url: ANXINCLOUD_PM_SERVICES }, - domain: FS_REPORT_DOMAIN + domain: FS_REPORT_DOMAIN, + webPepUrl: WEB_PEP_URL } }, { entry: require('./client').entry,// 静态信息 diff --git a/web/package.json b/web/package.json index c7ed003..c66ff68 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 --qnak 5XrM4wEB9YU6RQwT64sPzzE6cYFKZgssdP5Kj3uu --qnsk w6j2ixR_i-aelc6I7S3HotKIX-ukMzcKmDfH6-M5 --qnbkt pep-process-report --qndmn https://pepsource.anxinyun.cn --pmrs 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 --qnak 5XrM4wEB9YU6RQwT64sPzzE6cYFKZgssdP5Kj3uu --qnsk w6j2ixR_i-aelc6I7S3HotKIX-ukMzcKmDfH6-M5 --qnbkt pep-process-report --qndmn https://pepsource.anxinyun.cn --pmrs 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 326d914..7e6f1b4 100644 --- a/web/routes/attachment/index.js +++ b/web/routes/attachment/index.js @@ -20,12 +20,13 @@ module.exports = { entry: function (app, router, opts) { const getApiRoot = async function (ctx) { - const { apiUrl,domain } = opts; + const { apiUrl, domain, webPepUrl } = opts; ctx.status = 200; ctx.body = { root: apiUrl, - domain:domain + domain: domain, + webPepUrl }; };