mirror of
https://github.com/XShengTech/MEGREZ.git
synced 2026-01-13 16:47:16 +08:00
[Fix] 🐛 Page Router Permission
This commit is contained in:
parent
05502938ba
commit
e6f81e19dc
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user