todo
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 28s
Docker Build & Deploy / Deploy to Production (push) Successful in 8s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s

This commit is contained in:
SunCheng
2026-02-02 16:59:24 +08:00
parent 6abc5f8b6d
commit 338bac20ce
9 changed files with 819 additions and 106 deletions

View File

@@ -1,5 +1,6 @@
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),
@@ -34,6 +35,12 @@ const router = createRouter({
component: () => import('../views/CalendarView.vue'),
meta: { requiresAuth: true }
},
{
path: '/calendar-v2',
name: 'calendar-v2',
component: () => import('../views/CalendarV2.vue'),
meta: { requiresAuth: true }
},
{
path: '/smart-classification',
name: 'smart-classification',
@@ -113,6 +120,7 @@ const router = createRouter({
// 路由守卫
router.beforeEach((to, from, next) => {
const authStore = useAuthStore()
const versionStore = useVersionStore()
const requiresAuth = to.meta.requiresAuth !== false // 默认需要认证
if (requiresAuth && !authStore.isAuthenticated) {
@@ -122,6 +130,33 @@ router.beforeEach((to, from, next) => {
// 已登录用户访问登录页,跳转到首页
next({ name: 'transactions' })
} 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()
}
})