Spaces:
Runtime error

SII-gelingli
UI redesign: modern gradient theme, improved chat interface, better login page
c1b740a
Raw History Blame Contribute Delete
4.69 kB
import { useState } from 'react';
import { Outlet, useNavigate, useLocation } from 'react-router-dom';
import { Layout, Menu, Button, Typography, Avatar, Dropdown } from 'antd';
import {
MessageOutlined,
ToolOutlined,
HistoryOutlined,
SettingOutlined,
LogoutOutlined,
UserOutlined,
MenuFoldOutlined,
MenuUnfoldOutlined,
} from '@ant-design/icons';
import { useAuthStore } from '../../stores/authStore';
import Sidebar from './Sidebar';
const { Header, Sider, Content } = Layout;
export default function AppLayout() {
const [collapsed, setCollapsed] = useState(false);
const navigate = useNavigate();
const location = useLocation();
const { user, logout } = useAuthStore();
const isChatRoute = location.pathname.startsWith('/chat');
const menuItems = [
{ key: '/chat', icon: <MessageOutlined />, label: 'Chat' },
{ key: '/tools', icon: <ToolOutlined />, label: 'Tools' },
{ key: '/history', icon: <HistoryOutlined />, label: 'History' },
{ key: '/settings', icon: <SettingOutlined />, label: 'Settings' },
];
const userMenuItems = [
{
key: 'logout',
icon: <LogoutOutlined />,
label: 'Logout',
onClick: () => { logout(); navigate('/login'); },
},
];
return (
<Layout style={{ minHeight: '100vh' }}>
<Header
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
padding: '0 24px',
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.15)',
position: 'sticky',
top: 0,
zIndex: 100,
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
<div
style={{
width: 36,
height: 36,
borderRadius: 10,
background: 'rgba(255, 255, 255, 0.2)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<span style={{ fontSize: 20 }}>⚗️</span>
</div>
<Typography.Text strong style={{ color: '#fff', fontSize: 18, letterSpacing: 0.5 }}>
EchemAgent
</Typography.Text>
</div>
<Menu
mode="horizontal"
selectedKeys={[isChatRoute ? '/chat' : location.pathname]}
items={menuItems}
onClick={({ key }) => navigate(key)}
style={{
flex: 1,
justifyContent: 'center',
background: 'transparent',
borderBottom: 'none',
color: 'rgba(255, 255, 255, 0.85)',
}}
theme="dark"
/>
<Dropdown menu={{ items: userMenuItems }} placement="bottomRight">
<div
style={{
display: 'flex',
alignItems: 'center',
gap: 10,
cursor: 'pointer',
padding: '6px 12px',
borderRadius: 20,
background: 'rgba(255, 255, 255, 0.1)',
transition: 'all 0.3s',
}}
>
<Avatar
size={28}
icon={<UserOutlined />}
style={{ background: 'rgba(255, 255, 255, 0.3)' }}
/>
<Typography.Text style={{ color: '#fff', fontSize: 14 }}>
{user?.username}
</Typography.Text>
</div>
</Dropdown>
</Header>
<Layout>
{isChatRoute && (
<Sider
width={280}
collapsedWidth={0}
collapsible
collapsed={collapsed}
onCollapse={setCollapsed}
trigger={null}
style={{
background: '#fff',
borderRight: '1px solid #f0f0f0',
overflow: 'hidden',
}}
>
<div
style={{
padding: '12px',
borderBottom: '1px solid #f0f0f0',
display: 'flex',
justifyContent: 'flex-end',
}}
>
<Button
type="text"
icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
onClick={() => setCollapsed(!collapsed)}
size="small"
/>
</div>
<Sidebar collapsed={collapsed} />
</Sider>
)}
<Content
style={{
background: isChatRoute ? '#fafbfc' : '#fff',
minHeight: 'calc(100vh - 64px)',
}}
>
<Outlet />
</Content>
</Layout>
</Layout>
);
}