Browse Source

success Merge branch 'zhangrenyuan/feature-20250714163943-金币前端二期' into milestone-20250711-金币前端二期

zhangrenyuan/feature-20250714163943-金币前端二期
zry 3 weeks ago
parent
commit
6aa591c7d9
  1. 14
      src/router/index.js

14
src/router/index.js

@ -80,18 +80,16 @@ const router = createRouter({
] ]
}); });
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const token = localStorage.getItem("token"); const token = localStorage.getItem("token");
const machineId = localStorage.getItem("machineId"); const machineId = localStorage.getItem("machineId");
if (to.name != "login" && !token) {
next('/login?machineId=' + machineId);
}
next();
})
// 允许无token访问的路由
const publicRoutes = ['Login', 'PasswordSuccess'];
if (!publicRoutes.includes(to.name) && !token) {
next(`/login?machineId=${machineId}`);
return;
}
next();
});
export default router; export default router;
Loading…
Cancel
Save