Commit 8f36b76c authored by 崔佳豪's avatar 崔佳豪

fix: 处理退出登录未请求配置信息

parent 7a610533
Pipeline #65196 passed with stages
// @eslint-disable // @eslint-disable
import React, { import React, { Suspense, useEffect, useRef, useState } from 'react';
Suspense,
useEffect,
useRef,
useState,
} from 'react';
import { import { Anchor, Popover, Radio, Spin } from 'antd';
Anchor,
Popover,
Radio,
Spin,
} from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import _ from 'lodash'; import _ from 'lodash';
...@@ -19,23 +9,16 @@ import memoized from 'nano-memoize'; ...@@ -19,23 +9,16 @@ import memoized from 'nano-memoize';
import KeepAlive from 'react-activation'; import KeepAlive from 'react-activation';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { matchRoutes } from 'react-router-dom'; import { matchRoutes } from 'react-router-dom';
import Loading from '../components/Loading';
import RightContent from '@/components/GlobalHeader/SimpleRiightContent'; import RightContent from '@/components/GlobalHeader/SimpleRiightContent';
import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings'; import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings';
// import SettingDrawer from '@wisdom-utils/components/lib/layout/components/SettingDrawer'; // import SettingDrawer from '@wisdom-utils/components/lib/layout/components/SettingDrawer';
import { actionCreators } from '@/containers/App/store'; import { actionCreators } from '@/containers/App/store';
import Icon, { LoadingOutlined } from '@ant-design/icons'; import Icon, { LoadingOutlined } from '@ant-design/icons';
import BasicLayout from '@wisdom-utils/components/lib/layout/BasicLayout'; import BasicLayout from '@wisdom-utils/components/lib/layout/BasicLayout';
import { import { useHistory, useLocation } from '@wisdom-utils/runtime';
useHistory, import { helpers, store, event } from '@wisdom-utils/utils';
useLocation,
} from '@wisdom-utils/runtime';
import {
helpers,
store,
event
} from '@wisdom-utils/utils';
import { Storeage as Store } from '@wisdom-utils/utils/lib/helpers'; import { Storeage as Store } from '@wisdom-utils/utils/lib/helpers';
import Loading from '../components/Loading';
import { waterMark } from '../utils/mark'; import { waterMark } from '../utils/mark';
import layoutStyles from './BasicLayout.less'; import layoutStyles from './BasicLayout.less';
...@@ -49,28 +32,26 @@ const { getParamsV1 } = params; ...@@ -49,28 +32,26 @@ const { getParamsV1 } = params;
// const AMap = React.lazy(() => import('../pages/map/amap')); // const AMap = React.lazy(() => import('../pages/map/amap'));
const CesiumMap = React.lazy(() => import('../pages/map/cesiumMap')); const CesiumMap = React.lazy(() => import('../pages/map/cesiumMap'));
const waitTime = (time = 100) =>
const waitTime = (time = 100) => { new Promise(resolve => {
return new Promise((resolve) => {
setTimeout(() => { setTimeout(() => {
resolve(true); resolve(true);
}, time); }, time);
}); });
};
const antIcon = <LoadingOutlined style={{ fontSize: 12 }} spin />; const antIcon = <LoadingOutlined style={{ fontSize: 12 }} spin />;
const arrowSvg = ({ fillColor = '#fff' }) => ( const arrowSvg = ({ fillColor = '#fff' }) => (
<svg <svg
t='1543324489942' t="1543324489942"
className='icon' className="icon"
viewBox='0 0 1024 1024' viewBox="0 0 1024 1024"
version='1.1' version="1.1"
xmlns='http://www.w3.org/2000/svg' xmlns="http://www.w3.org/2000/svg"
width='16' width="16"
height='16' height="16"
> >
<path <path
d='M511.700683 639.423111 191.917496 319.596945 319.830771 319.596945 511.700683 511.715521 703.570595 319.596945 831.48387 319.596945Z' d="M511.700683 639.423111 191.917496 319.596945 319.830771 319.596945 511.700683 511.715521 703.570595 319.596945 831.48387 319.596945Z"
p-id='8626' p-id="8626"
// fill={fillColor} // fill={fillColor}
/> />
</svg> </svg>
...@@ -102,9 +83,15 @@ const StationsItem = (item, action, onChangeVisible, actionRef, setMenuLoading) ...@@ -102,9 +83,15 @@ const StationsItem = (item, action, onChangeVisible, actionRef, setMenuLoading)
const OnlyFocusStations = props => { const OnlyFocusStations = props => {
const data = props.data.stations; const data = props.data.stations;
return ( return (
<Spin spinning={props.loading} tip='加载中' size='small'> <Spin spinning={props.loading} tip="加载中" size="small">
<div className={layoutStyles.focusStations} style={{ border: 'none' }}> <div className={layoutStyles.focusStations} style={{ border: 'none' }}>
<ul>{Array.isArray(data) ? data.map(item => StationsItem(item, props.action, props.setVisible, props.actionRef, props.setMenuLoading)) : null}</ul> <ul>
{Array.isArray(data)
? data.map(item =>
StationsItem(item, props.action, props.setVisible, props.actionRef, props.setMenuLoading),
)
: null}
</ul>
</div> </div>
</Spin> </Spin>
); );
...@@ -128,15 +115,21 @@ const AllStations = props => { ...@@ -128,15 +115,21 @@ const AllStations = props => {
setDefaultTab(event.target.value); setDefaultTab(event.target.value);
}; };
return ( return (
<Spin spinning={props.loading} tip='加载中'> <Spin spinning={props.loading} tip="加载中">
<div className={layoutStyles.focusStations}> <div className={layoutStyles.focusStations}>
<ul>{Array.isArray(data) ? data.map(item => StationsItem(item, props.action, props.setVisible, props.actionRef, props.setMenuLoading)) : null}</ul> <ul>
{Array.isArray(data)
? data.map(item =>
StationsItem(item, props.action, props.setVisible, props.actionRef, props.setMenuLoading),
)
: null}
</ul>
</div> </div>
<Radio.Group <Radio.Group
options={optionsWith} options={optionsWith}
optionType='button' optionType="button"
buttonStyle='solid' buttonStyle="solid"
size='small' size="small"
value={defaultTab} value={defaultTab}
onChange={handleTabChange} onChange={handleTabChange}
style={{ marginTop: '6px' }} style={{ marginTop: '6px' }}
...@@ -159,7 +152,7 @@ const AllStations = props => { ...@@ -159,7 +152,7 @@ const AllStations = props => {
</Anchor> </Anchor>
</div> </div>
) : ( ) : (
<div className='city_pane city_container'>{props.data.citySelector}</div> <div className="city_pane city_container">{props.data.citySelector}</div>
)} )}
</div> </div>
</Spin> </Spin>
...@@ -181,26 +174,32 @@ const renderSite = ({ data, config, loading, setLoading, action, actionRef, setM ...@@ -181,26 +174,32 @@ const renderSite = ({ data, config, loading, setLoading, action, actionRef, setM
if (config && config.userInfo && config.userInfo.site === '') { if (config && config.userInfo && config.userInfo.site === '') {
loaded = false; loaded = false;
} }
if (!data.allStation || !_.isArray(data.allStation) || data.allStation.length <= 1) if (!data.allStation || !_.isArray(data.allStation) || data.allStation.length <= 1) return <></>;
return <></>;
return ( return (
<> <>
<Spin <Spin
indicator={antIcon} indicator={antIcon}
spinning={loaded} spinning={loaded}
size='small' size="small"
style={{ marginLeft: '10px' }} style={{ marginLeft: '10px' }}
tip='' tip=""
wrapperClassName={layoutStyles.spinLoadding} wrapperClassName={layoutStyles.spinLoadding}
> >
<> <>
<Popover <Popover
placement='bottomLeft' placement="bottomLeft"
trigger='click' trigger="click"
visible={visible} visible={visible}
content={ content={
<Stations data={data} loading={loading} setLoading={setLoading} setVisible={setVisible} action={action} <Stations
actionRef={actionRef} setMenuLoading={setMenuLoading} /> data={data}
loading={loading}
setLoading={setLoading}
setVisible={setVisible}
action={action}
actionRef={actionRef}
setMenuLoading={setMenuLoading}
/>
} }
arrowPointAtCenter arrowPointAtCenter
overlayClassName={classNames(layoutStyles.stationsWrapper, layoutStyles.stationsTop)} overlayClassName={classNames(layoutStyles.stationsWrapper, layoutStyles.stationsTop)}
...@@ -228,7 +227,6 @@ const renderSite = ({ data, config, loading, setLoading, action, actionRef, setM ...@@ -228,7 +227,6 @@ const renderSite = ({ data, config, loading, setLoading, action, actionRef, setM
// import defaultProps from '../defaultProps'; // import defaultProps from '../defaultProps';
const pickRoutes = memoized((routes, pathname, locale) => { const pickRoutes = memoized((routes, pathname, locale) => {
const matches = matchRoutes(routes, { pathname }); const matches = matchRoutes(routes, { pathname });
const routeConfig = matches ? matches[matches.length - 1].route : null; const routeConfig = matches ? matches[matches.length - 1].route : null;
...@@ -246,7 +244,7 @@ const transformFloatMenu = (routes, homepage) => { ...@@ -246,7 +244,7 @@ const transformFloatMenu = (routes, homepage) => {
return routes.concat(route); return routes.concat(route);
}; };
const Layout = (props) => { const Layout = props => {
const currentProduct = new Store(`__global__recent_productIndex__micro_${window.location.hostname}`); const currentProduct = new Store(`__global__recent_productIndex__micro_${window.location.hostname}`);
const menuState = sessionStorage.getItem('menuState') || 'open'; const menuState = sessionStorage.getItem('menuState') || 'open';
const [cityData, setCityData] = useState({}); const [cityData, setCityData] = useState({});
...@@ -273,20 +271,19 @@ const Layout = (props) => { ...@@ -273,20 +271,19 @@ const Layout = (props) => {
}); });
}, []); }, []);
useEffect(() => { useEffect(() => {
siteAction.setGlobalConfig(props.global); siteAction.setGlobalConfig(props.global);
const tk = Cookies.get('token') || props.global.token; const tk = Cookies.get('token') || props.global.token;
const isLogin = tk !== null && tk !== 'undefined' && tk !== (void 0); const isLogin = tk !== null && tk !== 'undefined' && tk !== void 0;
if (!isLogin) { if (!isLogin) {
let client = props?.global?.client || sessionStorage.getItem('client') || null; // let client = props?.global?.client || sessionStorage.getItem('client') || null;
client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client : 'city'; // client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client : 'city';
let generateType = props.global && props.global.hasOwnProperty('get') ? props.global.get('generateType') : null; // let generateType = props.global && props.global.hasOwnProperty('get') ? props.global.get('generateType') : null;
generateType = // generateType =
!_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined' // !_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined'
? `&generateType=${generateType}` // ? `&generateType=${generateType}`
: ''; // : '';
history.replace(`/user/login?client=${client}${generateType}`); // history.replace(`/user/login?client=${client}${generateType}`);
props.logout(); props.logout();
} }
}, [history, props, props.global, siteAction]); }, [history, props, props.global, siteAction]);
...@@ -305,7 +302,6 @@ const Layout = (props) => { ...@@ -305,7 +302,6 @@ const Layout = (props) => {
} }
}, [cityData, props.global, props.global.userInfo, siteAction]); }, [cityData, props.global, props.global.userInfo, siteAction]);
useEffect(() => { useEffect(() => {
window.share.event.on('updateSite', res => { window.share.event.on('updateSite', res => {
setCityData(res); setCityData(res);
...@@ -333,8 +329,7 @@ const Layout = (props) => { ...@@ -333,8 +329,7 @@ const Layout = (props) => {
}); });
} }
}; };
}, [props.global.userInfo]); }, [props.global.isHaveMark, props.global.userInfo]);
const onMenuHeaderClick = event => { const onMenuHeaderClick = event => {
// 非云平台不做响应 // 非云平台不做响应
...@@ -368,7 +363,7 @@ const Layout = (props) => { ...@@ -368,7 +363,7 @@ const Layout = (props) => {
const { share, history } = window; const { share, history } = window;
const findMenuPath = (flatMenu, url) => { const findMenuPath = (flatMenu, url) => {
const [path, param = ''] = url.split('|'); const [path, param = ''] = url.split('|');
let params = param.split('&').reduce((pre, item) => { const params = param.split('&').reduce((pre, item) => {
if (!item) return pre; if (!item) return pre;
const [key, value] = item.split('='); const [key, value] = item.split('=');
pre[key] = value; pre[key] = value;
...@@ -393,18 +388,14 @@ const Layout = (props) => { ...@@ -393,18 +388,14 @@ const Layout = (props) => {
return () => { return () => {
share && share.event && share.event.removeListener('route:pushState', skipHandler); share && share.event && share.event.removeListener('route:pushState', skipHandler);
}; };
}, []); }, [props.flatMenu]);
if (props.global && props.global.userInfo) {
if(props.global && props.global.userInfo){ if (!props.global.userInfo.site) {
if(!props.global.userInfo.site){
props.global.userInfo.site = ''; props.global.userInfo.site = '';
} }
} }
return ( return (
<SecurityLayout {...props}> <SecurityLayout {...props}>
<BasicLayout <BasicLayout
...@@ -412,7 +403,7 @@ const Layout = (props) => { ...@@ -412,7 +403,7 @@ const Layout = (props) => {
route={props.route} route={props.route}
location={location} location={location}
navTheme={props.global?.variableTheme?.navTheme ?? 'dark'} navTheme={props.global?.variableTheme?.navTheme ?? 'dark'}
mode='MDI' mode="MDI"
fixedHeader fixedHeader
headerHeight={52} headerHeight={52}
routeConfig={routeConfig} routeConfig={routeConfig}
...@@ -449,16 +440,15 @@ const Layout = (props) => { ...@@ -449,16 +440,15 @@ const Layout = (props) => {
} }
menuItemRender={(item, dom) => ( menuItemRender={(item, dom) => (
<a <a
onClick={(event) => { onClick={event => {
event.preventDefault(); event.preventDefault();
window.history.pushState(null, '', '/civbase' + item.path); window.history.pushState(null, '', `/civbase${item.path}`);
}} }}
> >
{dom} {dom}
</a> </a>
)} )}
> >
<Suspense fallback={<></>}> <Suspense fallback={<></>}>
{/* {window.location.pathname.startsWith('/civbase/civ_3d') ? ( */} {/* {window.location.pathname.startsWith('/civbase/civ_3d') ? ( */}
{/* <KeepAlive> */} {/* <KeepAlive> */}
...@@ -475,14 +465,13 @@ const Layout = (props) => { ...@@ -475,14 +465,13 @@ const Layout = (props) => {
<KeepAlive> <KeepAlive>
<CesiumMap /> <CesiumMap />
</KeepAlive> </KeepAlive>
) : ( ) : (
window.location.pathname.startsWith('/civbase/civ_webgis') && null window.location.pathname.startsWith('/civbase/civ_webgis') && null
)} )}
</Suspense> </Suspense>
{subLoading && <Loading loading={subLoading} />} {subLoading && <Loading loading={subLoading} />}
<div id='micro-container' className='subapp-container'> <div id="micro-container" className="subapp-container">
{props.children} {props.children}
</div> </div>
</BasicLayout> </BasicLayout>
......
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