Commit b9465cdf authored by 杨思琦's avatar 杨思琦

fix: 免登修改

parent ae61ffd1
Pipeline #73658 passed with stages
...@@ -115,9 +115,9 @@ ...@@ -115,9 +115,9 @@
"@wisdom-map/arcgismap": "1.4.0-163", "@wisdom-map/arcgismap": "1.4.0-163",
"@wisdom-map/basemap": "1.1.0-24", "@wisdom-map/basemap": "1.1.0-24",
"@wisdom-map/util": "^1.0.28-0", "@wisdom-map/util": "^1.0.28-0",
"@wisdom-utils/components": "0.1.299", "@wisdom-utils/components": "0.1.300",
"@wisdom-utils/runtime": "0.0.46", "@wisdom-utils/runtime": "0.0.46",
"@wisdom-utils/utils": "0.1.339", "@wisdom-utils/utils": "0.1.340",
"animate.css": "^4.1.1", "animate.css": "^4.1.1",
"antd": "4.21.2", "antd": "4.21.2",
"compression": "1.7.4", "compression": "1.7.4",
......
...@@ -13,6 +13,7 @@ instanceRequest.transformRequestURL = function(url) { ...@@ -13,6 +13,7 @@ instanceRequest.transformRequestURL = function(url) {
'/PandaCore/Identity/AuthorizationToken', '/PandaCore/Identity/AuthorizationToken',
'/PandaEnergy/WaterSaving/download', '/PandaEnergy/WaterSaving/download',
'/PandaOMS/OMS/WebSite/GetConfig', '/PandaOMS/OMS/WebSite/GetConfig',
'/PandaOMS/OMS/CheckFreeLogin',
]; ];
if (excludeURL.includes(url)) { if (excludeURL.includes(url)) {
return url.replace(/PandaCore\/GateWay\//, ''); return url.replace(/PandaCore\/GateWay\//, '');
......
...@@ -11,6 +11,7 @@ const transformGateWay = url => { ...@@ -11,6 +11,7 @@ const transformGateWay = url => {
export const API = { export const API = {
AUTHORIZATION_TOKEN: '/PandaCore/Identity/AuthorizationToken', // 授权验证,不需要走网关加前缀 AUTHORIZATION_TOKEN: '/PandaCore/Identity/AuthorizationToken', // 授权验证,不需要走网关加前缀
CHECK_FREE_LOGIN: '/PandaOMS/OMS/CheckFreeLogin',
GET_GATEWAY_CONFIG: '/PandaOMS/OMS/HostManager/GetGateWay', GET_GATEWAY_CONFIG: '/PandaOMS/OMS/HostManager/GetGateWay',
GET_CONFIG: '/PandaOMS/OMS/WebSite/GetConfig', GET_CONFIG: '/PandaOMS/OMS/WebSite/GetConfig',
GENERATE_TOKEN: '/PandaCore/GCK/BussinessAuth/GenerateToken', GENERATE_TOKEN: '/PandaCore/GCK/BussinessAuth/GenerateToken',
...@@ -61,6 +62,11 @@ const services = { ...@@ -61,6 +62,11 @@ const services = {
method: constants.REQUEST_METHOD_GET, method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP, type: constants.REQUEST_HTTP,
}, },
checkFreeLogin: {
url: API.CHECK_FREE_LOGIN,
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
getWateWayConfig: { getWateWayConfig: {
url: API.GET_GATEWAY_CONFIG, url: API.GET_GATEWAY_CONFIG,
method: constants.REQUEST_METHOD_GET, method: constants.REQUEST_METHOD_GET,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import '@wisdom-utils/utils/lib/helpers/format'; import '@wisdom-utils/utils/lib/helpers/format';
import { params } from '@wisdom-utils/utils/lib/helpers'; import { params } from '@wisdom-utils/utils/lib/helpers';
import React, { forwardRef, useEffect, useRef, useState } from 'react'; import React, { forwardRef, useEffect, useRef, useState } from 'react';
import { message } from 'antd';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { useHistory } from '@wisdom-utils/runtime'; import { useHistory } from '@wisdom-utils/runtime';
import { actionCreators } from '@/containers/App/store'; import { actionCreators } from '@/containers/App/store';
...@@ -23,6 +24,11 @@ const Login = forwardRef((props, _ref) => { ...@@ -23,6 +24,11 @@ const Login = forwardRef((props, _ref) => {
return param ? decodeURIComponent(escape(param)) : null; return param ? decodeURIComponent(escape(param)) : null;
}); });
const [authCode] = useState(() => {
const param = params.getParams('authCode')?.replaceAll(';', '&');
return param ? decodeURIComponent(escape(param)) : null;
});
// 需要在 GetGateWay 和 GetConfig 之后再执行登录。避免信息错落乱 // 需要在 GetGateWay 和 GetConfig 之后再执行登录。避免信息错落乱
const hasLogin = useRef(); const hasLogin = useRef();
useEffect(() => { useEffect(() => {
...@@ -34,40 +40,56 @@ const Login = forwardRef((props, _ref) => { ...@@ -34,40 +40,56 @@ const Login = forwardRef((props, _ref) => {
hasLogin.current !== true && hasLogin.current !== true &&
window.hasLogin !== true window.hasLogin !== true
) { ) {
hasLogin.current = true; appService
window.hasLogin = true; .checkFreeLogin({
if (window.globalConfig && window.globalConfig.hasGateWay) { token,
appService authCode,
.authorizationToken({ })
loginName: token, .then(response => {
type: 'token', if (response?.data) {
generateType: params.getParams('generateType') || '', hasLogin.current = true;
}) window.hasLogin = true;
.then(res => { if (window.globalConfig && window.globalConfig.hasGateWay) {
if (res.code === 0) { appService
const { data } = res; .authorizationToken({
props.updateConfig && loginName: token,
props.updateConfig( type: 'token',
Object.assign({}, window.globalConfig, { generateType: params.getParams('generateType') || '',
access_token: data.access_token, })
token: data.user_token, .then(res => {
}), if (res.code === 0) {
); const { data } = res;
return data; props.updateConfig &&
props.updateConfig(
Object.assign({}, window.globalConfig, {
access_token: data.access_token,
token: data.user_token,
}),
);
return data;
}
message.error({
duration: 3,
content: `授权失败:${res.msg}`,
});
action && action.events.emit('loginError', res.msg);
return Promise.reject(res);
})
.then(res => {
action.transformLoginHander(res, false);
});
} else {
action.init();
} }
message.error({ return response?.data;
duration: 3, }
content: `授权失败:${res.msg}`, message.error({
}); duration: 3,
action && action.events.emit('loginError', res.msg); content: `授权失败`,
return Promise.reject(res);
})
.then(res => {
action.transformLoginHander(res, false);
}); });
} else { action && action.events.emit('loginError', '授权失败');
action.init(); return Promise.reject(response);
} });
} }
}, [action, action.globalConfig, props.global]); }, [action, action.globalConfig, props.global]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment