| | |
| | | import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router"; |
| | | |
| | | // 登录页 |
| | | import Login from "../components/login.vue"; |
| | | import Login from "../views/login.vue"; |
| | | //首页 |
| | | import Index from "../views/Index.vue"; |
| | | const routes: Array<RouteRecordRaw> = [ |
| | |
| | | component: Login, |
| | | }, |
| | | { |
| | | path: "/Index", |
| | | path: "/", |
| | | name: "Index", |
| | | component: Index, |
| | | meta: { |
| | | title: "首页", |
| | | requireAuth: true, // 标识该路由是否需要登录 |
| | | }, |
| | | }, |
| | | ]; |
| | | |
| | |
| | | history: createWebHashHistory(), |
| | | routes, |
| | | }); |
| | | |
| | | //路由守卫 |
| | | router.beforeEach((to, from, next) => { |
| | | next(); |
| | | // if (to.matched.some((auth) => auth.meta.requireAuth)) { |
| | | // // 获取token |
| | | // let token = getToken(); |
| | | // if (token) { |
| | | // next(); |
| | | // } else { |
| | | // next({ |
| | | // path: "/login", |
| | | // }); |
| | | // } |
| | | // } else { |
| | | // next(); |
| | | // } |
| | | }); |
| | | export default router; |