This commit is contained in:
oneao committed 2026-03-03 22:05:25 +08:00
1 parent c0531c1d0a
commit 46106d0c76
13 files changed
+171 -146

No files matched your search

+13 -2
View File
@@ -1,5 +1,5 @@
import type { icons } from 'lucide-react-native'
import { router } from 'expo-router'
import { router, useNavigation } from 'expo-router'
import { create } from 'zustand'
export interface NavItem {
@@ -11,8 +11,10 @@ export interface NavItem {
interface NavState {
navMenus: NavItem[]
pathname: string
replace: (p: string) => void
setPathname: (p: string) => void
navigateToAuth: () => void
navigateTo: (p: string) => void
setNavMenus: (menus: NavItem[]) => void
}
@@ -21,7 +23,7 @@ const DEFAULT_NAV_MENUS: NavItem[] = [
{ label: '恋爱记', path: '/love', icon: 'Heart' },
{ label: '聊天', path: '/chat', icon: 'MessageCircle' },
{ label: '个人中心', path: '/user', icon: 'CircleUserRound' },
{ label: '空间管理', path: '/space/manage', icon: 'Earth' },
{ label: '空间管理', path: '/space', icon: 'Earth' },
]
export const useNavStore = create<NavState>()(
@@ -37,6 +39,15 @@ export const useNavStore = create<NavState>()(
router.replace('/auth')
}
},
navigateTo: (p: string) => {
router.navigate(p)
},
replace: (p: string) => {
if (router.canDismiss()) {
router.dismissAll()
}
router.replace(p)
},
setNavMenus: navMenus => set({ navMenus }),
}),
)