mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Refactor asyncRouteType to appType
This commit is contained in:
parent
0d9b2cf276
commit
93ef17a132
5 changed files with 38 additions and 39 deletions
|
@ -1,10 +1,6 @@
|
|||
import type { RouteObject } from 'react-router-dom';
|
||||
|
||||
export enum AsyncRouteType {
|
||||
Stable,
|
||||
Experimental,
|
||||
Dashboard
|
||||
}
|
||||
import { AppType } from 'constants/appType';
|
||||
|
||||
export interface AsyncRoute {
|
||||
/** The URL path for this route. */
|
||||
|
@ -14,25 +10,18 @@ export interface AsyncRoute {
|
|||
* Will fallback to using the `path` value if not specified.
|
||||
*/
|
||||
page?: string
|
||||
/** The page type used to load the correct page element. */
|
||||
type?: AsyncRouteType
|
||||
/** The app that this page is part of. */
|
||||
type?: AppType
|
||||
}
|
||||
|
||||
const importRoute = (page: string, type: AsyncRouteType) => {
|
||||
switch (type) {
|
||||
case AsyncRouteType.Dashboard:
|
||||
return import(/* webpackChunkName: "[request]" */ `../../apps/dashboard/routes/${page}`);
|
||||
case AsyncRouteType.Experimental:
|
||||
return import(/* webpackChunkName: "[request]" */ `../../apps/experimental/routes/${page}`);
|
||||
case AsyncRouteType.Stable:
|
||||
return import(/* webpackChunkName: "[request]" */ `../../apps/stable/routes/${page}`);
|
||||
}
|
||||
const importRoute = (page: string, type: AppType) => {
|
||||
return import(/* webpackChunkName: "[request]" */ `../../apps/${type}/routes/${page}`);
|
||||
};
|
||||
|
||||
export const toAsyncPageRoute = ({
|
||||
path,
|
||||
page,
|
||||
type = AsyncRouteType.Stable
|
||||
type = AppType.Stable
|
||||
}: AsyncRoute): RouteObject => {
|
||||
return {
|
||||
path,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue