u
This commit is contained in:
1 parent
00a1cce5ac
commit
c36b274976
9 files changed
+97
-197
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { create } from 'zustand'
|
||||
import { enterDefaultSpaceApi } from '@/request/api/space'
|
||||
import { useFinanceStore } from './finance'
|
||||
import { useNavStore } from './navigation'
|
||||
import { useSpaceStore } from './space'
|
||||
import { useUserStore } from './user'
|
||||
@@ -42,5 +43,6 @@ export const useAppStore = create<AppState>((set, get) => ({
|
||||
reset: () => {
|
||||
useUserStore.getState().clear()
|
||||
useSpaceStore.getState().clear()
|
||||
useFinanceStore.getState().clear()
|
||||
},
|
||||
}))
|
||||
@@ -28,6 +28,9 @@ interface FinanceState {
|
||||
getTotalBalance: () => string
|
||||
setRecords: (records: FinanceRecord[]) => void
|
||||
getRecordById: (id: number) => FinanceRecord | null
|
||||
|
||||
// 清空
|
||||
clear: () => void
|
||||
}
|
||||
|
||||
function recomputeGroups(records: FinanceRecord[]) {
|
||||
@@ -260,8 +263,9 @@ export const useFinanceStore = create<FinanceState>()(
|
||||
}),
|
||||
|
||||
ensureCategoriesLoaded: async () => {
|
||||
if (get().categories.length > 0)
|
||||
if (get().categories.length > 0) {
|
||||
return
|
||||
}
|
||||
const res = await listFinanceCategoriesApi()
|
||||
if (res.isSuccess) {
|
||||
set({ categories: res.data.categories })
|
||||
@@ -358,5 +362,12 @@ export const useFinanceStore = create<FinanceState>()(
|
||||
return null
|
||||
},
|
||||
// ================= 记录 =================
|
||||
|
||||
clear: () => {
|
||||
set({
|
||||
categories: [],
|
||||
records: [],
|
||||
})
|
||||
},
|
||||
}),
|
||||
)
|
||||
@@ -22,8 +22,8 @@ const DEFAULT_NAV_MENUS: NavItem[] = [
|
||||
{ label: '记账', path: '/finance', icon: 'CircleDollarSign' },
|
||||
// { label: '恋爱记', path: '/love', icon: 'Heart' },
|
||||
// { label: '聊天', path: '/chat', icon: 'MessageCircle' },
|
||||
{ label: '个人中心', path: '/user', icon: 'CircleUserRound' },
|
||||
{ label: '空间管理', path: '/space', icon: 'Earth' },
|
||||
{ label: '个人中心', path: '/user', icon: 'CircleUserRound' },
|
||||
]
|
||||
|
||||
export const useNavStore = create<NavState>()(
|
||||
|
||||
Reference in new issue
Block a user