@@ -43,10 +43,10 @@ export default class Router extends React.Component<Props, State> {
4343 this . router = props . router ;
4444 this . history = props . history ;
4545 }
46- static async init ( { path, routes, hooks, ctx = new Context ( ) } ) {
46+ static async init ( { path, routes, hooks, silent = false , ctx = new Context ( ) } ) {
4747 const plainRoutes = Router . buildRoutes ( routes ) ;
4848 const router = new RouterAsync ( { routes : plainRoutes , hooks } ) ;
49- const { route, status, params, redirect, result } = await router . resolve ( { path, ctx } ) ;
49+ const { route, status, params, redirect, result } = await router . run ( { path, ctx, silent } ) ;
5050 let props = {
5151 path,
5252 route,
@@ -66,26 +66,14 @@ export default class Router extends React.Component<Props, State> {
6666 }
6767 }
6868 static buildRoutes ( routes ) {
69- if ( ! Array . isArray ( routes ) ) {
70- routes = routes . props . children ;
71- }
69+ if ( ! Array . isArray ( routes ) ) routes = routes . props . children ;
7270 return deepMap ( routes , route => {
7371 const result : Route = { } ;
74- if ( route . props . path ) {
75- result . path = route . props . path ;
76- }
77- if ( route . props . action ) {
78- result . action = route . props . action ;
79- }
80- if ( route . props . status ) {
81- result . status = route . props . status ;
82- }
83- if ( route . props . to ) {
84- result . to = route . props . to ;
85- }
86- if ( route . props . children ) {
87- result . childs = Array . isArray ( route . props . children ) ? route . props . children : [ route . props . children ] ;
88- }
72+ if ( route . props . path ) result . path = route . props . path ;
73+ if ( route . props . action ) result . action = route . props . action ;
74+ if ( route . props . status ) result . status = route . props . status ;
75+ if ( route . props . to ) result . to = route . props . to ;
76+ if ( route . props . children ) result . childs = Array . isArray ( route . props . children ) ? route . props . children : [ route . props . children ] ;
8977 return result ;
9078 } ) ;
9179 }
@@ -126,7 +114,7 @@ export default class Router extends React.Component<Props, State> {
126114 }
127115 private _locationChanged = async ( location , action ) => {
128116 try {
129- const { path, route, status, params, redirect, result, ctx } = await this . router . resolve ( { path : location . pathname } ) ;
117+ const { path, route, status, params, redirect, result, ctx } = await this . router . run ( { path : location . pathname } ) ;
130118 let props = {
131119 path,
132120 route,
0 commit comments