upd: move the prompting of the id verification from page into router

This commit is contained in:
Marie 2024-09-11 22:04:36 +02:00
parent 2eaff3388f
commit 74e720c294
No known key found for this signature in database
GPG key ID: 7ADF6C9CD9A28555
6 changed files with 54 additions and 13 deletions

View file

@ -13,6 +13,7 @@ interface RouteDefBase {
path: string;
query?: Record<string, string>;
loginRequired?: boolean;
idRequired?: boolean;
name?: string;
hash?: string;
globalCacheKey?: string;
@ -186,13 +187,14 @@ export class Router extends EventEmitter<RouterEvent> implements IRouter {
public currentRoute: ShallowRef<RouteDef>;
private currentPath: string;
private isLoggedIn: boolean;
private isNotIdConfirmed: boolean;
private notFoundPageComponent: Component;
private currentKey = Date.now().toString();
private redirectCount = 0;
public navHook: ((path: string, flag?: any) => boolean) | null = null;
constructor(routes: Router['routes'], currentPath: Router['currentPath'], isLoggedIn: boolean, notFoundPageComponent: Component) {
constructor(routes: Router['routes'], currentPath: Router['currentPath'], isLoggedIn: boolean, isNotIdConfirmed: boolean, notFoundPageComponent: Component) {
super();
this.routes = routes;
@ -201,6 +203,7 @@ export class Router extends EventEmitter<RouterEvent> implements IRouter {
this.currentRoute = shallowRef(this.current.route);
this.currentPath = currentPath;
this.isLoggedIn = isLoggedIn;
this.isNotIdConfirmed = isNotIdConfirmed;
this.notFoundPageComponent = notFoundPageComponent;
}
@ -366,6 +369,11 @@ export class Router extends EventEmitter<RouterEvent> implements IRouter {
res.props.set('showLoginPopup', true);
}
if (res.route.idRequired && this.isNotIdConfirmed) {
res.route.component = this.notFoundPageComponent;
res.props.set('showIdConfirm', true);
}
const isSamePath = beforePath === path;
if (isSamePath && key == null) key = this.currentKey;
this.current = res;