提交 a5aea730 authored 作者: vipcxj's avatar vipcxj

fix: rn端processError无法阻止错误继续传递。

fix:navigator.js中跳转方法过时导致无效。
上级 3c365f1a
...@@ -8,12 +8,15 @@ function setContainer(container: Object) { ...@@ -8,12 +8,15 @@ function setContainer(container: Object) {
_container = container; _container = container;
} }
function back() {
_container.props.navigation.dispatch(NavigationActions.back());
}
function reset(routeName: string, params?: NavigationParams) { function reset(routeName: string, params?: NavigationParams) {
_container.dispatch(NavigationActions.reset({ _container.props.navigation.dispatch(NavigationActions.reset({
index: 0, index: 0,
actions: [ actions: [
NavigationActions.navigate({ NavigationActions.navigate({
type: 'Navigation/NAVIGATE',
routeName, routeName,
params, params,
}), }),
...@@ -22,18 +25,16 @@ function reset(routeName: string, params?: NavigationParams) { ...@@ -22,18 +25,16 @@ function reset(routeName: string, params?: NavigationParams) {
} }
function navigate(routeName: string, params?: NavigationParams) { function navigate(routeName: string, params?: NavigationParams) {
_container.dispatch(NavigationActions.navigate({ _container.props.navigation.dispatch(NavigationActions.navigate({
type: 'Navigation/NAVIGATE',
routeName, routeName,
params, params,
})); }));
} }
function navigateDeep(actions: { routeName: string, params?: NavigationParams }[]) { function navigateDeep(actions: { routeName: string, params?: NavigationParams }[]) {
_container.dispatch(actions.reduceRight( _container.props.navigation.dispatch(actions.reduceRight(
(prevAction, action): any => (prevAction, action): any =>
NavigationActions.navigate({ NavigationActions.navigate({
type: 'Navigation/NAVIGATE',
routeName: action.routeName, routeName: action.routeName,
params: action.params, params: action.params,
action: prevAction, action: prevAction,
...@@ -54,6 +55,7 @@ export default { ...@@ -54,6 +55,7 @@ export default {
setContainer, setContainer,
navigateDeep, navigateDeep,
navigate, navigate,
back,
reset, reset,
getCurrentRoute, getCurrentRoute,
}; };
...@@ -15,17 +15,22 @@ const errStyle = { ...@@ -15,17 +15,22 @@ const errStyle = {
}; };
export function processError(err) { export function processError(err) {
if (err && err.data) { if (err) {
const { data } = err; if (err.preventDefault) {
switch (data.errorCode) { err.preventDefault();
case errorCodes.no_such_user: }
Toast.fail('用户不存在!'); if (err.data) {
break; const { data } = err;
case errorCodes.invalid_token: switch (data.errorCode) {
navigate('Login'); case errorCodes.no_such_user:
break; Toast.fail('用户不存在!');
default: break;
showError(err); case errorCodes.invalid_token:
navigate('Login');
break;
default:
showError(err);
}
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论