This commit is contained in:
oneao committed 2026-01-28 22:32:28 +08:00
1 parent d9c49b34db
commit d33cef825a
36 files changed
+753 -1077

No files matched your search

@@ -69,16 +69,6 @@ export default function StaticTransactions({
data: group.records,
}))
if (records.length === 0) {
return (
<EmptyState
type="empty"
title="暂无记账记录"
description="快去添加你的第一笔记账吧 "
/>
)
}
return (
<SectionList
sections={sections}
@@ -90,6 +80,15 @@ export default function StaticTransactions({
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={handleRefresh} />
}
ListEmptyComponent={() => (
<View className="flex-1 justify-center py-20">
<EmptyState
type="empty"
title="暂无记账记录"
description="快去添加你的第一笔记账吧"
/>
</View>
)}
renderSectionHeader={({ section }) => (
<View className="bg-white py-2 px-4 border-b border-gray-50">
<View className="flex-row items-center justify-between">
@@ -5,7 +5,7 @@ import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
import { ADatePicker, ADrawer, AListItem, LucideIcon } from '@/components/common/ao'
import { Fab, FabIcon } from '@/components/ui/fab'
import { AddIcon } from '@/components/ui/icon'
import { queryMoneyRecordsApi } from '@/request/api/money/record'
import { deleteMoneyRecordApi, listMoneyRecordsApi } from '@/request/api/money/record'
import { useMoneyRecordStore } from '@/store/moneyRecord'
import { getCurrentYearMonth } from '@/utils/time'
import { toast } from '@/utils/toast'
@@ -26,12 +26,11 @@ export default function Money() {
// 操作菜单
const [showActionsMenu, setShowActionsMenu] = useState(false)
function getMoneyRecords() {
queryMoneyRecordsApi({
function fetchMoneyRecords() {
listMoneyRecordsApi({
record_time: searchParams.record_time,
}).then((res) => {
if (res.isSuccess) {
console.log(res.data.records)
moneyRecordStore.setRecords(res.data.records || [], searchParams.record_time)
}
else {
@@ -43,18 +42,20 @@ export default function Money() {
console.log(err)
})
}
useFocusEffect(
useCallback(() => {
// 页面显示 / 返回时
console.log('===show===')
return () => {
// 页面离开(可选)
}
}, []),
fetchMoneyRecords()
}, [searchParams.record_time]),
)
async function handleDeleteRecord(id: number) {
await deleteMoneyRecordApi({
id,
})
fetchMoneyRecords()
}
return (
<View
className="flex-1"
@@ -129,22 +130,6 @@ export default function Money() {
</Text>
</View>
</View>
{/* <View
className="flex-row items-center gap-3 mt-2"
style={{
borderBottomLeftRadius: 8,
borderBottomRightRadius: 8,
}}
>
<Text className="text-sm text-gray-600 text-right">预算</Text>
<View className="flex-1">
<Progress size="sm">
<ProgressFilledTrack />
</Progress>
</View>
<Text className="text-xs text-blue-500">点击设置</Text>
</View> */}
</View>
</View>
@@ -164,10 +149,10 @@ export default function Money() {
})
}}
onDelete={(id) => {
moneyRecordStore.deleteMoneyRecord(id)
handleDeleteRecord(id)
}}
onRefreshData={() => {
getMoneyRecords()
fetchMoneyRecords()
}}
/>
</View>