feat: 💨

This commit is contained in:
codytseng 2026-01-06 00:00:51 +08:00
parent 695f2fe017
commit ed843f637a
8 changed files with 198 additions and 197 deletions

View file

@ -8,14 +8,9 @@ import RelayPage from '@/pages/primary/RelayPage'
import SearchPage from '@/pages/primary/SearchPage'
import SettingsPage from '@/pages/primary/SettingsPage'
import { TPageRef } from '@/types'
import { createRef, ForwardRefExoticComponent, RefAttributes } from 'react'
import { createRef } from 'react'
type RouteConfig = {
key: string
component: ForwardRefExoticComponent<RefAttributes<TPageRef>>
}
const PRIMARY_ROUTE_CONFIGS: RouteConfig[] = [
const PRIMARY_ROUTE_CONFIGS = [
{ key: 'home', component: NoteListPage },
{ key: 'explore', component: ExplorePage },
{ key: 'notifications', component: NotificationListPage },
@ -25,7 +20,7 @@ const PRIMARY_ROUTE_CONFIGS: RouteConfig[] = [
{ key: 'search', component: SearchPage },
{ key: 'bookmark', component: BookmarkPage },
{ key: 'settings', component: SettingsPage }
]
] as const
export const PRIMARY_PAGE_REF_MAP = PRIMARY_ROUTE_CONFIGS.reduce(
(acc, { key }) => {
@ -40,7 +35,7 @@ export const PRIMARY_PAGE_MAP = PRIMARY_ROUTE_CONFIGS.reduce(
acc[key] = <Component ref={PRIMARY_PAGE_REF_MAP[key]} />
return acc
},
{} as Record<string, JSX.Element>
{} as Record<(typeof PRIMARY_ROUTE_CONFIGS)[number]['key'], JSX.Element>
)
export type TPrimaryPageName = keyof typeof PRIMARY_PAGE_MAP