feat: remove V1 calendar/budget/stats modules
- 删除 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 端点和路由将不可用
This commit is contained in:
@@ -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()
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user