diff --git a/src/layout/DefaultLayout/Desktop/SideBar/Avatar.tsx b/src/app/(main)/@nav/_layout/Desktop/Avatar.tsx similarity index 100% rename from src/layout/DefaultLayout/Desktop/SideBar/Avatar.tsx rename to src/app/(main)/@nav/_layout/Desktop/Avatar.tsx diff --git a/src/layout/DefaultLayout/Desktop/SideBar/BottomActions.tsx b/src/app/(main)/@nav/_layout/Desktop/BottomActions.tsx similarity index 100% rename from src/layout/DefaultLayout/Desktop/SideBar/BottomActions.tsx rename to src/app/(main)/@nav/_layout/Desktop/BottomActions.tsx diff --git a/src/layout/DefaultLayout/Desktop/SideBar/TopActions.tsx b/src/app/(main)/@nav/_layout/Desktop/TopActions.tsx similarity index 100% rename from src/layout/DefaultLayout/Desktop/SideBar/TopActions.tsx rename to src/app/(main)/@nav/_layout/Desktop/TopActions.tsx diff --git a/src/layout/DefaultLayout/Desktop/SideBar/index.tsx b/src/app/(main)/@nav/_layout/Desktop/index.tsx similarity index 67% rename from src/layout/DefaultLayout/Desktop/SideBar/index.tsx rename to src/app/(main)/@nav/_layout/Desktop/index.tsx index 24fe8b41167b7..1d1ef6aaf2563 100644 --- a/src/layout/DefaultLayout/Desktop/SideBar/index.tsx +++ b/src/app/(main)/@nav/_layout/Desktop/index.tsx @@ -1,17 +1,16 @@ +'use client'; + import { SideNav } from '@lobehub/ui'; import { memo } from 'react'; -import { SidebarTabKey } from '@/store/global/initialState'; +import { useActiveTabKey } from '@/hooks/useActiveTabKey'; import Avatar from './Avatar'; import BottomActions from './BottomActions'; import TopActions from './TopActions'; -interface Props { - sidebarKey?: SidebarTabKey; -} - -export default memo(({ sidebarKey }) => { +const Nav = memo(() => { + const sidebarKey = useActiveTabKey(); return ( } @@ -21,3 +20,7 @@ export default memo(({ sidebarKey }) => { /> ); }); + +Nav.displayName = 'DesktopNav'; + +export default Nav; diff --git a/src/app/(main)/@nav/_layout/Mobile.tsx b/src/app/(main)/@nav/_layout/Mobile.tsx new file mode 100644 index 0000000000000..c62aa07ad868c --- /dev/null +++ b/src/app/(main)/@nav/_layout/Mobile.tsx @@ -0,0 +1,71 @@ +'use client'; + +import { Icon, MobileTabBar, type MobileTabBarProps } from '@lobehub/ui'; +import { createStyles } from 'antd-style'; +import { Bot, MessageSquare, User } from 'lucide-react'; +import { useRouter } from 'next/navigation'; +import { rgba } from 'polished'; +import { memo, useMemo } from 'react'; +import { useTranslation } from 'react-i18next'; + +import { useActiveTabKey } from '@/hooks/useActiveTabKey'; +import { SidebarTabKey } from '@/store/global/initialState'; + +const useStyles = createStyles(({ css, token }) => ({ + active: css` + svg { + fill: ${rgba(token.colorPrimary, 0.33)}; + } + `, + container: css` + position: fixed; + z-index: 100; + right: 0; + bottom: 0; + left: 0; + `, +})); + +const Nav = memo(() => { + const { t } = useTranslation('common'); + const { styles } = useStyles(); + const activeKey = useActiveTabKey(); + const router = useRouter(); + const items: MobileTabBarProps['items'] = useMemo( + () => [ + { + icon: (active) => ( + + ), + key: SidebarTabKey.Chat, + onClick: () => { + router.push('/chat'); + }, + title: t('tab.chat'), + }, + { + icon: (active) => , + key: SidebarTabKey.Market, + onClick: () => { + router.push('/market'); + }, + title: t('tab.market'), + }, + { + icon: (active) => , + key: SidebarTabKey.Setting, + onClick: () => { + router.push('/settings'); + }, + title: t('tab.setting'), + }, + ], + [t], + ); + + return ; +}); + +Nav.displayName = 'MobileNav'; + +export default Nav; diff --git a/src/app/(main)/@nav/default.tsx b/src/app/(main)/@nav/default.tsx new file mode 100644 index 0000000000000..8976223be15db --- /dev/null +++ b/src/app/(main)/@nav/default.tsx @@ -0,0 +1,16 @@ +import { isMobileDevice } from '@/utils/responsive'; + +import Desktop from './_layout/Desktop'; +import Mobile from './_layout/Mobile'; + +const Default = () => { + const mobile = isMobileDevice(); + + const Nav = mobile ? Mobile : Desktop; + + return