移动端适配问题

This commit is contained in:
runny committed 2026-05-20 16:02:51 +08:00
1 parent 72642b981e
commit e70e17efd4
9 files changed
+271 -11

No files matched your search

+24 -2
View File
@@ -14,7 +14,8 @@ import { getStoredAuthUser } from '../utils/auth';
const routes = [
{
path: '/',
redirect: '/workspace'
name: 'Home',
component: WorkspaceView
},
{
path: '/workspace',
@@ -67,14 +68,35 @@ const router = createRouter({
routes
});
const DEFAULT_CHAT_AGENT_ID = 16;
const publicPaths = ['/', '/workspace', '/casdoor-callback', '/reset-password'];
router.beforeEach((to, _from, next) => {
const user = getStoredAuthUser();
const isLoggedIn = !!user && user.role !== 'guest';
if (to.path === '/admin') {
const user = getStoredAuthUser();
if (!user || user.role !== 'admin') {
next('/workspace');
return;
}
}
if (to.path === '/') {
if (isLoggedIn) {
next(`/chat/${DEFAULT_CHAT_AGENT_ID}`);
return;
}
next('/workspace');
return;
}
if (!isLoggedIn && !publicPaths.includes(to.path)) {
next('/workspace');
return;
}
next();
});