Commit 72b6bed0 authored by yzl's avatar yzl

- 修复引导页闪动

parent a2d7d3f2
Pipeline #57726 failed with stages
import { Spin } from 'antd'; import { Spin } from 'antd';
export default (props) => { export default props => {
const { loading } = props; const { loading } = props;
const style = { const style = {
...@@ -8,10 +8,7 @@ export default (props) => { ...@@ -8,10 +8,7 @@ export default (props) => {
top: '50%', top: '50%',
left: '50%', left: '50%',
transform: 'translate(-50%, -50%)', transform: 'translate(-50%, -50%)',
} };
return (
<Spin spinning={loading} size="large" style={style} tip="子应用正在加载..." />
);
}
return <Spin spinning={loading} style={style} />;
};
...@@ -10,27 +10,28 @@ import { useHistory } from '@wisdom-utils/runtime'; ...@@ -10,27 +10,28 @@ import { useHistory } from '@wisdom-utils/runtime';
import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings'; import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings';
import { actionCreators } from '@/containers/App/store'; import { actionCreators } from '@/containers/App/store';
import LoginAction from '@/pages/user/login/login'; import LoginAction from '@/pages/user/login/login';
import styles from './index.less';
import { defaultApp } from '@/micro'; import { defaultApp } from '@/micro';
import usingIcon from '@/assets/bootPage/using-icon.png'; import usingIcon from '@/assets/bootPage/using-icon.png';
import { appService } from '@/api'; import { appService } from '@/api';
import styles from './index.less';
const industries = [ const industries = [
{ name: '供水', type: '供水', subTitle: 'WATER SUPPLY' , color: 'rgb(16,104,239)'}, { name: '供水', type: '供水', subTitle: 'WATER SUPPLY', color: 'rgb(16,104,239)' },
{ name: '农饮水', type: '农饮水', subTitle: 'RURAL POTABLE WATER' , color: 'rgb(4,142,101)'}, { name: '农饮水', type: '农饮水', subTitle: 'RURAL POTABLE WATER', color: 'rgb(4,142,101)' },
{ name: '排水', type: '排水', subTitle: 'DRAINAGE' , color: 'rgb(234,117,28)'}, { name: '排水', type: '排水', subTitle: 'DRAINAGE', color: 'rgb(234,117,28)' },
{ name: '水利', type: '水利', subTitle: 'WATER CONSERVANCY' , color: 'rgb(0,144,158)'}, { name: '水利', type: '水利', subTitle: 'WATER CONSERVANCY', color: 'rgb(0,144,158)' },
{ name: '能源', type: '能源', subTitle: 'ENERGY SOURCES', color: 'rgb(49,139,27)' }, { name: '能源', type: '能源', subTitle: 'ENERGY SOURCES', color: 'rgb(49,139,27)' },
{ name: '高品质水', type: '高品质水', subTitle: 'HIGH QUALITY WATER' , color: 'rgb(106,208,218)'}, { name: '高品质水', type: '高品质水', subTitle: 'HIGH QUALITY WATER', color: 'rgb(106,208,218)' },
// { name: '水资源', type: '水资源', subTitle: 'WATER RESOURCES' }, // { name: '水资源', type: '水资源', subTitle: 'WATER RESOURCES' },
{ name: '熊猫智能实验室', type: '实验室', subTitle: 'PANDA AI. LAB', color: 'rgb(104,163,242)' }, { name: '熊猫智能实验室', type: '实验室', subTitle: 'PANDA AI. LAB', color: 'rgb(104,163,242)' },
{ name: '水务大数据', type: '大数据', subTitle: 'WATER BIG DATA' , color: 'rgb(85,77,210)'}, { name: '水务大数据', type: '大数据', subTitle: 'WATER BIG DATA', color: 'rgb(85,77,210)' },
{ name: '熊猫新产品', type: '熊猫新产品', subTitle: "PANDA'S NEW PRODUCT" , color: 'rgb(12,103,205)'}, { name: '熊猫新产品', type: '熊猫新产品', subTitle: "PANDA'S NEW PRODUCT", color: 'rgb(12,103,205)' },
{ name: '项目案例', type: '项目案例', subTitle: 'PROJECT CASE' , color: 'rgb(107,36,155)'}, { name: '项目案例', type: '项目案例', subTitle: 'PROJECT CASE', color: 'rgb(107,36,155)' },
]; ];
// let loginAction = null; // let loginAction = null;
const BootPage = props => { const BootPage = props => {
const [Industries] = useState(props.global.userInfo.Industries);
const [percentNum, setPercentNum] = useState(0); const [percentNum, setPercentNum] = useState(0);
const [currentType, setCurrentType] = useState(''); const [currentType, setCurrentType] = useState('');
// const [loadding, setLoadding] = useState(false); // const [loadding, setLoadding] = useState(false);
...@@ -45,23 +46,21 @@ const BootPage = props => { ...@@ -45,23 +46,21 @@ const BootPage = props => {
const handlePage = useCallback( const handlePage = useCallback(
(event, type) => { (event, type) => {
setPercentNum(Math.ceil(Math.random()*50)); setPercentNum(Math.ceil(Math.random() * 50));
setCurrentType(type); setCurrentType(type);
event.persist(); event.persist();
event.preventDefault(); event.preventDefault();
// 新增熊猫新产品引导页 // 新增熊猫新产品引导页
if(type === '熊猫新产品') { if (type === '熊猫新产品') {
setTimeout(() => { setTimeout(() => {
setPercentNum(100); setPercentNum(100);
setTimeout(() => { setTimeout(() => {
window.history.pushState('', null , `/cloud/introduction/newproducts`); window.history.pushState('', null, `/cloud/introduction/newproducts`);
}, 500); }, 500);
}) });
return; return;
} }
...@@ -75,11 +74,10 @@ const BootPage = props => { ...@@ -75,11 +74,10 @@ 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);
}, },
[loginAction, props.global.token, props.instance], [loginAction, props.global, props.instance],
); );
const renderIndustries = (config, callback) => const renderIndustries = (config, callback) =>
industries.map(item => { industries.map(item => {
if ( if (
...@@ -98,17 +96,16 @@ const BootPage = props => { ...@@ -98,17 +96,16 @@ const BootPage = props => {
<span className={styles.bootPageNameEng}>{item.subTitle}</span> <span className={styles.bootPageNameEng}>{item.subTitle}</span>
</div> </div>
</div> </div>
{ {currentType === item.type && (
currentType === item.type && <Progress <Progress
style={{width: '98%'}} style={{ width: '98%' }}
strokeColor={item.color} strokeColor={item.color}
percent={percentNum} percent={percentNum}
status="active" status="active"
format={percent => <span style={{color: '#fff'}}>{percent}%</span>} format={percent => <span style={{ color: '#fff' }}>{percent}%</span>}
className={styles.bootProgress} className={styles.bootProgress}
/> />
} )}
</li> </li>
); );
} }
...@@ -129,19 +126,16 @@ const BootPage = props => { ...@@ -129,19 +126,16 @@ const BootPage = props => {
window.addEventListener('resize', handleResize); window.addEventListener('resize', handleResize);
const handleToggleIndustry = event => { const handleToggleIndustry = event => {
setPercentNum(98) setPercentNum(98);
setTimeout(() => { setTimeout(() => {
props.history.push(`/?client=${props.global.client}`) props.history.push(`/?client=${props.global.client}`);
}, 1000) }, 1000);
// window.share.event.emit('triggerMicro', props.global); // window.share.event.emit('triggerMicro', props.global);
props.updateCurrentIndex(0); props.updateCurrentIndex(0);
defaultApp(); defaultApp();
}; };
loginAction.events.on('toggleIndustry', handleToggleIndustry); loginAction.events.on('toggleIndustry', handleToggleIndustry);
...@@ -152,27 +146,26 @@ const BootPage = props => { ...@@ -152,27 +146,26 @@ const BootPage = props => {
}, [loginAction.events, props, currentType]); }, [loginAction.events, props, currentType]);
useEffect(() => { useEffect(() => {
window.share.event.on('visible' , ret => { window.share.event.on('visible', ret => {
setTimeout(() => { setTimeout(() => {
setPercentNum(100); setPercentNum(100);
setTimeout(() => { setTimeout(() => {
window.history.pushState(null, '', ret); window.history.pushState(null, '', ret);
}, 500); }, 500);
}, 500) }, 500);
}) });
}, []);
}, [])
const [IndustryNum, setIndustryNum] = useState(0); const [IndustryNum, setIndustryNum] = useState(0);
const renderIndustr = useMemo(() => renderIndustries(props.global, handlePage), [handlePage, props.global.token, currentType, percentNum]); // const renderIndustr = useMemo(() => renderIndustries(props.global, handlePage), [handlePage, props.global.token, percentNum, currentType]);
useEffect(() => { useEffect(() => {
const NewIndustryNum = const NewIndustryNum =
props.global && props.global.userInfo && props.global.userInfo.Industries props.global && props.global.userInfo && props.global.userInfo.Industries
? props.global.userInfo.Industries.filter(item => !!industries.find(d => d.type === item)).length ? props.global.userInfo.Industries.filter(item => !!industries.find(d => d.type === item)).length
: 0; : 0;
setIndustryNum(NewIndustryNum); setIndustryNum(NewIndustryNum);
}, [handlePage, props.global.token]); }, [handlePage, props.global, props.global.token]);
const intl = useIntl(); const intl = useIntl();
const toOMSUsingAnalysis = e => { const toOMSUsingAnalysis = e => {
e && e.stopPropagation(); e && e.stopPropagation();
...@@ -201,7 +194,7 @@ const BootPage = props => { ...@@ -201,7 +194,7 @@ const BootPage = props => {
{/* eslint-disable-next-line jsx-a11y/alt-text */} {/* eslint-disable-next-line jsx-a11y/alt-text */}
<img src="https://panda-water.cn/web4/assets/images/bootPage/熊猫图标.png" /> <img src="https://panda-water.cn/web4/assets/images/bootPage/熊猫图标.png" />
<div className={styles.bootPageTitle}> <div className={styles.bootPageTitle}>
<span className={styles.bootPageZh}>{'熊猫智慧水务一体化解决方案'}</span> <span className={styles.bootPageZh}>熊猫智慧水务一体化解决方案</span>
<span className={styles.bootPageEn}>Panda Smart Water Integration Platform & Solution</span> <span className={styles.bootPageEn}>Panda Smart Water Integration Platform & Solution</span>
</div> </div>
</header> </header>
...@@ -220,12 +213,40 @@ const BootPage = props => { ...@@ -220,12 +213,40 @@ const BootPage = props => {
opacity: 1, opacity: 1,
}} }}
> >
{renderIndustr} {industries.map(
item =>
props.global &&
<li
className={styles.bootPageLi}
key={item.type}
style={{display: Industries.indexOf(item.type) > -1 ? 'block' : 'none'}}
onClick={event => handlePage(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>
),
)}
)}
</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}>
......
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