feat: 全屏个股详情预览 + Tailwind 改版 + 账号鉴权

This commit is contained in:
2026-08-14 22:37:18 +08:00
parent 0f8b9a7255
commit 4c2ea5521d
47 changed files with 2937 additions and 893 deletions

View File

@@ -1,9 +1,11 @@
import { createRouter, createWebHistory } from 'vue-router';
import HomeView from '@/views/HomeView.vue';
import { useAuthStore } from '@/stores/auth';
const router = createRouter({
history: createWebHistory(),
routes: [
{ path: '/login', name: 'login', component: () => import('@/views/LoginView.vue'), meta: { public: true } },
{ path: '/', name: 'home', component: HomeView },
{ path: '/screener', name: 'screener', component: () => import('@/views/ScreenerView.vue') },
{ path: '/backtest', name: 'backtest', component: () => import('@/views/BacktestView.vue') },
@@ -11,4 +13,21 @@ const router = createRouter({
],
});
router.beforeEach(async (to) => {
const auth = useAuthStore();
await auth.restore();
if (to.meta.public) {
if (to.name === 'login' && auth.isAuthenticated) {
return typeof to.query.redirect === 'string' ? to.query.redirect : '/';
}
return true;
}
if (!auth.isAuthenticated) {
return { name: 'login', query: { redirect: to.fullPath } };
}
return true;
});
export default router;