|
1 | 1 | import { NgModule } from '@angular/core'; |
2 | | -import { Route, RouterModule, Routes, UrlSegment, UrlSegmentGroup } from '@angular/router'; |
| 2 | +import { LoadChildrenCallback, Route, RouterModule, Routes, UrlSegment, UrlSegmentGroup } from '@angular/router'; |
3 | 3 | import { PageNotFoundComponent } from './page-not-found.component'; |
4 | 4 |
|
5 | 5 | export function urlMatcher(segments: UrlSegment[], group: UrlSegmentGroup, route: Route) { |
@@ -28,67 +28,54 @@ export const YANDERE_PATH = `yandere`; |
28 | 28 | export const PIXIV_PATH = 'pixiv'; |
29 | 29 | export const FILE_PATH = 'file'; |
30 | 30 |
|
| 31 | +const linkParserMod: LoadChildrenCallback = () => import('./link-parser/link-parser.module').then(m => m.LinkParserModule) |
| 32 | +const imgurMod: LoadChildrenCallback = () => import('./imgur/imgur.module').then(m => m.ImgurModule); |
| 33 | +const mangadexMod: LoadChildrenCallback = () => import('./mangadex/mangadex.module').then(m => m.MangadexModule); |
| 34 | +const telegraphMod = () => import('./telegraph/telegraph.module').then(m => m.TelegraphModule) |
| 35 | +const readMod = () => import('./read/read.module').then(m => m.ReadModule); |
| 36 | +const redditMod = () => import('./reddit/reddit.module').then(m => m.RedditModule) |
| 37 | +const zenkoMod = () => import('./zenko/zenko.module').then(m => m.ZenkoModule) |
| 38 | +const nhentaiMod = () => import('./nhentai/nhentai.module').then(m => m.NhentaiModule) |
| 39 | +const comickMod = () => import('./comick/comick.module').then(m => m.ComickModule) |
| 40 | +const yandereMod = () => import('./yandere/yandere.module').then(m => m.YandereModule) |
| 41 | +const pixivMod = () => import('./pixiv/pixiv.module').then(m => m.PixivModule) |
| 42 | +const fileMod = () => import('./file/file.module').then(m => m.FileModule) |
| 43 | + |
| 44 | +const COMPARE_OUTLET_NAME = 'right' |
| 45 | + |
| 46 | +const moduleMap = new Map<string, LoadChildrenCallback>() |
| 47 | + .set(IMGUR_PATH, imgurMod) |
| 48 | + .set(MANGADEX_PATH, mangadexMod) |
| 49 | + .set(TELEGRAPH_PATH, telegraphMod) |
| 50 | + |
31 | 51 | const routes: Routes = [ |
32 | | - { |
33 | | - path: '', |
34 | | - loadChildren: () => import('./link-parser/link-parser.module').then(m => m.LinkParserModule) |
35 | | - }, |
36 | | - { |
37 | | - path: LIST_PATH, |
38 | | - loadChildren: () => import('./list/list.module').then(m => m.ListModule) |
39 | | - }, |
40 | | - { |
41 | | - path: IMGUR_PATH, |
42 | | - loadChildren: () => import('./imgur/imgur.module').then(m => m.ImgurModule) |
43 | | - }, |
44 | | - { |
45 | | - path: MANGADEX_PATH, |
46 | | - loadChildren: () => import('./mangadex/mangadex.module').then(m => m.MangadexModule) |
47 | | - }, |
48 | | - { |
49 | | - path: READ_PATH, |
50 | | - loadChildren: () => import('./read/read.module').then(m => m.ReadModule) |
51 | | - }, |
52 | | - { |
53 | | - path: TELEGRAPH_PATH, |
54 | | - loadChildren: () => import('./telegraph/telegraph.module').then(m => m.TelegraphModule) |
55 | | - }, |
56 | | - { |
57 | | - path: REDDIT_PATH, |
58 | | - loadChildren: () => import('./reddit/reddit.module').then(m => m.RedditModule) |
59 | | - }, |
60 | | - { |
61 | | - path: ZENKO_PATH, |
62 | | - loadChildren: () => import('./zenko/zenko.module').then(m => m.ZenkoModule) |
63 | | - }, |
64 | | - { |
65 | | - path: NHENTAI_PATH, |
66 | | - loadChildren: () => import('./nhentai/nhentai.module').then(m => m.NhentaiModule) |
67 | | - }, |
68 | | - { |
69 | | - path: COMICK_PATH, |
70 | | - loadChildren: () => import('./comick/comick.module').then(m => m.ComickModule) |
71 | | - }, |
72 | | - { |
73 | | - path: YANDERE_PATH, |
74 | | - loadChildren: () => import('./yandere/yandere.module').then(m => m.YandereModule) |
75 | | - }, |
76 | | - { |
77 | | - path: PIXIV_PATH, |
78 | | - loadChildren: () => import('./pixiv/pixiv.module').then(m => m.PixivModule) |
79 | | - }, |
80 | | - { |
81 | | - path: FILE_PATH, |
82 | | - loadChildren: () => import('./file/file.module').then(m => m.FileModule) |
83 | | - }, |
84 | | - { |
85 | | - matcher: urlMatcher, |
86 | | - loadChildren: () => import('./link-parser/link-parser.module').then(m => m.LinkParserModule) |
87 | | - }, |
88 | | - { |
89 | | - path: '**', |
90 | | - component: PageNotFoundComponent |
91 | | - } |
| 52 | + { path: '', loadChildren: linkParserMod }, |
| 53 | + { path: LIST_PATH, loadChildren: () => import('./list/list.module').then(m => m.ListModule) }, |
| 54 | + { path: IMGUR_PATH, loadChildren: imgurMod }, |
| 55 | + { outlet: COMPARE_OUTLET_NAME, path: IMGUR_PATH, loadChildren: imgurMod }, |
| 56 | + { path: MANGADEX_PATH, loadChildren: mangadexMod }, |
| 57 | + { outlet: COMPARE_OUTLET_NAME, path: MANGADEX_PATH, loadChildren: mangadexMod }, |
| 58 | + { path: READ_PATH, loadChildren: readMod }, |
| 59 | + { outlet: COMPARE_OUTLET_NAME, path: READ_PATH, loadChildren: readMod }, |
| 60 | + { path: TELEGRAPH_PATH, loadChildren: telegraphMod }, |
| 61 | + { outlet: COMPARE_OUTLET_NAME, path: TELEGRAPH_PATH, loadChildren: telegraphMod }, |
| 62 | + { path: REDDIT_PATH, loadChildren: redditMod }, |
| 63 | + { outlet: COMPARE_OUTLET_NAME, path: REDDIT_PATH, loadChildren: redditMod }, |
| 64 | + { path: ZENKO_PATH, loadChildren: zenkoMod }, |
| 65 | + { outlet: COMPARE_OUTLET_NAME, path: ZENKO_PATH, loadChildren: zenkoMod }, |
| 66 | + { path: NHENTAI_PATH, loadChildren: nhentaiMod }, |
| 67 | + { outlet: COMPARE_OUTLET_NAME, path: NHENTAI_PATH, loadChildren: nhentaiMod }, |
| 68 | + { path: COMICK_PATH, loadChildren: comickMod }, |
| 69 | + { outlet: COMPARE_OUTLET_NAME, path: COMICK_PATH, loadChildren: comickMod }, |
| 70 | + { path: YANDERE_PATH, loadChildren: yandereMod }, |
| 71 | + { outlet: COMPARE_OUTLET_NAME, path: YANDERE_PATH, loadChildren: yandereMod }, |
| 72 | + { path: PIXIV_PATH, loadChildren: pixivMod }, |
| 73 | + { outlet: COMPARE_OUTLET_NAME, path: PIXIV_PATH, loadChildren: pixivMod }, |
| 74 | + { path: FILE_PATH, loadChildren: fileMod }, |
| 75 | + { outlet: COMPARE_OUTLET_NAME, path: FILE_PATH, loadChildren: fileMod }, |
| 76 | + { matcher: urlMatcher, loadChildren: linkParserMod }, |
| 77 | + { outlet: COMPARE_OUTLET_NAME, matcher: urlMatcher, loadChildren: linkParserMod }, |
| 78 | + { path: '**', component: PageNotFoundComponent } |
92 | 79 | ]; |
93 | 80 |
|
94 | 81 | @NgModule({ |
|
0 commit comments