@@ -43,10 +43,10 @@ export default class Router extends React.Component<Props, State> {
43
43
this . router = props . router ;
44
44
this . history = props . history ;
45
45
}
46
- static async init ( { path, routes, hooks, ctx = new Context ( ) } ) {
46
+ static async init ( { path, routes, hooks, silent = false , ctx = new Context ( ) } ) {
47
47
const plainRoutes = Router . buildRoutes ( routes ) ;
48
48
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 } ) ;
50
50
let props = {
51
51
path,
52
52
route,
@@ -66,26 +66,14 @@ export default class Router extends React.Component<Props, State> {
66
66
}
67
67
}
68
68
static buildRoutes ( routes ) {
69
- if ( ! Array . isArray ( routes ) ) {
70
- routes = routes . props . children ;
71
- }
69
+ if ( ! Array . isArray ( routes ) ) routes = routes . props . children ;
72
70
return deepMap ( routes , route => {
73
71
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 ] ;
89
77
return result ;
90
78
} ) ;
91
79
}
@@ -126,7 +114,7 @@ export default class Router extends React.Component<Props, State> {
126
114
}
127
115
private _locationChanged = async ( location , action ) => {
128
116
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 } ) ;
130
118
let props = {
131
119
path,
132
120
route,
0 commit comments