mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-14 11:17:28 +08:00
fix(webui): split route bundles
This commit is contained in:
@@ -1,44 +1,53 @@
|
||||
import React from 'react';
|
||||
import React, { Suspense, lazy } from 'react';
|
||||
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
||||
import { AppProvider } from './context/AppContext';
|
||||
import { UIProvider } from './context/UIContext';
|
||||
import Layout from './components/Layout';
|
||||
import Dashboard from './pages/Dashboard';
|
||||
import Chat from './pages/Chat';
|
||||
import Config from './pages/Config';
|
||||
import Cron from './pages/Cron';
|
||||
import Logs from './pages/Logs';
|
||||
import Skills from './pages/Skills';
|
||||
import MCP from './pages/MCP';
|
||||
import Memory from './pages/Memory';
|
||||
import TaskAudit from './pages/TaskAudit';
|
||||
import EKG from './pages/EKG';
|
||||
import LogCodes from './pages/LogCodes';
|
||||
import SubagentProfiles from './pages/SubagentProfiles';
|
||||
import Subagents from './pages/Subagents';
|
||||
|
||||
const Dashboard = lazy(() => import('./pages/Dashboard'));
|
||||
const Chat = lazy(() => import('./pages/Chat'));
|
||||
const Config = lazy(() => import('./pages/Config'));
|
||||
const Cron = lazy(() => import('./pages/Cron'));
|
||||
const Logs = lazy(() => import('./pages/Logs'));
|
||||
const Skills = lazy(() => import('./pages/Skills'));
|
||||
const MCP = lazy(() => import('./pages/MCP'));
|
||||
const Memory = lazy(() => import('./pages/Memory'));
|
||||
const TaskAudit = lazy(() => import('./pages/TaskAudit'));
|
||||
const EKG = lazy(() => import('./pages/EKG'));
|
||||
const LogCodes = lazy(() => import('./pages/LogCodes'));
|
||||
const SubagentProfiles = lazy(() => import('./pages/SubagentProfiles'));
|
||||
const Subagents = lazy(() => import('./pages/Subagents'));
|
||||
|
||||
const pageFallback = (
|
||||
<div className="absolute inset-0 flex items-center justify-center bg-zinc-950/80 text-xs tracking-[0.3em] text-zinc-500 uppercase">
|
||||
Loading
|
||||
</div>
|
||||
);
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<AppProvider>
|
||||
<UIProvider>
|
||||
<BrowserRouter basename="/webui">
|
||||
<Routes>
|
||||
<Route path="/" element={<Layout />}>
|
||||
<Route index element={<Dashboard />} />
|
||||
<Route path="chat" element={<Chat />} />
|
||||
<Route path="logs" element={<Logs />} />
|
||||
<Route path="log-codes" element={<LogCodes />} />
|
||||
<Route path="skills" element={<Skills />} />
|
||||
<Route path="mcp" element={<MCP />} />
|
||||
<Route path="config" element={<Config />} />
|
||||
<Route path="cron" element={<Cron />} />
|
||||
<Route path="memory" element={<Memory />} />
|
||||
<Route path="task-audit" element={<TaskAudit />} />
|
||||
<Route path="ekg" element={<EKG />} />
|
||||
<Route path="subagent-profiles" element={<SubagentProfiles />} />
|
||||
<Route path="subagents" element={<Subagents />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
<Suspense fallback={pageFallback}>
|
||||
<Routes>
|
||||
<Route path="/" element={<Layout />}>
|
||||
<Route index element={<Dashboard />} />
|
||||
<Route path="chat" element={<Chat />} />
|
||||
<Route path="logs" element={<Logs />} />
|
||||
<Route path="log-codes" element={<LogCodes />} />
|
||||
<Route path="skills" element={<Skills />} />
|
||||
<Route path="mcp" element={<MCP />} />
|
||||
<Route path="config" element={<Config />} />
|
||||
<Route path="cron" element={<Cron />} />
|
||||
<Route path="memory" element={<Memory />} />
|
||||
<Route path="task-audit" element={<TaskAudit />} />
|
||||
<Route path="ekg" element={<EKG />} />
|
||||
<Route path="subagent-profiles" element={<SubagentProfiles />} />
|
||||
<Route path="subagents" element={<Subagents />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</Suspense>
|
||||
</BrowserRouter>
|
||||
</UIProvider>
|
||||
</AppProvider>
|
||||
|
||||
@@ -16,5 +16,20 @@ export default defineConfig(({mode}) => {
|
||||
server: {
|
||||
hmr: process.env.DISABLE_HMR !== 'true',
|
||||
},
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (!id.includes('node_modules')) return undefined;
|
||||
if (id.includes('react-router-dom') || id.includes('react-dom') || id.includes('/react/')) {
|
||||
return 'react-vendor';
|
||||
}
|
||||
if (id.includes('motion')) return 'motion';
|
||||
if (id.includes('lucide-react')) return 'icons';
|
||||
return undefined;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user