diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index bfe2a80e82655cc2ba8569654d0d01d4a93c5033..68171dbb54b13107eba3450004561539da18e9db 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -44,6 +44,9 @@ class BasicLayout extends React.PureComponent { type: 'user/fetchCurrent', }); } + componentWillUnmount() { + clearTimeout(this.resizeTimeout); + } onCollapse = (collapsed) => { this.props.dispatch({ type: 'global/changeLayoutCollapsed', @@ -170,9 +173,11 @@ class BasicLayout extends React.PureComponent { type: 'global/changeLayoutCollapsed', payload: !collapsed, }); - const event = document.createEvent('HTMLEvents'); - event.initEvent('resize', true, false); - window.dispatchEvent(event); + this.resizeTimeout = setTimeout(() => { + const event = document.createEvent('HTMLEvents'); + event.initEvent('resize', true, false); + window.dispatchEvent(event); + }, 600); } handleNoticeClear = (type) => { message.success(`清空了${type}`);