1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/frontend/app/model/navigation.service.ts

37 lines
992 B
TypeScript
Raw Normal View History

2018-03-31 03:30:30 +08:00
import {Injectable} from '@angular/core';
2017-07-09 18:03:17 +08:00
2018-03-31 03:30:30 +08:00
import {Router} from '@angular/router';
import {ShareService} from '../gallery/share.service';
2017-07-09 18:03:17 +08:00
@Injectable()
export class NavigationService {
constructor(private _router: Router,
private _shareService: ShareService) {
}
public isLoginPage() {
return this._router.isActive('login', true) || this._router.isActive('shareLogin', true);
}
public async toLogin() {
await this._shareService.wait();
if (this._shareService.isSharing()) {
2018-03-31 03:30:30 +08:00
return this._router.navigate(['shareLogin'], {queryParams: {sk: this._shareService.getSharingKey()}});
2017-07-09 18:03:17 +08:00
} else {
2018-03-31 03:30:30 +08:00
return this._router.navigate(['login']);
2017-07-09 18:03:17 +08:00
}
}
public async toGallery() {
await this._shareService.wait();
if (this._shareService.isSharing()) {
2018-03-31 03:30:30 +08:00
return this._router.navigate(['gallery', ''], {queryParams: {sk: this._shareService.getSharingKey()}});
2017-07-09 18:03:17 +08:00
} else {
2018-03-31 03:30:30 +08:00
return this._router.navigate(['gallery', '']);
2017-07-09 18:03:17 +08:00
}
}
}