mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
fix(router): loging
This commit is contained in:
@ -31,38 +31,45 @@ export class Router {
|
|||||||
|
|
||||||
componentDidLoad() {
|
componentDidLoad() {
|
||||||
this.init = true;
|
this.init = true;
|
||||||
this.onRedirectChanged();
|
console.debug('[ion-router] router did load');
|
||||||
this.onRoutesChanged();
|
this.onRedirectChanged(undefined);
|
||||||
|
this.onRoutesChanged(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listen('ionRouteRedirectChanged')
|
@Listen('ionRouteRedirectChanged')
|
||||||
protected onRedirectChanged() {
|
protected onRedirectChanged(ev: Event) {
|
||||||
if (!this.init) {
|
if (!this.init) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (ev) {
|
||||||
|
console.debug('[ion-router] route data changed', ev.target);
|
||||||
|
}
|
||||||
this.redirects = readRedirects(this.el);
|
this.redirects = readRedirects(this.el);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listen('ionRouteDataChanged')
|
@Listen('ionRouteDataChanged')
|
||||||
protected onRoutesChanged() {
|
protected onRoutesChanged(ev: Event) {
|
||||||
if (!this.init) {
|
if (!this.init) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const tree = readRoutes(this.el);
|
const tree = readRoutes(this.el);
|
||||||
this.routes = flattenRouterTree(tree);
|
this.routes = flattenRouterTree(tree);
|
||||||
console.debug('[ion-router] route data changed', this.routes);
|
|
||||||
|
|
||||||
// schedule write
|
// schedule write
|
||||||
if (this.timer) {
|
if (this.timer) {
|
||||||
cancelAnimationFrame(this.timer);
|
clearTimeout(this.timer);
|
||||||
this.timer = undefined;
|
this.timer = undefined;
|
||||||
}
|
}
|
||||||
this.timer = requestAnimationFrame(() => {
|
if (ev) {
|
||||||
|
console.debug('[ion-router] route data changed', ev.target);
|
||||||
|
this.timer = setTimeout(() => {
|
||||||
this.timer = undefined;
|
this.timer = undefined;
|
||||||
this.onPopState();
|
this.writeNavStateRoot(this.getPath(), RouterDirection.None);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.writeNavStateRoot(this.getPath(), RouterDirection.None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Listen('window:popstate')
|
@Listen('window:popstate')
|
||||||
protected onPopState() {
|
protected onPopState() {
|
||||||
@ -76,7 +83,7 @@ export class Router {
|
|||||||
|
|
||||||
const path = this.getPath();
|
const path = this.getPath();
|
||||||
console.debug('[ion-router] URL changed -> update nav', path, direction);
|
console.debug('[ion-router] URL changed -> update nav', path, direction);
|
||||||
this.writeNavStateRoot(path, direction);
|
return this.writeNavStateRoot(path, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
@ -87,13 +94,13 @@ export class Router {
|
|||||||
const { ids, outlet } = readNavState(document.body);
|
const { ids, outlet } = readNavState(document.body);
|
||||||
const chain = routerIDsToChain(ids, this.routes);
|
const chain = routerIDsToChain(ids, this.routes);
|
||||||
if (!chain) {
|
if (!chain) {
|
||||||
console.warn('no matching URL for ', ids.map(i => i.id));
|
console.warn('[ion-router] no matching URL for ', ids.map(i => i.id));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const path = chainToPath(chain);
|
const path = chainToPath(chain);
|
||||||
if (!path) {
|
if (!path) {
|
||||||
console.warn('router could not match path because some required param is missing');
|
console.warn('[ion-router] router could not match path because some required param is missing');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user