Browse Source

免密

master
wenlele 2 years ago
parent
commit
dc0a2e17c9
  1. 1
      web/client/src/layout/actions/global.js
  2. 27
      web/client/src/layout/containers/layout/index.jsx
  3. 2
      web/client/src/layout/reducers/global.js
  4. 6
      web/config.js
  5. 2
      web/package.json
  6. 5
      web/routes/attachment/index.js

1
web/client/src/layout/actions/global.js

@ -38,6 +38,7 @@ export function initApiRoot () {
type: INIT_API_ROOT, type: INIT_API_ROOT,
payload: { payload: {
apiRoot: res.root, apiRoot: res.root,
webPepUrl:res.webPepUrl
} }
}) })
}); });

27
web/client/src/layout/containers/layout/index.jsx

@ -34,7 +34,7 @@ let requestlogout = false;
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;//退redirectToLoginwindow.location.hrefmessage.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,
}; };
} }

2
web/client/src/layout/reducers/global.js

@ -11,6 +11,7 @@ function global (state = {
clientHeight: 768, clientHeight: 768,
clientWidth: 1024, clientWidth: 1024,
apiRoot: '', apiRoot: '',
webPepUrl: ''
}, action) { }, action) {
const payload = action.payload; const payload = action.payload;
switch (action.type) { switch (action.type) {
@ -30,6 +31,7 @@ function global (state = {
case INIT_API_ROOT: case INIT_API_ROOT:
return Immutable.fromJS(state).merge({ return Immutable.fromJS(state).merge({
apiRoot: payload.apiRoot, apiRoot: payload.apiRoot,
webPepUrl: payload.webPepUrl
}).toJS(); }).toJS();
default: default:
return state; return state;

6
web/config.js

@ -13,6 +13,8 @@ args.option(['p', 'port'], '启动端口');
args.option(['u', 'api-url'], 'webapi的URL'); args.option(['u', 'api-url'], 'webapi的URL');
args.option('apiHrUrl', 'webapi的URL 外网可访问'); args.option('apiHrUrl', 'webapi的URL 外网可访问');
args.option(['d', 'domain'], 'web domain'); 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_URL = process.env.API_URL || flags.apiUrl;
const API_DC_URL = process.env.API_DC_URL || flags.apiHrUrl; const API_DC_URL = process.env.API_DC_URL || flags.apiHrUrl;
const FS_REPORT_DOMAIN = process.FS_REPORT_DOMAIN || flags.domain; 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; const ANXINCLOUD_QINIU_AK = process.env.ANXINCLOUD_QINIU_ACCESSKEY || flags.qnak;
@ -80,7 +83,8 @@ const product = {
service: { service: {
url: ANXINCLOUD_PM_SERVICES url: ANXINCLOUD_PM_SERVICES
}, },
domain: FS_REPORT_DOMAIN domain: FS_REPORT_DOMAIN,
webPepUrl: WEB_PEP_URL
} }
}, { }, {
entry: require('./client').entry,// 静态信息 entry: require('./client').entry,// 静态信息

2
web/package.json

@ -7,7 +7,7 @@
"test": "mocha", "test": "mocha",
"start-vite": "cross-env NODE_ENV=developmentVite npm run start-params", "start-vite": "cross-env NODE_ENV=developmentVite npm run start-params",
"start": "cross-env NODE_ENV=development 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", "deploy": "export NODE_ENV=production&& npm run build && node server",
"build-dev": "cross-env NODE_ENV=development&&webpack --config webpack.config.js", "build-dev": "cross-env NODE_ENV=development&&webpack --config webpack.config.js",
"build": "cross-env NODE_ENV=production&&webpack --config webpack.config.prod.js" "build": "cross-env NODE_ENV=production&&webpack --config webpack.config.prod.js"

5
web/routes/attachment/index.js

@ -20,12 +20,13 @@ module.exports = {
entry: function (app, router, opts) { entry: function (app, router, opts) {
const getApiRoot = async function (ctx) { const getApiRoot = async function (ctx) {
const { apiUrl,domain } = opts; const { apiUrl, domain, webPepUrl } = opts;
ctx.status = 200; ctx.status = 200;
ctx.body = { ctx.body = {
root: apiUrl, root: apiUrl,
domain:domain domain: domain,
webPepUrl
}; };
}; };

Loading…
Cancel
Save