Browse Source

免密

master
wenlele 2 years ago
parent
commit
dc0a2e17c9
  1. 1
      web/client/src/layout/actions/global.js
  2. 29
      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,
payload: {
apiRoot: res.root,
webPepUrl:res.webPepUrl
}
})
});

29
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;//退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 使
@ -374,6 +356,7 @@ function mapStateToProps (state) {
user: auth.user,
socket: webSocket.socket,
apiRoot: global.apiRoot,
webPepUrl: global.webPepUrl,
};
}

2
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;

6
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,// 静态信息

2
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"

5
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
};
};

Loading…
Cancel
Save