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
|
|
|
}
|
|
|
|
}
|
2018-12-05 04:43:07 +08:00
|
|
|
|
|
|
|
public async search(searchText: string) {
|
|
|
|
return this._router.navigate(['search', searchText]);
|
|
|
|
}
|
2017-07-09 18:03:17 +08:00
|
|
|
}
|