/* eslint-disable react-refresh/only-export-components */ import { type ComponentType, lazy, type LazyExoticComponent } from 'react'; type AppRouteComponent = LazyExoticComponent< ComponentType> >; export type AppRouteMatch = | { kind: 'platform'; } | { kind: 'shared-components'; }; export type ResolvedAppRoute = { kind: AppRouteMatch['kind']; loadingEyebrow: string; loadingText: string; Component: AppRouteComponent; }; const PlatformApp = lazy( () => import('../AuthenticatedApp'), ) as AppRouteComponent; const SharedComponentsShowcasePage = lazy( () => import('../components/shared-components/SharedComponentsShowcasePage'), ) as AppRouteComponent; export function shouldUseRecommendationRouteLoading() { return false; } export function matchAppRoute(pathname = ''): AppRouteMatch { const normalizedPath = pathname.trim().toLowerCase().replace(/\/+$/u, ''); if (normalizedPath === '/components' || normalizedPath === '/design-system') { return { kind: 'shared-components' }; } return { kind: 'platform' }; } export function resolveAppRoute(pathname = ''): ResolvedAppRoute { if (matchAppRoute(pathname).kind === 'shared-components') { return { kind: 'shared-components', loadingEyebrow: '正在载入共享组件', loadingText: '正在加载组件展示页', Component: SharedComponentsShowcasePage, }; } return { kind: 'platform', loadingEyebrow: '正在载入平台', loadingText: '正在加载内容', Component: PlatformApp, }; }