Commit 1b14c542 authored by 杨思琦's avatar 杨思琦

fix: 修改鉴权判定

parent fa99b894
Pipeline #79147 passed with stages
......@@ -115,9 +115,9 @@
"@wisdom-map/arcgismap": "1.4.0-193",
"@wisdom-map/basemap": "1.1.0-29",
"@wisdom-map/util": "^1.0.28-0",
"@wisdom-utils/components": "0.1.322",
"@wisdom-utils/components": "0.1.323",
"@wisdom-utils/runtime": "0.0.47",
"@wisdom-utils/utils": "0.1.362",
"@wisdom-utils/utils": "0.1.363",
"animate.css": "^4.1.1",
"antd": "4.21.2",
"compression": "1.7.4",
......
/* eslint-disable react/jsx-boolean-value */
/* eslint-disable jsx-a11y/alt-text */
/* eslint-disable prefer-destructuring */
/* eslint-disable no-return-assign */
/* eslint-disable no-shadow */
/* eslint-disable eqeqeq */
/* eslint-disable prettier/prettier */
/* eslint-disable react-hooks/rules-of-hooks */
/* eslint-disable global-require */
// @eslint-disable
import React, { Suspense, useEffect, useRef, useState } from 'react';
import React, { Suspense, useEffect, useRef, useState, useContext } from 'react';
import { Anchor, Modal, Popover, Radio, Spin } from 'antd';
import { ConfigProvider, Anchor, Modal, Popover, Radio, Spin, notification, Button } from 'antd';
import classNames from 'classnames';
import Cookies from 'js-cookie';
import _ from 'lodash';
......@@ -18,14 +27,14 @@ import BasicLayout from '@wisdom-utils/components/lib/layout/BasicLayout';
import { useHistory, useLocation } from '@wisdom-utils/runtime';
import { helpers, store, event } from '@wisdom-utils/utils';
import { Storeage as Store } from '@wisdom-utils/utils/lib/helpers';
import { defaultApp } from '@/micro';
import { appService } from '@/api';
import LoginAction from '@/pages/user/login/login';
import Loading from '../components/Loading';
import { waterMark } from '../utils/mark';
import layoutStyles from './BasicLayout.less';
import SecurityLayout from './SecurityLayout';
import Site from './Site';
import { defaultApp } from '@/micro';
import { appService } from '@/api';
import LoginAction from '@/pages/user/login/login';
const { params } = helpers;
......@@ -88,9 +97,7 @@ const OnlyFocusStations = props => {
<div className={layoutStyles.focusStations} style={{ border: 'none' }}>
<ul>
{Array.isArray(data)
? data.map(item =>
StationsItem(item, props.action, props.setVisible, props.actionRef, props.setMenuLoading),
)
? data.map(item => StationsItem(item, props.action, props.setVisible, props.actionRef, props.setMenuLoading))
: null}
</ul>
</div>
......@@ -106,7 +113,6 @@ const AllStations = props => {
useEffect(() => {
setTargetOffset(cityPane.current.clientHeight / 2);
}, []);
const handleClick = (event, link) => {
......@@ -205,11 +211,11 @@ const renderSite = ({ data, config, loading, setLoading, action, actionRef, setM
}
arrowPointAtCenter
overlayClassName={classNames(layoutStyles.stationsWrapper, layoutStyles.stationsTop)}
onVisibleChange={visible => setVisible(visible)}
onVisibleChange={value => setVisible(value)}
>
{Array.isArray(data.stations) ? (
<div className={layoutStyles.toggleSite}>
<img src={require('../assets/basic/site.png')} className={layoutStyles.site} />
<img src={require('../assets/basic/site.png')} className={layoutStyles.site} alt="" />
<span className={layoutStyles.name}>{data.currentStationName}</span>
<ArrowIcon
className={layoutStyles.arrow}
......@@ -240,12 +246,6 @@ const pickRoutes = memoized((routes, pathname, locale) => {
};
});
const transformFloatMenu = (routes, homepage) => {
const route = routes.find(route => route.path === `/${homepage}`);
console.log('route', route);
return routes.concat(route);
};
const Layout = props => {
const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${params.getParams(
'client',
......@@ -271,6 +271,8 @@ const Layout = props => {
const [visible, setVisible] = useState(false);
const [integrationLoading, setIntegrationLoading] = useState(false);
const { routeConfig = {}, matchPath } = pickRoutes(props.flatMenu, location.pathname);
const context = useContext(ConfigProvider.ConfigContext);
const prefixCls = props.prefixCls ?? context.getPrefixCls();
// useEffect(() => {
// setRouteConfig(routeConfig);
......@@ -298,19 +300,45 @@ const Layout = props => {
siteAction.setGlobalConfig(props.global);
const tk = Cookies.get('token') || props.global.token;
const isLogin = tk !== null && tk !== 'undefined' && tk !== void 0;
let client = props?.global?.client || sessionStorage.getItem('client') || null;
client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client : 'city';
// eslint-disable-next-line no-prototype-builtins
let generateType = props.global && props.global.hasOwnProperty('get') ? props.global.get('generateType') : null;
generateType =
!_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined'
? `&generateType=${generateType}`
: '';
if (!isLogin) {
let client = props?.global?.client || sessionStorage.getItem('client') || null;
client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client : 'city';
// eslint-disable-next-line no-prototype-builtins
let generateType = props.global && props.global.hasOwnProperty('get') ? props.global.get('generateType') : null;
generateType =
!_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined'
? `&generateType=${generateType}`
: '';
history.push(`/user/login?client=${client}${generateType}`, { reload: true });
props.logout();
}
}, [history, props, props.global, siteAction]);
store.on('event:unauthorized', () => {
store.off('event:unauthorized');
const key = `open${Date.now()}`;
notification.open({
description: '登录认证过期,即将跳转到登录页',
duration: null,
btn: (
<Button
className={classNames(`${prefixCls}-btn`, `${prefixCls}-btn-primary`)}
type="primary"
onClick={() => {
notification.close(key);
setTimeout(() => {
history.push(`/user/login?client=${client}${generateType}`, { reload: true });
props.logout();
})
}}>确认
</Button>
),
key,
closeIcon: <></>,
});
});
return () => {
store.off('event:unauthorized');
};
}, [history, prefixCls, props, props.global, siteAction]);
useEffect(() => {
if (
......@@ -328,6 +356,23 @@ const Layout = props => {
}
}, [cityData, cityLoading, props.global, props.global.userInfo, siteAction]);
const GetIntegrationConfig = () => {
appService
.GetIntegrationConfig({
type: '集成登录',
userId: window.globalConfig.userInfo?.OID ?? null,
isEnable: true,
})
.then(res => {
const { code, data } = res;
if (code == '0') {
setIntegrationData(data);
} else {
setIntegrationData([]);
}
})
}
useEffect(() => {
if (window?.globalConfig?.isIntegration >= 1) {
GetIntegrationConfig();
......@@ -352,7 +397,7 @@ const Layout = props => {
window.share.event.removeAllListeners('updateSite');
loginAction.events.removeListener('toggleIndustry', handleToggleIndustry);
};
}, []);
}, [loginAction.events, props]);
useEffect(() => {
const needMark = () =>
......@@ -374,24 +419,8 @@ const Layout = props => {
};
}, [props.global.isHaveMark, props.global.userInfo]);
const GetIntegrationConfig = () => {
appService
.GetIntegrationConfig({
type: '集成登录',
userId: window.globalConfig.userInfo?.OID ?? null,
isEnable: true,
})
.then(res => {
const { code, data } = res;
if (code == '0') {
setIntegrationData(data);
} else {
setIntegrationData([]);
}
})
}
const onMenuHeaderClick = event => {
//集成网站
// 集成网站
if (window.globalConfig.isIntegration > 1 || integrationData.length > 1) {
// window.qiankunIsCache = false;
history.push('/Industry');
......@@ -482,24 +511,24 @@ const Layout = props => {
return false;
};
//渲染集成站点切换弹框
// 渲染集成站点切换弹框
const renderIntegration = (inData, loginAction, props) => {
if (inData.length <= 1) {
return <></>
}
let choiceOne = inData?.find(function (a) {
const choiceOne = inData?.find(function (a) {
return a.url?.indexOf(window?.globalConfig?.client) >= 0
})
//切换集成站点
// 切换集成站点
const checkIntegration = (val, loginAction, props) => {
if (val.subType == '外链') {
if (val.paramValue == 'ticket') {
//获取临时token
// 获取临时token
appService.getTicketByToken({ token: window.globalConfig?.token }).then(res => {
if (res.code === 0) {
setVisible(false);
let url = val.url + (val.url.indexOf('?') > 0 ? '&' : '?') + val.paramName + '=' + res.data;
const url = `${val.url + (val.url.indexOf('?') > 0 ? '&' : '?') + val.paramName }=${ res.data}`;
window.open(url, "_blank");
} else {
setVisible(false);
......@@ -512,11 +541,11 @@ const Layout = props => {
});
} else {
setVisible(false);
let url = val.url + (val.url.indexOf('?') > 0 ? '&' : '?') + val.paramName + '=' + window.globalConfig?.token;
const url = `${val.url + (val.url.indexOf('?') > 0 ? '&' : '?') + val.paramName }=${ window.globalConfig?.token}`;
window.open(url, "_blank");
}
} else {
let cli = val.url?.indexOf('client=') >= 0 ? val.url.split('client=')[1] : '';
const cli = val.url?.indexOf('client=') >= 0 ? val.url.split('client=')[1] : '';
Cookies.set('client', cli, {
expires: 86400000 / (24 * 60 * 60 * 1000),
path: '/',
......
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