|
|
@ -80,18 +80,16 @@ const router = createRouter({ |
|
|
|
] |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => { |
|
|
|
const token = localStorage.getItem("token"); |
|
|
|
const machineId = localStorage.getItem("machineId"); |
|
|
|
const token = localStorage.getItem("token"); |
|
|
|
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; |