From a7954f55ad7ef808d7bb62d4278a2d9fd06ef29f Mon Sep 17 00:00:00 2001 From: SunCheng Date: Sat, 14 Feb 2026 00:01:44 +0800 Subject: [PATCH] feat: remove V1 calendar/budget/stats modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 V1 前端页面 (CalendarView, BudgetView, statisticsV1) - 移除 V1 路由配置 (/calendar, /budget, /) - 清理路由守卫中的 V1 版本切换逻辑 - 移除设置页面中的版本切换功能 - 更新底部导航和登录重定向到 V2 路由 - 移除 App.vue 中 V1 页面的缓存配置 - 删除后端 TransactionRecordController.GetDailyStatisticsAsync (Obsolete) - 删除 TransactionStatisticsController.GetBalanceStatisticsAsync - 保留 V2 仍在使用的共享 API (GetUncoveredCategories, GetArchiveSummary, GetDailyStatistics) - 保留 V2 使用的全局事件监听机制 - 所有测试通过 (210/210) Breaking Change: V1 API 端点和路由将不可用 --- .../TransactionStatisticsApplication.cs | 22 - Web/src/App.vue | 8 +- Web/src/api/statistics.js | 16 - Web/src/components/GlassBottomNav.vue | 2 +- Web/src/router/index.js | 49 +- Web/src/stores/version.js | 12 +- Web/src/views/BudgetView.vue | 1006 ---------- Web/src/views/CalendarView.vue | 343 ---- Web/src/views/LoginView.vue | 4 +- Web/src/views/SettingView.vue | 68 +- Web/src/views/statisticsV1/Index.vue | 1688 ----------------- .../modules/ExpenseCategoryCard.vue | 407 ---- .../modules/IncomeNoneCategoryCard.vue | 272 --- .../TransactionStatisticsApplicationTest.cs | 51 - .../TransactionStatisticsController.cs | 14 - .../remove-v1-calendar-stats-budget/design.md | 335 ++++ .../proposal.md | 82 + .../specs/budget-api/spec.md | 130 ++ .../specs/routing/spec.md | 77 + .../specs/statistics-api/spec.md | 141 ++ .../specs/transaction-api/spec.md | 76 + .../remove-v1-calendar-stats-budget/tasks.md | 140 ++ .../v1-files-backup.txt | 31 + 23 files changed, 1028 insertions(+), 3946 deletions(-) delete mode 100644 Web/src/views/BudgetView.vue delete mode 100644 Web/src/views/CalendarView.vue delete mode 100644 Web/src/views/statisticsV1/Index.vue delete mode 100644 Web/src/views/statisticsV1/modules/ExpenseCategoryCard.vue delete mode 100644 Web/src/views/statisticsV1/modules/IncomeNoneCategoryCard.vue create mode 100644 openspec/changes/remove-v1-calendar-stats-budget/design.md create mode 100644 openspec/changes/remove-v1-calendar-stats-budget/proposal.md create mode 100644 openspec/changes/remove-v1-calendar-stats-budget/specs/budget-api/spec.md create mode 100644 openspec/changes/remove-v1-calendar-stats-budget/specs/routing/spec.md create mode 100644 openspec/changes/remove-v1-calendar-stats-budget/specs/statistics-api/spec.md create mode 100644 openspec/changes/remove-v1-calendar-stats-budget/specs/transaction-api/spec.md create mode 100644 openspec/changes/remove-v1-calendar-stats-budget/tasks.md create mode 100644 openspec/changes/remove-v1-calendar-stats-budget/v1-files-backup.txt diff --git a/Application/TransactionStatisticsApplication.cs b/Application/TransactionStatisticsApplication.cs index 6507646..6b6ffda 100644 --- a/Application/TransactionStatisticsApplication.cs +++ b/Application/TransactionStatisticsApplication.cs @@ -32,9 +32,6 @@ public interface ITransactionStatisticsApplication // === 旧接口(保留用于向后兼容,建议迁移到新接口) === - [Obsolete("请使用 GetDailyStatisticsByRangeAsync")] - Task> GetBalanceStatisticsAsync(int year, int month); - [Obsolete("请使用 GetDailyStatisticsByRangeAsync")] Task> GetDailyStatisticsAsync(int year, int month); @@ -103,25 +100,6 @@ public class TransactionStatisticsApplication( // === 旧接口实现(保留用于向后兼容) === - public async Task> GetBalanceStatisticsAsync(int year, int month) - { - var savingClassify = await configService.GetConfigByKeyAsync("SavingsCategories"); - var statistics = await statisticsService.GetDailyStatisticsAsync(year, month, savingClassify); - - var sortedStats = statistics.OrderBy(s => DateTime.Parse(s.Key)).ToList(); - var result = new List(); - decimal cumulativeBalance = 0; - - foreach (var item in sortedStats) - { - var dailyBalance = item.Value.income - item.Value.expense; - cumulativeBalance += dailyBalance; - result.Add(new BalanceStatisticsDto(DateTime.Parse(item.Key).Day, cumulativeBalance)); - } - - return result; - } - public async Task> GetDailyStatisticsAsync(int year, int month) { var savingClassify = await configService.GetConfigByKeyAsync("SavingsCategories"); diff --git a/Web/src/App.vue b/Web/src/App.vue index 73f99e1..b011755 100644 --- a/Web/src/App.vue +++ b/Web/src/App.vue @@ -54,11 +54,9 @@ const messageStore = useMessageStore() // 定义需要缓存的页面组件名称 const cachedViews = ref([ 'CalendarV2', // 日历V2页面 - 'CalendarView', // 日历V1页面 'StatisticsView', // 统计页面 'StatisticsV2View', // 统计V2页面 'BalanceView', // 账单页面 - 'BudgetView', // 预算页面 'BudgetV2View' // 预算V2页面 ]) @@ -148,16 +146,16 @@ watch( ) const isShowAddBill = computed(() => { - return route.path === '/' || route.path === '/balance' || route.path === '/message' || route.path === '/calendar' || route.path === '/calendar-v2' + return route.path === '/' || route.path === '/balance' || route.path === '/message' || route.path === '/calendar-v2' }) // 需要显示底部导航栏的路由 const showNav = computed(() => { return [ '/', '/statistics-v2', - '/calendar', '/calendar-v2', + '/calendar-v2', '/balance', '/message', - '/budget', '/budget-v2', '/setting' + '/budget-v2', '/setting' ].includes(route.path) }) diff --git a/Web/src/api/statistics.js b/Web/src/api/statistics.js index 1300cf3..69b7399 100644 --- a/Web/src/api/statistics.js +++ b/Web/src/api/statistics.js @@ -160,22 +160,6 @@ export const getDailyStatistics = (params) => { }) } -/** - * 获取累积余额统计数据(用于余额卡片) - * @deprecated 请使用 getDailyStatisticsByRange 并在前端计算累积余额 - * @param {Object} params - 查询参数 - * @param {number} params.year - 年份 - * @param {number} params.month - 月份 - * @returns {Promise<{success: boolean, data: Array}>} - */ -export const getBalanceStatistics = (params) => { - return request({ - url: '/TransactionStatistics/GetBalanceStatistics', - method: 'get', - params - }) -} - /** * 获取指定周范围的每天的消费统计 * @deprecated 请使用 getDailyStatisticsByRange diff --git a/Web/src/components/GlassBottomNav.vue b/Web/src/components/GlassBottomNav.vue index f79ffc1..814ab05 100644 --- a/Web/src/components/GlassBottomNav.vue +++ b/Web/src/components/GlassBottomNav.vue @@ -41,7 +41,7 @@ const props = defineProps({ type: Array, default () { return [ - { name: 'calendar', label: '日历', icon: 'notes', path: '/calendar' }, + { name: 'calendar', label: '日历', icon: 'notes', path: '/calendar-v2' }, { name: 'statistics', label: '统计', icon: 'chart-trending-o', path: '/' }, { name: 'balance', label: '账单', icon: 'balance-list', path: '/balance' }, { name: 'budget', label: '预算', icon: 'bill-o', path: '/budget-v2' }, diff --git a/Web/src/router/index.js b/Web/src/router/index.js index 24ef01b..f847861 100644 --- a/Web/src/router/index.js +++ b/Web/src/router/index.js @@ -1,6 +1,5 @@ import { createRouter, createWebHistory } from 'vue-router' import { useAuthStore } from '@/stores/auth' -import { useVersionStore } from '@/stores/version' const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -29,12 +28,6 @@ const router = createRouter({ component: () => import('../views/SettingView.vue'), meta: { requiresAuth: true } }, - { - path: '/calendar', - name: 'calendar', - component: () => import('../views/CalendarView.vue'), - meta: { requiresAuth: true } - }, { path: '/calendar-v2', name: 'calendar-v2', @@ -65,12 +58,6 @@ const router = createRouter({ component: () => import('../views/ClassificationNLP.vue'), meta: { requiresAuth: true } }, - { - path: '/', - name: 'statistics', - component: () => import('../views/statisticsV1/Index.vue'), - meta: { requiresAuth: true } - }, { path: '/statistics-v2', name: 'statistics-v2', @@ -101,12 +88,6 @@ const router = createRouter({ component: () => import('../views/LogView.vue'), meta: { requiresAuth: true } }, - { - path: '/budget', - name: 'budget', - component: () => import('../views/BudgetView.vue'), - meta: { requiresAuth: true } - }, { path: '/budget-v2', name: 'budget-v2', @@ -132,7 +113,6 @@ const router = createRouter({ // 路由守卫 router.beforeEach((to, from, next) => { const authStore = useAuthStore() - const versionStore = useVersionStore() const requiresAuth = to.meta.requiresAuth !== false // 默认需要认证 if (requiresAuth && !authStore.isAuthenticated) { @@ -140,35 +120,8 @@ router.beforeEach((to, from, next) => { next({ name: 'login', query: { redirect: to.fullPath } }) } else if (to.name === 'login' && authStore.isAuthenticated) { // 已登录用户访问登录页,跳转到首页 - next({ name: 'transactions' }) + next({ name: 'statistics-v2' }) } else { - // 版本路由处理 - if (versionStore.isV2()) { - // 如果当前选择 V2,尝试跳转到 V2 路由 - const routeName = to.name?.toString() - if (routeName && !routeName.endsWith('-v2')) { - const v2RouteName = `${routeName}-v2` - const v2Route = router.getRoutes().find(route => route.name === v2RouteName) - - if (v2Route) { - next({ name: v2RouteName, query: to.query, params: to.params }) - return - } - } - } else { - // 如果当前选择 V1,且访问的是 V2 路由,跳转到 V1 - const routeName = to.name?.toString() - if (routeName && routeName.endsWith('-v2')) { - const v1RouteName = routeName.replace(/-v2$/, '') - const v1Route = router.getRoutes().find(route => route.name === v1RouteName) - - if (v1Route) { - next({ name: v1RouteName, query: to.query, params: to.params }) - return - } - } - } - next() } }) diff --git a/Web/src/stores/version.js b/Web/src/stores/version.js index 7023f39..07a6d22 100644 --- a/Web/src/stores/version.js +++ b/Web/src/stores/version.js @@ -2,14 +2,18 @@ import { defineStore } from 'pinia' import { ref } from 'vue' export const useVersionStore = defineStore('version', () => { - const currentVersion = ref(localStorage.getItem('app-version') || 'v1') + // V1 已下线,强制使用 V2 + const currentVersion = ref('v2') const setVersion = (version) => { - currentVersion.value = version - localStorage.setItem('app-version', version) + // 仅接受 v2,忽略 v1 设置 + if (version === 'v2') { + currentVersion.value = version + localStorage.setItem('app-version', version) + } } - const isV2 = () => currentVersion.value === 'v2' + const isV2 = () => true // 始终返回 true return { currentVersion, diff --git a/Web/src/views/BudgetView.vue b/Web/src/views/BudgetView.vue deleted file mode 100644 index 2bef2d8..0000000 --- a/Web/src/views/BudgetView.vue +++ /dev/null @@ -1,1006 +0,0 @@ - - - - - - diff --git a/Web/src/views/CalendarView.vue b/Web/src/views/CalendarView.vue deleted file mode 100644 index 21139fc..0000000 --- a/Web/src/views/CalendarView.vue +++ /dev/null @@ -1,343 +0,0 @@ - - - - - diff --git a/Web/src/views/LoginView.vue b/Web/src/views/LoginView.vue index b81fe29..5df77e7 100644 --- a/Web/src/views/LoginView.vue +++ b/Web/src/views/LoginView.vue @@ -1,4 +1,4 @@ -