Commit 1d74834f by zhaochengxiang

增加网络请求错误提示

parent 837b3fbe
import { createStore, applyMiddleware } from 'redux' import { createStore, applyMiddleware } from 'redux'
import createSagaMiddleware from 'redux-saga' import createSagaMiddleware from 'redux-saga'
import { all, call, takeLatest, takeEvery, cancelled } from 'redux-saga/effects' import { all, call, takeLatest, takeEvery, cancelled } from 'redux-saga/effects'
import { message } from 'antd'
import { SetSource, Cancel } from '../util/axios' import { SetSource, Cancel } from '../util/axios'
import { Connect } from '../util'; import { Connect, showMessage } from '../util';
import { reducers } from './reducer'; import { reducers } from './reducer';
import * as user from './user'; import * as user from './user';
import * as map from './map'; import * as map from './map';
...@@ -21,7 +20,7 @@ function* request(args) { ...@@ -21,7 +20,7 @@ function* request(args) {
if (callback) if (callback)
yield call(callback, rs) yield call(callback, rs)
} catch (ex) { } catch (ex) {
ex.ApiError && ex.ApiError.message && message.error(ex.ApiError.message); ex.ApiError && ex.ApiError.cnMessage && showMessage('error', ex.ApiError.cnMessage);
error && error(ex); error && error(ex);
}finally { }finally {
if (yield cancelled()) { if (yield cancelled()) {
......
...@@ -95,11 +95,7 @@ const callback = resp => { ...@@ -95,11 +95,7 @@ const callback = resp => {
return null; return null;
} }
else if (resp.status !== 200) { else if (resp.status !== 200) {
if (resp && resp.data && resp.data.ApiError && resp.data.ApiError.cnMessage) { throw resp.data;
showMessage('warn', resp.data.ApiError.cnMessage||'');
}
return null;
} }
return resp.data || resp; return resp.data || resp;
......
...@@ -43,6 +43,9 @@ class MapContent extends React.Component { ...@@ -43,6 +43,9 @@ class MapContent extends React.Component {
}, () => { }, () => {
this.setAllTreeGraphState(data||[]); this.setAllTreeGraphState(data||[]);
}); });
},
error: () => {
this.setState({ loading: false })
} }
}) })
}) })
......
...@@ -28,6 +28,9 @@ class Map extends React.Component { ...@@ -28,6 +28,9 @@ class Map extends React.Component {
loadingTopics: false, loadingTopics: false,
topics: data topics: data
}); });
},
error: () => {
this.setState({ loadingTopics: false });
} }
}) })
}) })
......
...@@ -63,6 +63,9 @@ class ImportMetadata extends React.Component { ...@@ -63,6 +63,9 @@ class ImportMetadata extends React.Component {
} else { } else {
this.setState({ loadingSystem: false }); this.setState({ loadingSystem: false });
} }
},
error: () => {
this.setState({ loadingSystem: false });
} }
}) })
}) })
...@@ -88,6 +91,9 @@ class ImportMetadata extends React.Component { ...@@ -88,6 +91,9 @@ class ImportMetadata extends React.Component {
}, },
callback: dbs => { callback: dbs => {
this.setState({ loadingDb: false, dbs: dbs||[], db: '', schema: '' }) this.setState({ loadingDb: false, dbs: dbs||[], db: '', schema: '' })
},
erorr: () => {
this.setState({ loadingDb: false });
} }
}); });
}); });
...@@ -112,6 +118,9 @@ class ImportMetadata extends React.Component { ...@@ -112,6 +118,9 @@ class ImportMetadata extends React.Component {
}, },
callback: schemas => { callback: schemas => {
this.setState({ loadingSchema: false, schemas, schema: '' }); this.setState({ loadingSchema: false, schemas, schema: '' });
},
error: () => {
this.setState({ loadingSchema: false });
} }
}); });
}) })
...@@ -158,6 +167,9 @@ class ImportMetadata extends React.Component { ...@@ -158,6 +167,9 @@ class ImportMetadata extends React.Component {
}, },
callback: data => { callback: data => {
this.setState({ loadingDataTable: false, dataTables: (data||[]).content||[], totalDataTables: (data||[]).totalElements||0 }) this.setState({ loadingDataTable: false, dataTables: (data||[]).content||[], totalDataTables: (data||[]).totalElements||0 })
},
error: () => {
this.setState({ loadingDataTable: false });
} }
}); });
}) })
...@@ -179,6 +191,9 @@ class ImportMetadata extends React.Component { ...@@ -179,6 +191,9 @@ class ImportMetadata extends React.Component {
}, },
callback: data => { callback: data => {
this.setState({ loadingDataFiled: false, dataFileds: data||[] }) this.setState({ loadingDataFiled: false, dataFileds: data||[] })
},
error: () => {
this.setState({ loadingDataFiled: false });
} }
}); });
}) })
......
...@@ -83,6 +83,9 @@ const ImportModal = (props) => { ...@@ -83,6 +83,9 @@ const ImportModal = (props) => {
setConfirmLoading(false); setConfirmLoading(false);
setHints(data||[]); setHints(data||[]);
setStep(step+1); setStep(step+1);
},
error: () => {
setConfirmLoading(false);
} }
}) })
} }
...@@ -123,8 +126,14 @@ const ImportModal = (props) => { ...@@ -123,8 +126,14 @@ const ImportModal = (props) => {
setConfirmLoading(false); setConfirmLoading(false);
reset(); reset();
onCancel && onCancel(true); onCancel && onCancel(true);
},
error: () => {
setConfirmLoading(false);
} }
}) })
},
error: () => {
setConfirmLoading(false);
} }
}) })
...@@ -231,6 +240,7 @@ const ImportModal = (props) => { ...@@ -231,6 +240,7 @@ const ImportModal = (props) => {
return ( return (
<Modal <Modal
forceRender
visible={visible} visible={visible}
title={title} title={title}
width={1000} width={1000}
......
...@@ -65,6 +65,9 @@ const ModelTree = (props) => { ...@@ -65,6 +65,9 @@ const ModelTree = (props) => {
itemRef.current = firstItem; itemRef.current = firstItem;
onSelect && onSelect(firstItem?(firstItem.key||''):''); onSelect && onSelect(firstItem?(firstItem.key||''):'');
},
error: () => {
setLoading(false);
} }
}) })
} }
......
...@@ -138,6 +138,9 @@ const UpdateTreeItemModal = (props) => { ...@@ -138,6 +138,9 @@ const UpdateTreeItemModal = (props) => {
if (onOk) { if (onOk) {
onOk(type==='add'?item:payload); onOk(type==='add'?item:payload);
} }
},
error: () => {
setConfirmLoading(false);
} }
}); });
} catch (errInfo) { } catch (errInfo) {
......
...@@ -43,6 +43,9 @@ class Model extends React.Component { ...@@ -43,6 +43,9 @@ class Model extends React.Component {
}, },
callback: data => { callback: data => {
this.setState({ loadingTableData: false, tableData: data.easyDataModelerDataModels||[] }); this.setState({ loadingTableData: false, tableData: data.easyDataModelerDataModels||[] });
},
error: () => {
this.setState({ loadingTableData: false });
} }
}) })
}) })
......
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