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

fix: 免登修改

parent ae61ffd1
Pipeline #73658 passed with stages
......@@ -115,9 +115,9 @@
"@wisdom-map/arcgismap": "1.4.0-163",
"@wisdom-map/basemap": "1.1.0-24",
"@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/utils": "0.1.339",
"@wisdom-utils/utils": "0.1.340",
"animate.css": "^4.1.1",
"antd": "4.21.2",
"compression": "1.7.4",
......
......@@ -13,6 +13,7 @@ instanceRequest.transformRequestURL = function(url) {
'/PandaCore/Identity/AuthorizationToken',
'/PandaEnergy/WaterSaving/download',
'/PandaOMS/OMS/WebSite/GetConfig',
'/PandaOMS/OMS/CheckFreeLogin',
];
if (excludeURL.includes(url)) {
return url.replace(/PandaCore\/GateWay\//, '');
......
......@@ -11,6 +11,7 @@ const transformGateWay = url => {
export const API = {
AUTHORIZATION_TOKEN: '/PandaCore/Identity/AuthorizationToken', // 授权验证,不需要走网关加前缀
CHECK_FREE_LOGIN: '/PandaOMS/OMS/CheckFreeLogin',
GET_GATEWAY_CONFIG: '/PandaOMS/OMS/HostManager/GetGateWay',
GET_CONFIG: '/PandaOMS/OMS/WebSite/GetConfig',
GENERATE_TOKEN: '/PandaCore/GCK/BussinessAuth/GenerateToken',
......@@ -61,6 +62,11 @@ const services = {
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
checkFreeLogin: {
url: API.CHECK_FREE_LOGIN,
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
getWateWayConfig: {
url: API.GET_GATEWAY_CONFIG,
method: constants.REQUEST_METHOD_GET,
......
......@@ -5,6 +5,7 @@
import '@wisdom-utils/utils/lib/helpers/format';
import { params } from '@wisdom-utils/utils/lib/helpers';
import React, { forwardRef, useEffect, useRef, useState } from 'react';
import { message } from 'antd';
import { connect } from 'react-redux';
import { useHistory } from '@wisdom-utils/runtime';
import { actionCreators } from '@/containers/App/store';
......@@ -23,6 +24,11 @@ const Login = forwardRef((props, _ref) => {
return param ? decodeURIComponent(escape(param)) : null;
});
const [authCode] = useState(() => {
const param = params.getParams('authCode')?.replaceAll(';', '&');
return param ? decodeURIComponent(escape(param)) : null;
});
// 需要在 GetGateWay 和 GetConfig 之后再执行登录。避免信息错落乱
const hasLogin = useRef();
useEffect(() => {
......@@ -34,6 +40,13 @@ const Login = forwardRef((props, _ref) => {
hasLogin.current !== true &&
window.hasLogin !== true
) {
appService
.checkFreeLogin({
token,
authCode,
})
.then(response => {
if (response?.data) {
hasLogin.current = true;
window.hasLogin = true;
if (window.globalConfig && window.globalConfig.hasGateWay) {
......@@ -68,6 +81,15 @@ const Login = forwardRef((props, _ref) => {
} else {
action.init();
}
return response?.data;
}
message.error({
duration: 3,
content: `授权失败`,
});
action && action.events.emit('loginError', '授权失败');
return Promise.reject(response);
});
}
}, [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