feat(router): mount Landing at / with auth-aware redirect
- / (anonymous) → LandingView - / (authenticated) → redirects to /dashboard via new meta.redirectIfAuth - Remove temporary /landing-preview route (Task 2 helper) - RouteMeta TS augmentation for redirectIfAuth - LandingView brand link uses router-link (was <a href>, causing SPA reload) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -36,15 +36,6 @@ const routes: RouteRecordRaw[] = [
|
||||
title: 'Home'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/landing-preview',
|
||||
name: 'LandingPreview',
|
||||
component: () => import('@/views/landing/LandingView.vue'),
|
||||
meta: {
|
||||
requiresAuth: false,
|
||||
title: 'PURO AI'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
@@ -133,7 +124,13 @@ const routes: RouteRecordRaw[] = [
|
||||
// ==================== User Routes ====================
|
||||
{
|
||||
path: '/',
|
||||
redirect: '/home'
|
||||
name: 'Landing',
|
||||
component: () => import('@/views/landing/LandingView.vue'),
|
||||
meta: {
|
||||
requiresAuth: false,
|
||||
title: 'PURO AI — 你的 AI 订阅,已经付过钱了',
|
||||
redirectIfAuth: '/dashboard'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/dashboard',
|
||||
@@ -542,6 +539,13 @@ router.beforeEach((to, _from, next) => {
|
||||
authInitialized = true
|
||||
}
|
||||
|
||||
// Auth-aware redirect for public pages that should bounce authenticated users elsewhere
|
||||
// (e.g., Landing / at `/` redirects to /dashboard if user is logged in)
|
||||
const redirectIfAuth = to.meta.redirectIfAuth
|
||||
if (redirectIfAuth && authStore.isAuthenticated) {
|
||||
return next(redirectIfAuth)
|
||||
}
|
||||
|
||||
// Set page title
|
||||
const appStore = useAppStore()
|
||||
// For custom pages, use menu item label as document title
|
||||
|
||||
Reference in New Issue
Block a user