Browse Source

离开前保存修改框点击确认后使用异步逻辑确保两个dispatch的执行顺序

xiaoct 7 years ago
parent
commit
b197221bf8
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/components/dashboardDesigner/header.jsx

+ 6 - 2
src/components/dashboardDesigner/header.jsx

@@ -27,11 +27,15 @@ class Header extends React.Component {
                         title="离开前保存修改吗?"
                         title="离开前保存修改吗?"
                         visible={this.state.visibleConfirm}
                         visible={this.state.visibleConfirm}
                         onVisibleChange={this.handleVisibleChange}
                         onVisibleChange={this.handleVisibleChange}
-                        onConfirm={() => {
+                        onConfirm={async () => {
                             this.setState({
                             this.setState({
                                 visibleConfirm: false
                                 visibleConfirm: false
                             });
                             });
-                            dispatch({ type: 'dashboardDesigner/saveWithThumbnail' });
+                            try {
+                                await dispatch({ type: 'dashboardDesigner/saveWithThumbnail' });
+                            }catch(e){
+                                return e
+                            }                            
                             dispatch({ type: 'main/redirect', path: '/dashboard' });
                             dispatch({ type: 'main/redirect', path: '/dashboard' });
                         }}
                         }}
                         onCancel={() => {
                         onCancel={() => {