搭建客服端基础框架:路由、侧边栏布局、客服工作台三栏页面
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { lazy, Suspense } from 'react'
|
||||
import { Navigate, createBrowserRouter } from 'react-router-dom'
|
||||
import { Spin } from 'antd'
|
||||
|
||||
const AgentLayout = lazy(() => import('@/components/layout/AgentLayout'))
|
||||
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 Statistics = lazy(() => import('@/pages/agent/Statistics'))
|
||||
const Settings = lazy(() => import('@/pages/agent/Settings'))
|
||||
|
||||
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: '/admin',
|
||||
element: <div>管理端</div>,
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
element: <Lazy><AgentLayout /></Lazy>,
|
||||
children: [
|
||||
{ index: true, element: <Navigate to="/agent/dashboard" replace /> },
|
||||
{
|
||||
path: 'agent',
|
||||
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: 'statistics', element: <Lazy><Statistics /></Lazy> },
|
||||
{ path: 'settings', element: <Lazy><Settings /></Lazy> },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
Reference in New Issue
Block a user