import { useRoutes } from 'react-router-dom'; import { SettingOutlined, BulbOutlined, SyncOutlined, FileSyncOutlined, UserOutlined, DownloadOutlined, FormOutlined, GlobalOutlined, } from '@ant-design/icons'; import type { MenuProps } from 'antd'; import Settings from '@/view/settings'; import Awesome from '@/view/awesome'; import UserCustom from '@/view/model/UserCustom'; import SyncPrompts from '@/view/model/SyncPrompts'; import SyncCustom from '@/view/model/SyncCustom'; import SyncRecord from '@/view/model/SyncRecord'; import Download from '@/view/download'; import Notes from '@/view/notes'; import Markdown from '@/view/markdown'; export type ChatRouteMetaObject = { label: string; icon?: React.ReactNode; }; type ChatRouteObject = { path: string; element?: JSX.Element; hideMenu?: boolean; meta?: ChatRouteMetaObject; children?: ChatRouteObject[]; }; export const routes: Array = [ { path: '/', element: , meta: { label: 'Awesome', icon: , }, }, { path: '/notes', element: , meta: { label: 'Notes', icon: , }, }, { path: '/md/:id', element: , hideMenu: true, }, { path: '/model', meta: { label: 'Language Model', icon: , }, children: [ { path: 'user-custom', element: , meta: { label: 'User Custom', icon: , }, }, // --- Sync { path: 'sync-prompts', element: , meta: { label: 'Sync Prompts', icon: , }, }, { path: 'sync-custom', element: , meta: { label: 'Sync Custom', icon: , }, }, { path: 'sync-custom/:id', element: , hideMenu: true, }, ], }, { path: 'download', element: , meta: { label: 'Download', icon: , }, }, { path: '/settings', element: , meta: { label: 'Settings', icon: , }, }, ]; type MenuItem = Required['items'][number]; export const menuItems: MenuItem[] = routes .filter((j) => !j.hideMenu) .map((i) => ({ ...i.meta, key: i.path || '', children: i?.children ?.filter((j) => !j.hideMenu) ?.map((j) => ({ ...j.meta, key: `${i.path}/${j.path}` || '' })), })); export default () => { return useRoutes(routes); };