Skip to content

Commit

Permalink
fix(router): 去除没有卵用的404
Browse files Browse the repository at this point in the history
  • Loading branch information
Littly committed Dec 10, 2018
1 parent fe29c3b commit 8350ab6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
1 change: 1 addition & 0 deletions packages/taro-router/package.json
Expand Up @@ -26,6 +26,7 @@
"author": "O2Team",
"license": "MIT",
"dependencies": {
"invariant": "^2.2.4",
"resolve-pathname": "^2.2.0",
"rollup-plugin-alias": "^1.4.0",
"value-equal": "^0.4.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/taro-router/src/apis/index.ts
Expand Up @@ -12,7 +12,7 @@ interface NavigateToOption {
}

interface NavigateBackOption {
delta: number
delta?: number
success?: SuccessCallback
fail?: FailCallback
complete?: CompleteCallback
Expand Down Expand Up @@ -40,8 +40,9 @@ const createNavigateTo = (history: History) => {
}

const createNavigateBack = (history: History) => {
return function ({ delta }: NavigateBackOption = { delta: -1 }) {
return function (opts: NavigateBackOption = { delta: -1 }) {
try {
const { delta = -1 } = opts
history.go(delta)
return Promise.resolve()
} catch (e) {
Expand Down
13 changes: 0 additions & 13 deletions packages/taro-router/src/router/page404.tsx

This file was deleted.

10 changes: 4 additions & 6 deletions packages/taro-router/src/router/router.tsx
@@ -1,5 +1,6 @@
import Taro, { Component } from '@tarojs/taro-h5';
import Nerv, { PropTypes } from 'nervjs';
import invariant from 'invariant';

import { createNavigateBack, createNavigateTo, createRedirectTo } from '../apis';
import Route from './route';
Expand Down Expand Up @@ -56,12 +57,9 @@ class Router extends Component<Props, State> {
return pathname === path;
})

return matchedRoute || {
path: pathname,
componentLoader: () => import('./page404'),
isIndex: pathname === '/',
key: location.state.key
}
invariant(matchedRoute, `Can not find proper registered route for '${pathname}'`)

return matchedRoute!
}

push (toLocation: Types.Location) {
Expand Down

0 comments on commit 8350ab6

Please sign in to comment.