Files
bidding_watcher/ionic-app/src/router/index.ts
dmy 8f6e5c8423 feat: 添加投标项目查看器的Ionic移动端应用
新增基于Ionic + Vue 3 + TypeScript + Tailwind CSS的移动端应用,适配Android平台。主要功能包括AI推荐项目展示、爬虫信息统计、置顶项目管理和下拉刷新功能。同时更新前后端API端口配置为3300。
2026-01-18 18:53:35 +08:00

43 lines
923 B
TypeScript

import { createRouter, createWebHistory } from '@ionic/vue-router'
import HomePage from '@/pages/HomePage.vue'
import LoginPage from '@/pages/LoginPage.vue'
import { useAuthStore } from '@/stores/auth'
const routes = [
{
path: '/',
redirect: '/login'
},
{
path: '/login',
component: LoginPage
},
{
path: '/home',
component: HomePage,
meta: { requiresAuth: true }
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
// 路由守卫
router.beforeEach((to, from, next) => {
const authStore = useAuthStore()
if (to.meta.requiresAuth && !authStore.state.value.isAuthenticated) {
// 需要认证但未登录,跳转到登录页
next('/login')
} else if (to.path === '/login' && authStore.state.value.isAuthenticated) {
// 已登录用户访问登录页,跳转到首页
next('/home')
} else {
next()
}
})
export default router