Commit fb5e1a80 authored by yzl's avatar yzl

- 优化进入子应用过渡效果

- 增加进入子应用前的进度条
parent 20787d5e
Pipeline #57560 passed with stages
...@@ -15,5 +15,5 @@ import 'antd/dist/antd.less'; ...@@ -15,5 +15,5 @@ import 'antd/dist/antd.less';
// const namespace = `__PANDA_STORE__${location.hostname}`; // const namespace = `__PANDA_STORE__${location.hostname}`;
// window.createStoreage = new Storeage(namespace); // window.createStoreage = new Storeage(namespace);
;(() => { ;(() => {
render(); render({loading: true });
})(); })();
import { Spin } from 'antd';
export default (props) => {
const { loading } = props;
const style = {
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
}
return (
<Spin spinning={loading} size="large" style={style} tip="子应用正在加载..." />
);
}
...@@ -3,24 +3,29 @@ import React from 'react'; ...@@ -3,24 +3,29 @@ import React from 'react';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Router, Switch } from '@wisdom-utils/runtime'; import { Router, Switch } from '@wisdom-utils/runtime';
import { helpers } from '@wisdom-utils/utils'; import { helpers, event } from '@wisdom-utils/utils';
import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings'; import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings';
// eslint-disable-next-line import/extensions // eslint-disable-next-line import/extensions
import { dyRoutes } from '../../routes/config'; import { dyRoutes } from '../../routes/config';
const pkg = require('../../../package.json'); const pkg = require('../../../package.json');
const { renderRoutes } = helpers; const { renderRoutes } = helpers;
const config = require('../../../config/config'); const config = require('../../../config/config');
function App(props) { function App(props) {
event.emit('loading' , props.loading);
const metaSecurity = /https/.test(window.location.protocol) ? ( const metaSecurity = /https/.test(window.location.protocol) ? (
<meta httpEquiv="Content-Security-Policy" content="upgrade-insecure-requests" /> <meta httpEquiv='Content-Security-Policy' content='upgrade-insecure-requests' />
) : null; ) : null;
return ( return (
<> <>
<Helmet title={`${(props.global && props.global.title) || defaultSetting.title}`}> <Helmet title={`${(props.global && props.global.title) || defaultSetting.title}`}>
<title>{`${(props.global && props.global.title) || defaultSetting.title}`}</title> <title>{`${(props.global && props.global.title) || defaultSetting.title}`}</title>
<link rel="shortcut icon" href={`${window.location.origin}/web4/${props.global && props.global.shortcutIcon}`} /> <link rel='shortcut icon'
href={`${window.location.origin}/web4/${props.global && props.global.shortcutIcon}`} />
{metaSecurity} {metaSecurity}
<meta name="description" content={`${(props.global && props.global.title) || defaultSetting.title}`} /> <meta name='description' content={`${(props.global && props.global.title) || defaultSetting.title}`} />
</Helmet> </Helmet>
<Router basename={config.base || pkg.name.toLocaleLowerCase() || ''}> <Router basename={config.base || pkg.name.toLocaleLowerCase() || ''}>
<Switch> <Switch>
...@@ -41,7 +46,7 @@ function App(props) { ...@@ -41,7 +46,7 @@ function App(props) {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']), global: state.getIn(['global', 'globalConfig']),
menu: state.getIn(['global', 'menu']) menu: state.getIn(['global', 'menu']),
}); });
export default connect( export default connect(
mapStateToProps, mapStateToProps,
......
...@@ -19,8 +19,9 @@ import memoized from 'nano-memoize'; ...@@ -19,8 +19,9 @@ 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 BootPage from '../pages/bootpage';
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';
...@@ -33,6 +34,7 @@ import { ...@@ -33,6 +34,7 @@ import {
import { import {
helpers, helpers,
store, store,
event,
} from '@wisdom-utils/utils'; } from '@wisdom-utils/utils';
import { waterMark } from '../utils/mark'; import { waterMark } from '../utils/mark';
...@@ -47,7 +49,7 @@ const { getParamsV1 } = params; ...@@ -47,7 +49,7 @@ 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) => {
return new Promise((resolve) => { return new Promise((resolve) => {
setTimeout(() => { setTimeout(() => {
resolve(true); resolve(true);
...@@ -57,17 +59,17 @@ const waitTime = (time= 100) => { ...@@ -57,17 +59,17 @@ const waitTime = (time= 100) => {
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>
...@@ -99,13 +101,13 @@ const StationsItem = (item, action, onChangeVisible, actionRef, setMenuLoading) ...@@ -99,13 +101,13 @@ 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>
) );
} };
const AllStations = props => { const AllStations = props => {
const data = props.data.stations; const data = props.data.stations;
...@@ -125,15 +127,15 @@ const AllStations = props => { ...@@ -125,15 +127,15 @@ 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' }}
...@@ -156,7 +158,7 @@ const AllStations = props => { ...@@ -156,7 +158,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>
...@@ -169,8 +171,8 @@ const Stations = props => { ...@@ -169,8 +171,8 @@ const Stations = props => {
props.data.siteCityList && props.data.siteCityList &&
((props.data.siteCityList.letters && props.data.siteCityList.letters.length) || ((props.data.siteCityList.letters && props.data.siteCityList.letters.length) ||
(props.data.siteCityList.content && props.data.siteCityList.content.length)); (props.data.siteCityList.content && props.data.siteCityList.content.length));
return isAll ? <AllStations {...props}/> : <OnlyFocusStations {...props}/>; return isAll ? <AllStations {...props} /> : <OnlyFocusStations {...props} />;
} };
const renderSite = ({ data, config, loading, setLoading, action, actionRef, setMenuLoading }) => { const renderSite = ({ data, config, loading, setLoading, action, actionRef, setMenuLoading }) => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
...@@ -178,25 +180,26 @@ const renderSite = ({ data, config, loading, setLoading, action, actionRef, setM ...@@ -178,25 +180,26 @@ 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} actionRef={actionRef} setMenuLoading={setMenuLoading} /> <Stations 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)}
...@@ -232,21 +235,22 @@ const pickRoutes = memoized((routes, pathname, locale) => { ...@@ -232,21 +235,22 @@ const pickRoutes = memoized((routes, pathname, locale) => {
locale, // just for cache locale, // just for cache
routeConfig, routeConfig,
// matchPath: matches ? matches.map(match => _.replace(match.route.path,'/*','')).join('/') : null // 解决下微端/*路径的问题 // matchPath: matches ? matches.map(match => _.replace(match.route.path,'/*','')).join('/') : null // 解决下微端/*路径的问题
matchPath: routeConfig ? _.replace(routeConfig.key, "/*", "") : '', matchPath: routeConfig ? _.replace(routeConfig.key, '/*', '') : '',
}; };
}); });
const transformFloatMenu = (routes, homepage) => { const transformFloatMenu = (routes, homepage) => {
const route = routes.find(route => route.path === `/${homepage}`); const route = routes.find(route => route.path === `/${homepage}`);
console.log("route", route); console.log('route', route);
return routes.concat(route); return routes.concat(route);
} };
const Layout = (props) => { const Layout = (props) => {
const [cityData, setCityData] = useState({}); const [cityData, setCityData] = useState({});
const [siteLoading, setSiteLoading] = useState(false); const [siteLoading, setSiteLoading] = useState(false);
const [siteAction, setSiteAction] = useState(() => new Site(props, setSiteLoading)); const [siteAction, setSiteAction] = useState(() => new Site(props, setSiteLoading));
const [menuLoading, setMenuLoading] = useState(true); const [menuLoading, setMenuLoading] = useState(true);
const [subLoading, setSubLoading] = useState(true);
// const [settings, setSetting] = useState({}); // const [settings, setSetting] = useState({});
// const [routeConfig, setRouteConfig] = useState(null); // const [routeConfig, setRouteConfig] = useState(null);
// const [matchPath, setMatchPath] = useState(''); // const [matchPath, setMatchPath] = useState('');
...@@ -254,13 +258,34 @@ const Layout = (props) => { ...@@ -254,13 +258,34 @@ const Layout = (props) => {
const history = useHistory(); const history = useHistory();
const location = useLocation(); const location = useLocation();
const { routeConfig = {}, matchPath } = pickRoutes(props.flatMenu, location.pathname); const { routeConfig = {}, matchPath } = pickRoutes(props.flatMenu, location.pathname);
const [visible, setVisible] = useState(true);
// useEffect(() => { // useEffect(() => {
// setRouteConfig(routeConfig); // setRouteConfig(routeConfig);
// setMatchPath(match) // setMatchPath(match)
// }, [location.pathname]) // }, [location.pathname])
useEffect(() => {
event.on('loading', ret => {
setSubLoading(ret);
});
event.on('visible', (ret) => {
setTimeout(() => {
setVisible(ret);
}, 2000)
})
}, []);
useEffect(() => {
let flag = false;
if(props.location.pathname.indexOf('industry') !== -1) {
flag = true;
}
setVisible(flag);
}, [])
useEffect(() => { useEffect(() => {
siteAction.setGlobalConfig(props.global); siteAction.setGlobalConfig(props.global);
...@@ -307,31 +332,32 @@ const Layout = (props) => { ...@@ -307,31 +332,32 @@ const Layout = (props) => {
const needMark = () => const needMark = () =>
(props.global.isHaveMark || window.location.origin.replace(/^(http|https):\/\//, '') === 'panda-water.cn') && (props.global.isHaveMark || window.location.origin.replace(/^(http|https):\/\//, '') === 'panda-water.cn') &&
document.querySelectorAll('.pandawatermark_mask_div').length <= 0 && document.querySelectorAll('.pandawatermark_mask_div').length <= 0 &&
props.global.userInfo props.global.userInfo;
if(needMark()) { if (needMark()) {
waterMark({ waterMark({
watermark_txt: `${props.global.userInfo.fullName}${props.global.userInfo.loginName})` watermark_txt: `${props.global.userInfo.fullName}${props.global.userInfo.loginName})`,
}); });
} }
return () => { return () => {
const marks = document.querySelectorAll('.pandawatermark_mask_div') const marks = document.querySelectorAll('.pandawatermark_mask_div');
if(marks && marks.length) { if (marks && marks.length) {
Array.prototype.forEach.call(marks, function(dom, index) { Array.prototype.forEach.call(marks, function(dom, index) {
document.body.removeChild(dom) document.body.removeChild(dom);
}) });
}
} }
};
}, [props.global.userInfo]); }, [props.global.userInfo]);
const onMenuHeaderClick = event => { const onMenuHeaderClick = event => {
// 非云平台不做响应 // 非云平台不做响应
if(!props.global.get('userInfo.site')) return; if (!props.global.get('userInfo.site')) return;
// 至少2个行业才能回到引导页 // 至少2个行业才能回到引导页
const Industries = props.global.get('userInfo.Industries'); const Industries = props.global.get('userInfo.Industries');
if(Industries && Industries.length > 1) { if (Industries && Industries.length > 1) {
history.push(`/industry`) history.push('/Industry');
setVisible(true);
} }
}; };
// useEffect(async () => { // useEffect(async () => {
...@@ -372,36 +398,51 @@ const Layout = (props) => { ...@@ -372,36 +398,51 @@ const Layout = (props) => {
}; };
const skipHandler = (data, title, url) => { const skipHandler = (data, title, url) => {
const targetMenuPath = findMenuPath(props.flatMenu, url); const targetMenuPath = findMenuPath(props.flatMenu, url);
if (targetMenuPath) { if (targetMenuPath) {
history.pushState(data, title, `/civbase/${targetMenuPath}`); history.pushState(data, title, `/civbase/${targetMenuPath}`);
} }
} };
share && share.event && share.event.on('route:pushState', skipHandler); share && share.event && share.event.on('route:pushState', skipHandler);
return () => { return () => {
share && share.event && share.event.removeListener('route:pushState', skipHandler); share && share.event && share.event.removeListener('route:pushState', skipHandler);
} };
}, []); }, []);
return ( return (
<>
<div style={{
position:'absolute',
top:'0',
right:'0',
bottom:'0',
left:'0',
zIndex:1000,
display: visible ? 'block' : 'none'
}}>
<BootPage visible={visible} />
</div>
<div style={{display: visible ? 'none' : 'block'}}>
<SecurityLayout {...props}> <SecurityLayout {...props}>
<BasicLayout <BasicLayout
title={props.global.title} title={props.global.title}
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}
matchPath={matchPath} matchPath={matchPath}
actionRef={actionRef} actionRef={actionRef}
menu={{ menu={{
loading: menuLoading loading: menuLoading,
// onLoadingChange: (loading) => setMenuLoading(loading) // onLoadingChange: (loading) => setMenuLoading(loading)
}} }}
logo={logo} logo={logo}
topMenuActiveKey={props.currentMenuIndex} topMenuActiveKey={props.currentMenuIndex}
rightContentRender={() => <RightContent/>} rightContentRender={() => <RightContent />}
onPageChange={() => { onPageChange={() => {
// if(!props.global.token) { // if(!props.global.token) {
// history.push('/user/login') // history.push('/user/login')
...@@ -409,9 +450,9 @@ const Layout = (props) => { ...@@ -409,9 +450,9 @@ const Layout = (props) => {
}} }}
onMenuHeaderClick={onMenuHeaderClick} onMenuHeaderClick={onMenuHeaderClick}
onTopMenuHeaderClick={onTopMenuHeaderClick} onTopMenuHeaderClick={onTopMenuHeaderClick}
menuProps = {{ menuProps={{
popupClassName: 'testpop', popupClassName: 'testpop',
popupOffset: [0, 15] popupOffset: [0, 15],
}} }}
headerSiteRender={() => headerSiteRender={() =>
renderSite({ renderSite({
...@@ -428,7 +469,7 @@ const Layout = (props) => { ...@@ -428,7 +469,7 @@ const Layout = (props) => {
<a <a
onClick={(event) => { onClick={(event) => {
event.preventDefault() event.preventDefault();
window.history.pushState(null, '', '/civbase' + item.path); window.history.pushState(null, '', '/civbase' + item.path);
}} }}
> >
...@@ -453,16 +494,19 @@ const Layout = (props) => { ...@@ -453,16 +494,19 @@ 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>
<div id="micro-container" className="subapp-container"> {subLoading && <Loading loading={subLoading} />}
<div id='micro-container' className='subapp-container'>
{props.children} {props.children}
</div> </div>
</BasicLayout> </BasicLayout>
</SecurityLayout> </SecurityLayout>
</div>
</>
); );
}; };
......
...@@ -62,10 +62,10 @@ export const initMicroApps = () => { ...@@ -62,10 +62,10 @@ export const initMicroApps = () => {
micorConfig.dev : micorConfig.dev :
products; products;
registerMicroApps( const apps = entrys.map(item => {
entrys.map(item => { return {
item.loader = loader; ...item,
item.props = { props: {
emitter: window.share.event, emitter: window.share.event,
baseRoot: item.name, baseRoot: item.name,
event: event, event: event,
...@@ -78,9 +78,16 @@ export const initMicroApps = () => { ...@@ -78,9 +78,16 @@ export const initMicroApps = () => {
//createStoreage.get('globalConfig'), //createStoreage.get('globalConfig'),
XMLHttpRequest: window.XMLHttpRequest, XMLHttpRequest: window.XMLHttpRequest,
// offGlobalStateChange: actions.offGlobalStateChange // offGlobalStateChange: actions.offGlobalStateChange
}; }
return item; }
}), { })
const microApps = apps.map((app => ({
...app,
loader,
})))
registerMicroApps(microApps, {
beforeLoad: [ beforeLoad: [
app => { app => {
store.dispatch(actionCreators.updateMicroMounted(true)); store.dispatch(actionCreators.updateMicroMounted(true));
...@@ -208,7 +215,6 @@ export const initMicroApps = () => { ...@@ -208,7 +215,6 @@ export const initMicroApps = () => {
}; };
export const defaultApp = () => { export const defaultApp = () => {
const globalStore = store.getState().toJS(); const globalStore = store.getState().toJS();
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const config = window.globalConfig; const config = window.globalConfig;
...@@ -219,6 +225,10 @@ export const defaultApp = () => { ...@@ -219,6 +225,10 @@ export const defaultApp = () => {
let url = !config.home ? let url = !config.home ?
((config.homepage === '' || _.isNull(config.homepage)) ? `/civbase/civweb4`: (`/civbase/${config.homepage.replace(/^\//, '')}`)) : `/civbase/${config.homepage.replace(/^\//, '')}`; ((config.homepage === '' || _.isNull(config.homepage)) ? `/civbase/civweb4`: (`/civbase/${config.homepage.replace(/^\//, '')}`)) : `/civbase/${config.homepage.replace(/^\//, '')}`;
setDefaultMountApp(url); setDefaultMountApp(url);
window.history.pushState(null, '', url);
event.emit('visible', false);
} }
}; };
......
// 云平台引导页 // 云平台引导页
import React, { useCallback, useEffect, useMemo, useState } from 'react'; import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { Space, Spin } from 'antd'; import { Space, Spin, Progress } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { useIntl } from '@wisdom-utils/components'; import { useIntl } from '@wisdom-utils/components';
...@@ -16,44 +16,25 @@ import usingIcon from '@/assets/bootPage/using-icon.png'; ...@@ -16,44 +16,25 @@ import usingIcon from '@/assets/bootPage/using-icon.png';
import { appService } from '@/api'; import { appService } from '@/api';
const industries = [ const industries = [
{ name: '供水', type: '供水', subTitle: 'WATER SUPPLY' }, { name: '供水', type: '供水', subTitle: 'WATER SUPPLY' , color: 'rgb(16,104,239)'},
{ name: '农饮水', type: '农饮水', subTitle: 'RURAL POTABLE WATER' }, { name: '农饮水', type: '农饮水', subTitle: 'RURAL POTABLE WATER' , color: 'rgb(4,142,101)'},
{ name: '排水', type: '排水', subTitle: 'DRAINAGE' }, { name: '排水', type: '排水', subTitle: 'DRAINAGE' , color: 'rgb(234,117,28)'},
{ name: '水利', type: '水利', subTitle: 'WATER CONSERVANCY' }, { name: '水利', type: '水利', subTitle: 'WATER CONSERVANCY' , color: 'rgb(0,144,158)'},
{ name: '能源', type: '能源', subTitle: 'ENERGY SOURCES' }, { name: '能源', type: '能源', subTitle: 'ENERGY SOURCES', color: 'rgb(16,104,239)' },
{ name: '高品质水', type: '高品质水', subTitle: 'HIGH QUALITY WATER' }, { name: '高品质水', type: '高品质水', subTitle: 'HIGH QUALITY WATER' , color: 'rgb(16,104,239)'},
// { name: '水资源', type: '水资源', subTitle: 'WATER RESOURCES' }, // { name: '水资源', type: '水资源', subTitle: 'WATER RESOURCES' },
{ name: '熊猫智能实验室', type: '实验室', subTitle: 'PANDA AI. LAB' }, { name: '熊猫智能实验室', type: '实验室', subTitle: 'PANDA AI. LAB', color: 'rgb(16,104,239)' },
{ name: '水务大数据', type: '大数据', subTitle: 'WATER BIG DATA' }, { name: '水务大数据', type: '大数据', subTitle: 'WATER BIG DATA' , color: 'rgb(85,77,210)'},
{ name: '熊猫新产品', type: '熊猫新产品', subTitle: "PANDA'S NEW PRODUCT" }, { name: '熊猫新产品', type: '熊猫新产品', subTitle: "PANDA'S NEW PRODUCT" , color: 'rgb(12,103,205)'},
{ name: '项目案例', type: '项目案例', subTitle: 'PROJECT CASE' }, { name: '项目案例', type: '项目案例', subTitle: 'PROJECT CASE' , color: 'rgb(107,36,155)'},
]; ];
const renderIndustries = (config, callback) =>
industries.map(item => {
if (
config &&
config.userInfo &&
config.userInfo.Industries &&
config.userInfo.Industries instanceof Array &&
config.userInfo.Industries.indexOf(item.type) > -1
) {
return (
<li className={styles.bootPageLi} key={item.type} onClick={event => callback(event, item.type)}>
<div className={styles.bootPageList}>
<div className={styles.listMain}>
<img src={require(`@/assets/bootPage/${item.type}.png`)} alt="" />
<span className={styles.bootPageName}>{item.name}</span>
<span className={styles.bootPageNameEng}>{item.subTitle}</span>
</div>
</div>
</li>
);
}
});
// let loginAction = null; // let loginAction = null;
const BootPage = props => { const BootPage = props => {
const [loadding, setLoadding] = useState(false); const {visible} = props;
const [percentNum, setPercentNum] = useState(10);
const [currentType, setCurrentType] = useState('');
// const [loadding, setLoadding] = useState(false);
const [hasRole, setHasRole] = useState(false); const [hasRole, setHasRole] = useState(false);
const [scale, setScale] = useState(1); const [scale, setScale] = useState(1);
const [loginAction, setAction] = useState(() => new LoginAction(props)); const [loginAction, setAction] = useState(() => new LoginAction(props));
...@@ -62,8 +43,11 @@ const BootPage = props => { ...@@ -62,8 +43,11 @@ const BootPage = props => {
{ title: defaultSetting.title, id: '', pageName: '行业切换' }, { title: defaultSetting.title, id: '', pageName: '行业切换' },
props.global.title || defaultSetting.title, props.global.title || defaultSetting.title,
); );
const handlePage = useCallback( const handlePage = useCallback(
(event, type) => { (event, type) => {
setPercentNum(Math.ceil(Math.random()*50));
event.persist(); event.persist();
event.preventDefault(); event.preventDefault();
...@@ -73,7 +57,7 @@ const BootPage = props => { ...@@ -73,7 +57,7 @@ const BootPage = props => {
return; return;
} }
setLoadding(true); // setLoadding(true);
const config = props.global; const config = props.global;
// const loginAction = new LoginAction(props); // const loginAction = new LoginAction(props);
config.uiwidgets = []; config.uiwidgets = [];
...@@ -82,9 +66,56 @@ const BootPage = props => { ...@@ -82,9 +66,56 @@ const BootPage = props => {
props.instance && props.instance.updateConfig(config); props.instance && props.instance.updateConfig(config);
// props.instance && props.instance.getUserInfoAndConfig('', true, type); // props.instance && props.instance.getUserInfoAndConfig('', true, type);
loginAction && loginAction.getUserInfoAndConfig('', true, type); loginAction && loginAction.getUserInfoAndConfig('', true, type);
setCurrentType(type);
}, },
[loginAction, props.global.token, props.instance], [loginAction, props.global.token, props.instance],
); );
const renderIndustries = (config, callback) =>
industries.map(item => {
if (
config &&
config.userInfo &&
config.userInfo.Industries &&
config.userInfo.Industries instanceof Array &&
config.userInfo.Industries.indexOf(item.type) > -1
) {
return (
<li className={styles.bootPageLi} key={item.type} onClick={event => callback(event, item.type)}>
<div className={styles.bootPageList}>
<div className={styles.listMain}>
<img src={require(`@/assets/bootPage/${item.type}.png`)} alt="" />
<span className={styles.bootPageName}>{item.name}</span>
<span className={styles.bootPageNameEng}>{item.subTitle}</span>
</div>
</div>
{
currentType === item.type && <Progress
style={{width: '98%'}}
strokeColor={item.color}
percent={percentNum}
status="active"
format={percent => <span style={{color: '#fff'}}>{percent}%</span>}
className={styles.bootProgress}
/>
}
</li>
);
}
});
useEffect(() => {
if(visible){
setCurrentType('');
setPercentNum(10);
}
} , [visible])
useEffect(() => { useEffect(() => {
// eslint-disable-next-line no-use-before-define // eslint-disable-next-line no-use-before-define
handleResize(); handleResize();
...@@ -100,11 +131,16 @@ const BootPage = props => { ...@@ -100,11 +131,16 @@ const BootPage = props => {
window.addEventListener('resize', handleResize); window.addEventListener('resize', handleResize);
const handleToggleIndustry = event => { const handleToggleIndustry = event => {
setLoadding(false);
props.history.push(`/?client=${props.global.client}`); // props.history.push(`/?client=${props.global.client}`);
defaultApp(); defaultApp();
// window.share.event.emit('triggerMicro', props.global); // window.share.event.emit('triggerMicro', props.global);
props.updateCurrentIndex(0); props.updateCurrentIndex(0);
setPercentNum(100);
// setLoadding(false);
}; };
loginAction.events.on('toggleIndustry', handleToggleIndustry); loginAction.events.on('toggleIndustry', handleToggleIndustry);
return () => { return () => {
...@@ -114,7 +150,7 @@ const BootPage = props => { ...@@ -114,7 +150,7 @@ const BootPage = props => {
}, [loginAction.events, props]); }, [loginAction.events, props]);
const [IndustryNum, setIndustryNum] = useState(0); const [IndustryNum, setIndustryNum] = useState(0);
const renderIndustr = useMemo(() => renderIndustries(props.global, handlePage), [handlePage, props.global.token]); const renderIndustr = useMemo(() => renderIndustries(props.global, handlePage), [handlePage, props.global.token, currentType, percentNum]);
useEffect(() => { useEffect(() => {
const NewIndustryNum = const NewIndustryNum =
props.global && props.global.userInfo && props.global.userInfo.Industries props.global && props.global.userInfo && props.global.userInfo.Industries
...@@ -172,9 +208,9 @@ const BootPage = props => { ...@@ -172,9 +208,9 @@ const BootPage = props => {
{renderIndustr} {renderIndustr}
</ul> </ul>
</section> </section>
<Space className={styles.abs}> {/*<Space className={styles.abs}>*/}
<Spin spinning={loadding} size="large" /> {/* <Spin spinning={loadding} size="large" />*/}
</Space> {/*</Space>*/}
</div> </div>
{hasRole ? ( {hasRole ? (
<div className={styles.cloudMonitorBtns}> <div className={styles.cloudMonitorBtns}>
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
transition: all .5s ease-out; transition: all .5s ease-out;
padding-top: 10px; padding-top: 10px;
.bootPageLi { .bootPageLi {
position: relative;
width: 298px; width: 298px;
height: 268.8px; height: 268.8px;
margin: 10px; margin: 10px;
...@@ -168,6 +169,11 @@ ...@@ -168,6 +169,11 @@
height: 100%; height: 100%;
} }
} }
.bootProgress {
position: absolute;
bottom: -5px;
}
} }
@media screen and (max-width: 1440px) { @media screen and (max-width: 1440px) {
......
...@@ -265,7 +265,8 @@ export const AppInitState = () => { ...@@ -265,7 +265,8 @@ export const AppInitState = () => {
initAppTheme(); initAppTheme();
} }
const RootContainer = () => { const RootContainer = (props) => {
const { loading } = props;
useEffect(() => { useEffect(() => {
AppInitState(); AppInitState();
...@@ -275,43 +276,46 @@ const RootContainer = () => { ...@@ -275,43 +276,46 @@ const RootContainer = () => {
...{ ...{
prefixCls: customPrefixCls, prefixCls: customPrefixCls,
theme: { theme: {
"root-entry-name": "default", 'root-entry-name': 'default',
...getThemeVariables({}), ...getThemeVariables({}),
primaryColor: defaultSetting.primaryColor, primaryColor: defaultSetting.primaryColor,
}, },
} },
} };
if(finalConfig.prefixCls) { if (finalConfig.prefixCls) {
Modal.config({ Modal.config({
rootPrefixCls: customPrefixCls rootPrefixCls: customPrefixCls,
}); });
message.config({ message.config({
rootPrefixCls: `${finalConfig.prefixCls}-message` rootPrefixCls: `${finalConfig.prefixCls}-message`,
}); });
notification.config({ notification.config({
rootPrefixCls: `${finalConfig.prefixCls}-notification` rootPrefixCls: `${finalConfig.prefixCls}-notification`,
}); });
} }
return React.createElement(Provider, { return React.createElement(Provider, {
store: store store: store,
}, React.createElement(ConnectedRouter, { }, React.createElement(ConnectedRouter, {
history: history history: history,
}, React.createElement(LocaleContainer, { }, React.createElement(LocaleContainer, {
prefixCls: customPrefixCls prefixCls: customPrefixCls,
}, React.createElement(ConfigProvider, { }, React.createElement(ConfigProvider, {
prefixCls: customPrefixCls prefixCls: customPrefixCls,
}, React.createElement(Container, null, React.createElement(App)))))) }, React.createElement(Container, null, React.createElement(App , {
} loading,
}))))));
};
export const render = ({ loading }) => {
export const render = () => {
// eslint-disable-next-line react-hooks/rules-of-hooks // eslint-disable-next-line react-hooks/rules-of-hooks
ReactDOM.render(<RootContainer/>, MOUNT_NODE); ReactDOM.render(<RootContainer loading={loading} />, MOUNT_NODE);
}; };
// updateTheme('#ff9600'); // updateTheme('#ff9600');
const loader = (appContent, loading) => render({ appContent, loading }); const loader = (loading) => render({ loading });
export default loader; export default loader;
...@@ -41,10 +41,10 @@ export const dyRoutes = (routes, layout, theme) => { ...@@ -41,10 +41,10 @@ export const dyRoutes = (routes, layout, theme) => {
}, },
], ],
}, },
{ // {
path: '/industry', // path: '/industry',
component: BootPage, // component: BootPage,
}, // },
{ {
path: '/cloud/analysis/using', path: '/cloud/analysis/using',
component: UsingAnalysis, component: UsingAnalysis,
......
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