fix: 只有admin才可以看到并配置管理后台

This commit is contained in:
sophie committed 2026-05-14 09:38:35 +08:00
1 parent 2e9a70933d
commit 489c79758d
2 files changed
+13

No files matched your search

+12
View File
@@ -7,6 +7,7 @@ import AdminView from '../views/AdminView.vue';
import ProfileView from '../views/ProfileView.vue';
import ResetPasswordView from '../views/ResetPasswordView.vue';
import { config } from '../config';
import { getStoredAuthUser } from '../utils/auth';
const routes = [
{
@@ -52,6 +53,17 @@ const router = createRouter({
routes
});
router.beforeEach((to, _from, next) => {
if (to.path === '/admin') {
const user = getStoredAuthUser();
if (!user || user.role !== 'admin') {
next('/workspace');
return;
}
}
next();
});
router.afterEach((to) => {
const baseTitle = config.appTitle || 'AI工作台';
if (to.meta.title) {