添加路由守卫

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(),
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)
app.use(router)
app.mount('#app')

View File

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