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

39 lines
1.0 KiB
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() {
2018-03-31 03:30:30 +08:00
console.log('toLogin');
2017-07-09 18:03:17 +08:00
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() {
2018-03-31 03:30:30 +08:00
console.log('toGallery');
2017-07-09 18:03:17 +08:00
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
}
}
}