refactor(chat + workspace): chat和workspace重构,子路由、懒加载等

This commit is contained in:
sophie committed 2026-06-10 16:39:05 +08:00
1 parent 0a647a0b79
commit 1f1f7236b0
57 files changed
+4356 -3798

No files matched your search

+8 -3
View File
@@ -20,7 +20,7 @@ export function setupRouterGuards(router: Router): void {
if (to.matched.some((r) => r.meta.requiresAdmin)) {
if (!auth.isAdmin) {
next('/workspace');
next('/workspace/applications');
return;
}
}
@@ -30,12 +30,17 @@ export function setupRouterGuards(router: Router): void {
next(`/chat/${DEFAULT_CHAT_AGENT_ID}`);
return;
}
next('/workspace');
next('/login');
return;
}
if (to.path === '/login' && auth.isLoggedIn) {
next('/workspace/applications');
return;
}
if (!auth.isLoggedIn && !isPublicPath(to.path)) {
next('/workspace');
next('/login');
return;
}
+108 -143
View File
@@ -1,218 +1,183 @@
/**
* app/router/routes/admin.routes.ts
* 管理后台嵌套路由;全部 admin 模块已独立拆分。
*/
import type { RouteRecordRaw } from 'vue-router';
import type { RouteRecordRaw } from "vue-router";
const AdminLayout = () => import("@/features/admin/views/AdminLayout.vue");
const AgentsPage = () =>
import("@/features/admin/modules/agents/AgentsPage.vue");
const AdminLayout = () => import('@/features/admin/views/AdminLayout.vue');
const UsersPage = () => import("@/features/admin/modules/users/UsersPage.vue");
const AgentsPage = () => import('@/features/admin/modules/agents/AgentsPage.vue');
const DepartmentsPage = () =>
import("@/features/admin/modules/departments/DepartmentsPage.vue");
const UsersPage = () => import('@/features/admin/modules/users/UsersPage.vue');
const ApprovalsPage = () =>
import("@/features/admin/modules/approvals/ApprovalsPage.vue");
const DepartmentsPage = () => import('@/features/admin/modules/departments/DepartmentsPage.vue');
const AnnouncementsPage = () =>
import("@/features/admin/modules/announcements/AnnouncementsPage.vue");
const ApprovalsPage = () => import('@/features/admin/modules/approvals/ApprovalsPage.vue');
const QuestionsPage = () =>
import("@/features/admin/modules/questions/QuestionsPage.vue");
const AnnouncementsPage = () => import('@/features/admin/modules/announcements/AnnouncementsPage.vue');
const RequestsPage = () =>
import("@/features/admin/modules/requests/RequestsPage.vue");
const QuestionsPage = () => import('@/features/admin/modules/questions/QuestionsPage.vue');
const PermissionsPage = () =>
import("@/features/admin/modules/permissions/PermissionsPage.vue");
const PlatformAppsPage = () =>
import("@/features/admin/modules/platform-apps/PlatformAppsPage.vue");
const DashboardPage = () =>
import("@/features/admin/modules/dashboard/DashboardPage.vue");
const RequestsPage = () => import('@/features/admin/modules/requests/RequestsPage.vue');
const SchedulesPage = () =>
import("@/features/admin/modules/schedules/SchedulesPage.vue");
const PermissionsPage = () => import('@/features/admin/modules/permissions/PermissionsPage.vue');
const PlatformAppsPage = () => import('@/features/admin/modules/platform-apps/PlatformAppsPage.vue');
const DashboardPage = () => import('@/features/admin/modules/dashboard/DashboardPage.vue');
const SchedulesPage = () => import('@/features/admin/modules/schedules/SchedulesPage.vue');
const KnowledgeBasePage = () => import('@/features/admin/modules/knowledge-base/KnowledgeBasePage.vue');
const WecomPage = () => import('@/features/admin/modules/wecom/WecomPage.vue');
const ReportsPage = () => import('@/features/admin/modules/reports/ReportsPage.vue');
const KnowledgeBasePage = () =>
import("@/features/admin/modules/knowledge-base/KnowledgeBasePage.vue");
const WecomPage = () => import("@/features/admin/modules/wecom/WecomPage.vue");
const ReportsPage = () =>
import("@/features/admin/modules/reports/ReportsPage.vue");
export const adminRoutes: RouteRecordRaw[] = [
{
path: '/admin',
path: "/admin",
component: AdminLayout,
meta: { requiresAdmin: true },
children: [
{ path: '', redirect: '/admin/dashboard' },
{ path: "", redirect: "/admin/dashboard" },
{
path: 'dashboard',
name: 'AdminDashboard',
path: "dashboard",
name: "AdminDashboard",
component: DashboardPage,
meta: { requiresAdmin: true, adminModule: 'dashboard', title: '概览' },
meta: { requiresAdmin: true, adminModule: "dashboard", title: "概览" },
},
{
path: 'schedules',
name: 'AdminSchedules',
path: "schedules",
name: "AdminSchedules",
component: SchedulesPage,
meta: { requiresAdmin: true, adminModule: 'schedules', title: '定时任务' },
meta: {
requiresAdmin: true,
adminModule: "schedules",
title: "定时任务",
},
},
{
path: 'knowledge-base',
name: 'AdminKnowledgeBase',
path: "knowledge-base",
name: "AdminKnowledgeBase",
component: KnowledgeBasePage,
meta: { requiresAdmin: true, adminModule: 'knowledge_base', title: '知识库' },
meta: {
requiresAdmin: true,
adminModule: "knowledge_base",
title: "知识库",
},
},
{
path: 'wecom',
name: 'AdminWecom',
path: "wecom",
name: "AdminWecom",
component: WecomPage,
meta: { requiresAdmin: true, adminModule: 'wecom', title: '企业微信' },
meta: { requiresAdmin: true, adminModule: "wecom", title: "企业微信" },
},
{
path: 'approvals',
name: 'AdminApprovals',
path: "approvals",
name: "AdminApprovals",
component: ApprovalsPage,
meta: { requiresAdmin: true, adminModule: 'approvals', title: '用户审批' },
meta: {
requiresAdmin: true,
adminModule: "approvals",
title: "用户审批",
},
},
{
path: 'agents',
name: 'AdminAgents',
path: "agents",
name: "AdminAgents",
component: AgentsPage,
meta: { requiresAdmin: true, adminModule: 'agents', title: '应用管理' },
meta: { requiresAdmin: true, adminModule: "agents", title: "应用管理" },
},
{
path: 'users',
name: 'AdminUsers',
path: "users",
name: "AdminUsers",
component: UsersPage,
meta: { requiresAdmin: true, adminModule: 'users', title: '用户管理' },
meta: { requiresAdmin: true, adminModule: "users", title: "用户管理" },
},
{
path: 'departments',
name: 'AdminDepartments',
path: "departments",
name: "AdminDepartments",
component: DepartmentsPage,
meta: { requiresAdmin: true, adminModule: 'departments', title: '部门管理' },
meta: {
requiresAdmin: true,
adminModule: "departments",
title: "部门管理",
},
},
{
path: 'announcements',
name: 'AdminAnnouncements',
path: "announcements",
name: "AdminAnnouncements",
component: AnnouncementsPage,
meta: { requiresAdmin: true, adminModule: 'announcements', title: '公告管理' },
meta: {
requiresAdmin: true,
adminModule: "announcements",
title: "公告管理",
},
},
{
path: 'questions',
name: 'AdminQuestions',
path: "questions",
name: "AdminQuestions",
component: QuestionsPage,
meta: { requiresAdmin: true, adminModule: 'questions', title: '常用问题' },
meta: {
requiresAdmin: true,
adminModule: "questions",
title: "常用问题",
},
},
{
path: 'requests',
name: 'AdminRequests',
path: "requests",
name: "AdminRequests",
component: RequestsPage,
meta: { requiresAdmin: true, adminModule: 'requests', title: '权限申请' },
meta: {
requiresAdmin: true,
adminModule: "requests",
title: "权限申请",
},
},
{
path: 'permissions',
name: 'AdminPermissions',
path: "permissions",
name: "AdminPermissions",
component: PermissionsPage,
meta: { requiresAdmin: true, adminModule: 'permissions', title: '权限管理' },
meta: {
requiresAdmin: true,
adminModule: "permissions",
title: "权限管理",
},
},
{
path: 'platform-apps',
name: 'AdminPlatformApps',
path: "platform-apps",
name: "AdminPlatformApps",
component: PlatformAppsPage,
meta: { requiresAdmin: true, adminModule: 'platform_apps', title: '平台应用说明' },
meta: {
requiresAdmin: true,
adminModule: "platform_apps",
title: "平台应用说明",
},
},
{
path: 'reports/:table?',
name: 'AdminReports',
path: "reports/:table?",
name: "AdminReports",
component: ReportsPage,
meta: { requiresAdmin: true, adminModule: 'reports', title: '报表' },
meta: { requiresAdmin: true, adminModule: "reports", title: "报表" },
},
],
},
];
@@ -1,14 +1,13 @@
/**
* app/router/routes/auth.routes.ts
* 认证 / 工作台相关路由。
* 认证路由:/login 登录页、/casdoor-callback OAuth 回调、/reset-password 重置密码。
*/
import type { RouteRecordRaw } from 'vue-router';
import WorkspaceView from '@/views/WorkspaceView.vue';
import ResetPasswordView from '@/views/ResetPasswordView.vue';
import LoginView from '@/features/auth/views/LoginView.vue';
import ResetPasswordView from '@/features/auth/views/ResetPasswordView.vue';
export const authRoutes: RouteRecordRaw[] = [
{ path: '/', name: 'Home', component: WorkspaceView },
{ path: '/workspace', name: 'Workspace', component: WorkspaceView },
{ path: '/casdoor-callback', name: 'CasdoorCallback', component: WorkspaceView },
{ path: '/login', name: 'Login', component: LoginView },
{ path: '/casdoor-callback', name: 'CasdoorCallback', component: LoginView },
{ path: '/reset-password', name: 'ResetPassword', component: ResetPasswordView },
];
@@ -3,8 +3,12 @@
* 对话相关路由。
*/
import type { RouteRecordRaw } from 'vue-router';
import ChatView from '@/views/ChatView.vue';
export const chatRoutes: RouteRecordRaw[] = [
{ path: '/chat/:agentId', name: 'Chat', component: ChatView, props: true },
{
path: '/chat/:agentId',
name: 'Chat',
component: () => import('@/features/chat/views/ChatView.vue'),
props: true,
},
];
+2
View File
@@ -7,9 +7,11 @@ import { adminRoutes } from './admin.routes';
import { authRoutes } from './auth.routes';
import { chatRoutes } from './chat.routes';
import { kbRoutes } from './kb.routes';
import { workspaceRoutes } from './workspace.routes';
export const appRoutes: RouteRecordRaw[] = [
...authRoutes,
...workspaceRoutes,
...chatRoutes,
...adminRoutes,
...kbRoutes,
@@ -0,0 +1,64 @@
/**
* app/router/routes/workspace.routes.ts
* 工作台路由表:/workspace 布局壳 + 各业务子页面懒加载。
*/
import type { RouteRecordRaw } from 'vue-router';
export const workspaceRoutes: RouteRecordRaw[] = [
{
path: '/workspace',
component: () => import('@/features/workspace/views/WorkspaceLayout.vue'),
meta: { title: 'AI工作台' },
children: [
{ path: '', redirect: '/workspace/applications' },
{
path: 'profile',
name: 'workspace-profile',
component: () => import('@/features/workspace/pages/ProfilePage.vue'),
meta: { title: '个人中心' },
},
{
path: 'applications',
name: 'workspace-applications',
component: () => import('@/features/workspace/pages/HomePage.vue'),
meta: { workspaceFocus: 'applications' },
},
{
path: 'updates',
name: 'workspace-updates',
component: () => import('@/features/workspace/pages/HomePage.vue'),
meta: { workspaceFocus: 'updates' },
},
{
path: 'knowledge-base',
name: 'workspace-knowledge-base',
component: () => import('@/features/workspace/pages/KnowledgeBasePage.vue'),
meta: { title: '知识库管理' },
},
{
path: 'schedule-runs',
name: 'workspace-schedule-runs',
component: () => import('@/features/workspace/pages/ScheduleRunsPage.vue'),
meta: { title: '排程记录' },
},
{
path: 'shipping-notice',
name: 'workspace-shipping-notice',
component: () => import('@/features/workspace/pages/ShippingNoticePage.vue'),
meta: { title: '货代发货' },
},
{
path: 'feedback',
name: 'workspace-feedback',
component: () => import('@/features/workspace/pages/FeedbackPage.vue'),
meta: { title: '意见反馈' },
},
{
path: 'history',
name: 'workspace-history',
component: () => import('@/features/chat/pages/HistoryPage.vue'),
meta: { title: '聊天历史' },
},
],
},
];