提交 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,7 +15,11 @@ const errStyle = { ...@@ -15,7 +15,11 @@ const errStyle = {
}; };
export function processError(err) { export function processError(err) {
if (err && err.data) { if (err) {
if (err.preventDefault) {
err.preventDefault();
}
if (err.data) {
const { data } = err; const { data } = err;
switch (data.errorCode) { switch (data.errorCode) {
case errorCodes.no_such_user: case errorCodes.no_such_user:
...@@ -28,6 +32,7 @@ export function processError(err) { ...@@ -28,6 +32,7 @@ export function processError(err) {
showError(err); showError(err);
} }
} }
}
} }
function showError(err) { function showError(err) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论