feat: add account settings and router dependency

This commit is contained in:
2026-10-16 19:42:41 +08:00
parent 3ef97a472e
commit 483cb4ec8c
5 changed files with 142 additions and 6 deletions
+1
View File
@@ -9,6 +9,7 @@ const router=createRouter({history:createWebHistory(),routes:[
{path:'/login',component:()=>import('./views/LoginView.vue'),meta:{public:true}},
{path:'/register',component:()=>import('./views/RegisterView.vue'),meta:{public:true}},
{path:'/profile',component:()=>import('./views/ProfileView.vue')},
{path:'/settings',component:()=>import('./views/AccountSettingsView.vue')},
{path:'/admin',component:()=>import('./views/AdminView.vue'),meta:{role:'admin'}},
]})
router.beforeEach(async to=>{if(to.meta.public)return true;try{role=(await getCurrentUser()).role}catch{return {path:'/login',query:{redirect:to.fullPath}}}if(to.meta.role&&role!==to.meta.role)return {path:'/profile',query:{forbidden:'1'}};return true})