feat: refactor sidebar and settings to include agents and models; update routing and i18n messages

This commit is contained in:
duanshuwen
2026-04-20 22:56:33 +08:00
parent 4f41eb380e
commit 35319e6a1d
6 changed files with 126 additions and 33 deletions

View File

@@ -8,8 +8,6 @@ import { onAuthLogout } from './auth-session';
const HomePage = lazy(() => import('../pages/Home'));
const ChannelsPage = lazy(() => import('../pages/Channels'));
const AgentsPage = lazy(() => import('../pages/Agents'));
const ModelsPage = lazy(() => import('../pages/Models'));
const SkillsPage = lazy(() => import('../pages/Skills'));
const CronPage = lazy(() => import('../pages/Cron'));
const ScriptsPage = lazy(() => import('../pages/Scripts'));
@@ -32,6 +30,10 @@ function renderLazyPage(element: ReactNode) {
);
}
function renderSettingViewRedirect(view: 'agents' | 'models') {
return <Navigate to={`/setting?view=${view}`} replace />;
}
function AuthLogoutRedirector() {
const location = useLocation();
const navigate = useNavigate();
@@ -65,8 +67,8 @@ export function AppRouter() {
<Route element={<MainLayout />}>
<Route path="/home" element={renderLazyPage(<HomePage />)} />
<Route path="/channels" element={renderLazyPage(<ChannelsPage />)} />
<Route path="/agents" element={renderLazyPage(<AgentsPage />)} />
<Route path="/models" element={renderLazyPage(<ModelsPage />)} />
<Route path="/agents" element={renderSettingViewRedirect('agents')} />
<Route path="/models" element={renderSettingViewRedirect('models')} />
<Route path="/skills" element={renderLazyPage(<SkillsPage />)} />
<Route path="/cron" element={renderLazyPage(<CronPage />)} />
<Route path="/scripts" element={renderLazyPage(<ScriptsPage />)} />

View File

@@ -32,8 +32,6 @@ export const NAV_ITEMS: NavItem[] = [
{ path: '/home', labelKey: 'sidebar.home' },
{ path: '/knowledge', labelKey: 'sidebar.knowledge' },
{ path: '/channels', labelKey: 'sidebar.channels' },
{ path: '/agents', labelKey: 'sidebar.agents' },
{ path: '/models', labelKey: 'sidebar.models' },
{ path: '/skills', labelKey: 'sidebar.skills' },
{ path: '/cron', labelKey: 'sidebar.cron' },
// { path: '/scripts', labelKey: 'sidebar.scripts' },
@@ -44,13 +42,14 @@ export function normalizeWorkspacePath(pathname: string): WorkspacePath {
switch (pathname) {
case '/knowledge':
case '/channels':
case '/agents':
case '/models':
case '/skills':
case '/cron':
case '/scripts':
case '/setting':
return pathname;
case '/agents':
case '/models':
return '/setting';
case '/home':
default:
return DEFAULT_PATH;