添加路由守卫

This commit is contained in:
niyyzf 2024-07-25 17:51:02 +08:00
parent 85899c277b
commit 7f2a9c1b4b
2 changed files with 24 additions and 7 deletions

View File

@ -17,6 +17,23 @@ const router = createRouter({
history: createWebHistory(), history: createWebHistory(),
routes, routes,
}) })
router.beforeEach( (to, from, next) => {
const isLogin=false
//如果登录
if (!isLogin) {
if (to.path === '/welcome') {
next()
} else {
next('/welcome')
}
}
else {
next()
}
next()
})
const app = createApp(App) const app = createApp(App)
app.use(router) app.use(router)
app.mount('#app') app.mount('#app')

View File

@ -22,10 +22,10 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
height: 100vh; height: 100vh;
padding: 45px 15px; padding: 12vw 4vw;
button{ button{
display: flex; display: flex;
padding: 15px 40px; padding: 4vw 10.67vw;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
border-radius: 10px; border-radius: 10px;
@ -34,7 +34,7 @@
min-width: 80%; min-width: 80%;
box-shadow: 1px 2px 6px 0 rgba(0, 110, 233, 0.10); box-shadow: 1px 2px 6px 0 rgba(0, 110, 233, 0.10);
color: #FFF; color: #FFF;
font-size: 14px; font-size: 3.73vw;
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
line-height: 140%; /* 19.6px */ line-height: 140%; /* 19.6px */
@ -46,11 +46,11 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
text-align: center; text-align: center;
gap: 24px; gap: 6.4vw;
flex: 1; flex: 1;
h1{ h1{
color: #000; color: #000;
font-size: 16px; font-size: 4.27vw;
font-style: normal; font-style: normal;
font-weight: 600; font-weight: 600;
line-height: 140%; /* 22.4px */ line-height: 140%; /* 22.4px */
@ -58,8 +58,8 @@
h3{ h3{
color: #4A4646; color: #4A4646;
text-align: center; text-align: center;
width: 301px; width: 80.27vw;
font-size: 14px; font-size: 3.73vw;
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
line-height: 140%; /* 19.6px */ line-height: 140%; /* 19.6px */