[Fix] 🐛 Page Router Permission

This commit is contained in:
Harry-zklcdc 2025-07-06 15:32:39 +08:00
parent 05502938ba
commit e6f81e19dc

View File

@ -1,4 +1,5 @@
import AppLayout from '@/layout/AppLayout.vue';
import { useProfileStore } from '@/stores/profile';
import { createRouter, createWebHistory } from 'vue-router';
import Forget from '@/views/Forget.vue';
@ -100,4 +101,19 @@ const router = createRouter({
]
});
router.beforeEach((to, from, next) => {
const profileStore = useProfileStore();
if (to.path.startsWith('/admin')) {
if (!profileStore.isAdmin && !profileStore.isSuperAdmin) {
next({ name: 'not-found' });
return;
}
if ((to.path.endsWith('servers') || to.path.endsWith('settings')) && !profileStore.isSuperAdmin) {
next({ name: 'not-found' });
return;
}
}
next();
});
export default router;