2022-04-05 01:37:31 +08:00
|
|
|
import { NgModule } from '@angular/core';
|
|
|
|
import {
|
|
|
|
RouterModule,
|
|
|
|
Routes,
|
|
|
|
UrlMatchResult,
|
|
|
|
UrlSegment,
|
|
|
|
} from '@angular/router';
|
|
|
|
import { LoginComponent } from './ui/login/login.component';
|
|
|
|
import { GalleryComponent } from './ui/gallery/gallery.component';
|
|
|
|
import { AdminComponent } from './ui/admin/admin.component';
|
|
|
|
import { ShareLoginComponent } from './ui/sharelogin/share-login.component';
|
|
|
|
import { QueryParams } from '../../common/QueryParams';
|
|
|
|
import { DuplicateComponent } from './ui/duplicates/duplicates.component';
|
|
|
|
import { FacesComponent } from './ui/faces/faces.component';
|
|
|
|
import { AuthGuard } from './model/network/helper/auth.guard';
|
|
|
|
import { AlbumsComponent } from './ui/albums/albums.component';
|
2016-12-27 06:36:38 +08:00
|
|
|
|
2018-12-10 05:33:52 +08:00
|
|
|
export function galleryMatcherFunction(
|
2022-04-05 01:37:31 +08:00
|
|
|
segments: UrlSegment[]
|
|
|
|
): UrlMatchResult | null {
|
2018-12-10 05:33:52 +08:00
|
|
|
if (segments.length === 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
const path = segments[0].path;
|
|
|
|
|
|
|
|
const posParams: { [key: string]: UrlSegment } = {};
|
|
|
|
if (path === 'gallery') {
|
|
|
|
if (segments.length > 1) {
|
|
|
|
posParams[QueryParams.gallery.directory] = segments[1];
|
|
|
|
}
|
2022-04-05 01:37:31 +08:00
|
|
|
return {
|
|
|
|
consumed: segments.slice(0, Math.min(segments.length, 2)),
|
|
|
|
posParams,
|
|
|
|
};
|
2018-12-10 05:33:52 +08:00
|
|
|
}
|
|
|
|
if (path === 'search') {
|
|
|
|
if (segments.length > 1) {
|
2021-01-31 19:22:56 +08:00
|
|
|
posParams[QueryParams.gallery.search.query] = segments[1];
|
2018-12-10 05:33:52 +08:00
|
|
|
}
|
2022-04-05 01:37:31 +08:00
|
|
|
return {
|
|
|
|
consumed: segments.slice(0, Math.min(segments.length, 2)),
|
|
|
|
posParams,
|
|
|
|
};
|
2018-12-10 05:33:52 +08:00
|
|
|
}
|
|
|
|
if (path === 'share') {
|
|
|
|
if (segments.length > 1) {
|
2020-01-08 05:17:54 +08:00
|
|
|
posParams[QueryParams.gallery.sharingKey_params] = segments[1];
|
2018-12-10 05:33:52 +08:00
|
|
|
}
|
2022-04-05 01:37:31 +08:00
|
|
|
return {
|
|
|
|
consumed: segments.slice(0, Math.min(segments.length, 2)),
|
|
|
|
posParams,
|
|
|
|
};
|
2018-12-10 05:33:52 +08:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2020-01-08 05:17:54 +08:00
|
|
|
|
2021-04-11 21:59:30 +08:00
|
|
|
const routes: Routes = [
|
2017-06-11 04:32:56 +08:00
|
|
|
{
|
|
|
|
path: 'login',
|
2022-04-05 01:37:31 +08:00
|
|
|
component: LoginComponent,
|
2017-06-11 04:32:56 +08:00
|
|
|
},
|
2017-07-04 01:17:49 +08:00
|
|
|
{
|
|
|
|
path: 'shareLogin',
|
2022-04-05 01:37:31 +08:00
|
|
|
component: ShareLoginComponent,
|
2017-07-04 01:17:49 +08:00
|
|
|
},
|
2017-06-11 04:32:56 +08:00
|
|
|
{
|
|
|
|
path: 'admin',
|
2020-01-08 05:17:54 +08:00
|
|
|
component: AdminComponent,
|
2022-04-05 01:37:31 +08:00
|
|
|
canActivate: [AuthGuard],
|
2017-06-11 04:32:56 +08:00
|
|
|
},
|
2019-01-18 07:26:20 +08:00
|
|
|
{
|
|
|
|
path: 'duplicates',
|
2020-01-08 05:17:54 +08:00
|
|
|
component: DuplicateComponent,
|
2022-04-05 01:37:31 +08:00
|
|
|
canActivate: [AuthGuard],
|
2019-01-18 07:26:20 +08:00
|
|
|
},
|
2021-05-29 03:01:59 +08:00
|
|
|
{
|
|
|
|
path: 'albums',
|
|
|
|
component: AlbumsComponent,
|
2022-04-05 01:37:31 +08:00
|
|
|
canActivate: [AuthGuard],
|
2021-05-29 03:01:59 +08:00
|
|
|
},
|
2019-02-15 07:25:55 +08:00
|
|
|
{
|
|
|
|
path: 'faces',
|
2020-01-08 05:17:54 +08:00
|
|
|
component: FacesComponent,
|
2022-04-05 01:37:31 +08:00
|
|
|
canActivate: [AuthGuard],
|
2019-02-15 07:25:55 +08:00
|
|
|
},
|
2017-06-11 04:32:56 +08:00
|
|
|
{
|
2018-12-10 05:33:52 +08:00
|
|
|
matcher: galleryMatcherFunction,
|
2020-01-08 05:17:54 +08:00
|
|
|
component: GalleryComponent,
|
2022-04-05 01:37:31 +08:00
|
|
|
canActivate: [AuthGuard],
|
2017-07-04 01:17:49 +08:00
|
|
|
},
|
2022-04-05 01:37:31 +08:00
|
|
|
{ path: '', redirectTo: '/login', pathMatch: 'full' },
|
|
|
|
{ path: '**', redirectTo: '/login', pathMatch: 'full' },
|
2016-12-27 06:36:38 +08:00
|
|
|
];
|
|
|
|
|
2021-04-11 21:59:30 +08:00
|
|
|
@NgModule({
|
|
|
|
imports: [RouterModule.forRoot(routes)],
|
2022-04-05 01:37:31 +08:00
|
|
|
exports: [RouterModule],
|
2021-04-11 21:59:30 +08:00
|
|
|
})
|
2022-04-05 01:37:31 +08:00
|
|
|
export class AppRoutingModule {}
|