From b33ebf087991c442bd15b10fcd52b2c70570413d Mon Sep 17 00:00:00 2001 From: wangxiaogang <1433729587@qq.com> Date: Thu, 11 Jun 2026 16:26:46 +0800 Subject: [PATCH] feat(t03): improve performance and UX - add category/tag caching and optimistic updates - add stats dashboard aggregation and batched tracking - add undo delete snackbar and group read-only view mode - improve app-ready timeout handling and refresh guards --- client/src/api/budget.ts | 4 +- client/src/api/stats.ts | 13 ++ .../components/AmountEditor/AmountEditor.vue | 15 ++- client/src/components/Snackbar/Snackbar.vue | 65 +++++++++ .../TransactionItem/TransactionItem.vue | 28 +++- client/src/composables/usePageReady.ts | 39 ++++++ client/src/pages.json | 12 +- client/src/pages/add/index.vue | 95 +++++++++++-- client/src/pages/admin/config.vue | 2 +- client/src/pages/admin/feedback.vue | 2 +- client/src/pages/admin/index.vue | 2 +- client/src/pages/admin/logs.vue | 2 +- client/src/pages/admin/notifications.vue | 2 +- client/src/pages/admin/track.vue | 2 +- client/src/pages/admin/users.vue | 2 +- client/src/pages/backup-manage/index.vue | 2 +- client/src/pages/bills/index.vue | 73 ++++++---- client/src/pages/budget/index.vue | 2 +- client/src/pages/category-manage/index.vue | 8 +- client/src/pages/group-manage/index.vue | 2 +- client/src/pages/index/index.vue | 70 +++++++++- client/src/pages/notifications/index.vue | 2 +- client/src/pages/profile-edit/index.vue | 2 +- client/src/pages/profile/index.vue | 2 +- client/src/pages/recurring/index.vue | 2 +- client/src/pages/stats/index.vue | 14 +- client/src/pages/tag-manage/index.vue | 2 +- client/src/stores/budget.ts | 3 +- client/src/stores/category.ts | 83 ++++++++++-- client/src/stores/group.ts | 11 +- client/src/stores/notification.ts | 11 +- client/src/stores/stats.ts | 33 ++++- client/src/stores/tag.ts | 52 ++++++-- client/src/stores/transaction.ts | 52 +++++++- client/src/utils/app-ready.ts | 10 +- client/src/utils/tracker.ts | 4 +- server/src/routes/admin.ts | 7 +- server/src/routes/budget.ts | 13 +- server/src/routes/stats.ts | 126 ++++++++++++++++++ server/src/routes/track.ts | 22 +-- 40 files changed, 761 insertions(+), 132 deletions(-) create mode 100644 client/src/components/Snackbar/Snackbar.vue create mode 100644 client/src/composables/usePageReady.ts diff --git a/client/src/api/budget.ts b/client/src/api/budget.ts index 18725b3..0900a3e 100644 --- a/client/src/api/budget.ts +++ b/client/src/api/budget.ts @@ -14,6 +14,6 @@ export function getBudget(month?: string, group_id?: number | null) { } /** 设置预算 */ -export function setBudget(amount: number, month: string) { - return request({ url: '/budget', method: 'POST', data: { amount, month } }) +export function setBudget(amount: number, month: string, group_id?: number | null) { + return request({ url: '/budget', method: 'POST', data: { amount, month, group_id } }) } diff --git a/client/src/api/stats.ts b/client/src/api/stats.ts index fcdbf5c..1e7e9a3 100644 --- a/client/src/api/stats.ts +++ b/client/src/api/stats.ts @@ -43,6 +43,19 @@ export function getTrend(month?: string, type: string = 'expense', group_id?: nu return request({ url: '/stats/trend', data: { month, type, group_id, period } }) } +/** 聚合统计(一次请求返回 overview + category + trend) */ +export interface DashboardData { + overview: Overview + category: CategoryStat[] + trend: TrendPoint[] + month: string +} + +/** 获取聚合统计数据 */ +export function getDashboard(params?: { month?: string; type?: string; period?: 'week' | 'month' | 'year'; group_id?: number | null }) { + return request({ url: '/stats/dashboard', data: params }) +} + /** 智能分类建议结果 */ export interface CategorySuggestion { category: { id: number; name: string; color: string } | null diff --git a/client/src/components/AmountEditor/AmountEditor.vue b/client/src/components/AmountEditor/AmountEditor.vue index c234653..f32c013 100644 --- a/client/src/components/AmountEditor/AmountEditor.vue +++ b/client/src/components/AmountEditor/AmountEditor.vue @@ -1,17 +1,17 @@