chore(client): fix #8858
This commit is contained in:
parent
30bdfde4cc
commit
a50b1d69a1
2 changed files with 12 additions and 0 deletions
|
|
@ -66,6 +66,7 @@ export class Router extends EventEmitter<{
|
|||
private currentKey = Date.now().toString();
|
||||
|
||||
public currentRoute: ShallowRef<RouteDef | null> = shallowRef(null);
|
||||
public navHook: ((path: string) => boolean) | null = null;
|
||||
|
||||
constructor(routes: Router['routes'], currentPath: Router['currentPath']) {
|
||||
super();
|
||||
|
|
@ -192,6 +193,10 @@ export class Router extends EventEmitter<{
|
|||
}
|
||||
|
||||
public push(path: string) {
|
||||
if (this.navHook) {
|
||||
const cancel = this.navHook(path);
|
||||
if (cancel) return;
|
||||
}
|
||||
const beforePath = this.currentPath;
|
||||
this.navigate(path, null);
|
||||
this.emit('push', {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue