配置Vite代理、API请求封装、JWT认证上下文、登录页面、路由鉴权
This commit is contained in:
+17
-16
@@ -1,9 +1,11 @@
|
||||
import { lazy, Suspense } from 'react'
|
||||
import { Navigate, createBrowserRouter } from 'react-router-dom'
|
||||
import { Spin } from 'antd'
|
||||
import RequireAuth 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'))
|
||||
@@ -27,28 +29,27 @@ function Lazy({ children }: { children: React.ReactNode }) {
|
||||
}
|
||||
|
||||
export const router = createBrowserRouter([
|
||||
{
|
||||
path: '/widget/preview',
|
||||
element: <Lazy><WidgetPreview /></Lazy>,
|
||||
},
|
||||
{
|
||||
path: '/admin',
|
||||
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> },
|
||||
],
|
||||
},
|
||||
{ path: '/login', element: <Lazy><Login /></Lazy> },
|
||||
{ path: '/widget/preview', element: <Lazy><WidgetPreview /></Lazy> },
|
||||
{
|
||||
path: '/',
|
||||
element: <Lazy><AgentLayout /></Lazy>,
|
||||
element: <RequireAuth />,
|
||||
children: [
|
||||
{
|
||||
path: 'admin',
|
||||
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: <Lazy><AgentLayout /></Lazy>,
|
||||
children: [
|
||||
{ index: true, element: <Navigate to="/agent/dashboard" replace /> },
|
||||
{ path: 'dashboard', element: <Lazy><Dashboard /></Lazy> },
|
||||
|
||||
Reference in New Issue
Block a user