router/index.ts
{
path: '/:pathMatch(.*)*',
name: 'NotFound',
component: () => import('~/pages/404/index.vue'),
},
vite.config.ts,build节点
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
路由守卫:
router.beforeEach((to, from, next) => {
console.log(to, from);
// 没有登录,返回登录页
const token = '';
if (!token && to.path !== '/login') {
return next({ path: '/login' });
}
// 防止重复登录,略
// 系统设计进入登录页则清除所有缓存信息
if (token && to.path === '/login') {
return next({ path: from.path ? from.path : '/' });
}
next();
});
1111111111111111111111111111111111111111111111111111