Files
kefu_cloud/web/src/router/index.tsx
T
yml2213 c5f28dca1c 新增独立快捷回复模块(团队/个人)
从知识库拆出快捷回复:支持团队暂存与发布同步、个人话术、输入码与工作台 / 调用,以及 CSV 导入导出;管理页顶栏与侧栏对齐。
2026-07-17 21:59:10 +08:00

86 lines
3.4 KiB
TypeScript

import { lazy, Suspense } from 'react'
import { Navigate, createBrowserRouter } from 'react-router-dom'
import { Spin } from 'antd'
import RequireAuth, { RequirePlatformAdmin, RequireStaff, RequireSupervisor, RequireTenantAdmin } from '@/components/RequireAuth'
const AgentLayout = lazy(() => import('@/components/layout/AgentLayout'))
const AdminLayout = lazy(() => import('@/components/layout/AdminLayout'))
const Login = lazy(() => import('@/pages/Login'))
const Dashboard = lazy(() => import('@/pages/agent/Dashboard'))
const ChatHistory = lazy(() => import('@/pages/agent/ChatHistory'))
const Customers = lazy(() => import('@/pages/agent/Customers'))
const Knowledge = lazy(() => import('@/pages/agent/Knowledge'))
const QuickReplies = lazy(() => import('@/pages/agent/QuickReplies'))
const Statistics = lazy(() => import('@/pages/agent/Statistics'))
const Settings = lazy(() => import('@/pages/agent/Settings'))
const AdminDashboard = lazy(() => import('@/pages/admin/Dashboard'))
const Tenants = lazy(() => import('@/pages/admin/Tenants'))
const Plans = lazy(() => import('@/pages/admin/Plans'))
const Ops = lazy(() => import('@/pages/admin/Ops'))
const WidgetPreview = lazy(() => import('@/pages/WidgetPreview'))
const WidgetEmbed = lazy(() => import('@/pages/WidgetEmbed'))
const loading = (
<div className="h-full flex items-center justify-center">
<Spin size="large" />
</div>
)
function Lazy({ children }: { children: React.ReactNode }) {
return <Suspense fallback={loading}>{children}</Suspense>
}
export const router = createBrowserRouter([
{ path: '/login', element: <Lazy><Login /></Lazy> },
{ path: '/widget/preview', element: <Lazy><WidgetPreview /></Lazy> },
{ path: '/widget/embed', element: <Lazy><WidgetEmbed /></Lazy> },
{
path: '/',
element: <RequireAuth />,
children: [
{
path: 'admin',
element: <RequirePlatformAdmin />,
children: [
{
element: <Lazy><AdminLayout /></Lazy>,
children: [
{ index: true, element: <Navigate to="/admin/dashboard" replace /> },
{ path: 'dashboard', element: <Lazy><AdminDashboard /></Lazy> },
{ path: 'tenants', element: <Lazy><Tenants /></Lazy> },
{ path: 'plans', element: <Lazy><Plans /></Lazy> },
{ path: 'ops', element: <Lazy><Ops /></Lazy> },
],
},
],
},
{ index: true, element: <Navigate to="/agent/dashboard" replace /> },
{
path: 'agent',
element: <RequireStaff />,
children: [
{
element: <Lazy><AgentLayout /></Lazy>,
children: [
{ index: true, element: <Navigate to="/agent/dashboard" replace /> },
{ path: 'dashboard', element: <Lazy><Dashboard /></Lazy> },
{ path: 'chat-history', element: <Lazy><ChatHistory /></Lazy> },
{ path: 'customers', element: <Lazy><Customers /></Lazy> },
{ path: 'knowledge', element: <Lazy><Knowledge /></Lazy> },
{ path: 'quick-replies', element: <Lazy><QuickReplies /></Lazy> },
{
element: <RequireSupervisor />,
children: [{ path: 'statistics', element: <Lazy><Statistics /></Lazy> }],
},
{
element: <RequireTenantAdmin />,
children: [{ path: 'settings', element: <Lazy><Settings /></Lazy> }],
},
],
},
],
},
],
},
])