基本功能完成,下一步开始美化UI
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { Layout, Menu, Button, Avatar, Dropdown, message } from 'antd';
|
||||
import { Outlet, useNavigate, useLocation } from 'react-router-dom';
|
||||
import { useNavigate, useLocation } from 'react-router-dom';
|
||||
import {
|
||||
DashboardOutlined,
|
||||
QuestionCircleOutlined,
|
||||
SettingOutlined,
|
||||
BarChartOutlined,
|
||||
UserOutlined,
|
||||
LogoutOutlined,
|
||||
@@ -12,11 +11,14 @@ import {
|
||||
SafetyOutlined,
|
||||
BookOutlined,
|
||||
CalendarOutlined,
|
||||
TeamOutlined
|
||||
TeamOutlined,
|
||||
MenuFoldOutlined,
|
||||
MenuUnfoldOutlined
|
||||
} from '@ant-design/icons';
|
||||
import { useAdmin } from '../contexts';
|
||||
import { Logo } from '../components/common/Logo';
|
||||
|
||||
const { Header, Sider, Content } = Layout;
|
||||
const { Header, Sider, Content, Footer } = Layout;
|
||||
|
||||
const AdminLayout = ({ children }: { children: React.ReactNode }) => {
|
||||
const navigate = useNavigate();
|
||||
@@ -89,11 +91,20 @@ const AdminLayout = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
return (
|
||||
<Layout style={{ minHeight: '100vh' }}>
|
||||
<Sider trigger={null} collapsible collapsed={collapsed} theme="light">
|
||||
<div className="logo p-4 text-center">
|
||||
<h2 className="text-lg font-bold text-blue-600 m-0">
|
||||
{collapsed ? '问卷' : '问卷系统'}
|
||||
</h2>
|
||||
<Sider
|
||||
trigger={null}
|
||||
collapsible
|
||||
collapsed={collapsed}
|
||||
theme="light"
|
||||
className="shadow-md z-10"
|
||||
width={240}
|
||||
>
|
||||
<div className="h-16 flex items-center justify-center border-b border-gray-100">
|
||||
{collapsed ? (
|
||||
<span className="text-xl font-bold text-mars-500">OA</span>
|
||||
) : (
|
||||
<Logo variant="primary" />
|
||||
)}
|
||||
</div>
|
||||
<Menu
|
||||
mode="inline"
|
||||
@@ -101,34 +112,49 @@ const AdminLayout = ({ children }: { children: React.ReactNode }) => {
|
||||
items={menuItems}
|
||||
onClick={handleMenuClick}
|
||||
style={{ borderRight: 0 }}
|
||||
className="py-4"
|
||||
/>
|
||||
</Sider>
|
||||
|
||||
<Layout>
|
||||
<Header className="bg-white shadow-sm flex justify-between items-center px-6">
|
||||
<Layout className="bg-gray-50/50">
|
||||
<Header className="bg-white shadow-sm flex justify-between items-center px-6 h-16 sticky top-0 z-10">
|
||||
<Button
|
||||
type="text"
|
||||
icon={collapsed ? <DashboardOutlined /> : <DashboardOutlined />}
|
||||
icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
|
||||
onClick={() => setCollapsed(!collapsed)}
|
||||
className="text-lg"
|
||||
className="text-lg w-10 h-10 flex items-center justify-center"
|
||||
/>
|
||||
|
||||
<div className="flex items-center">
|
||||
<span className="mr-4 text-gray-600">
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="text-gray-600 hidden sm:block">
|
||||
欢迎,{admin?.username}
|
||||
</span>
|
||||
<Dropdown menu={{ items: userMenuItems }} placement="bottomRight">
|
||||
<Avatar icon={<UserOutlined />} className="cursor-pointer" />
|
||||
<Dropdown menu={{ items: userMenuItems }} placement="bottomRight" arrow>
|
||||
<Avatar
|
||||
icon={<UserOutlined />}
|
||||
className="cursor-pointer bg-mars-100 text-mars-600 hover:bg-mars-200 transition-colors"
|
||||
/>
|
||||
</Dropdown>
|
||||
</div>
|
||||
</Header>
|
||||
|
||||
<Content className="m-6 p-6 bg-white rounded-lg shadow-sm">
|
||||
{children}
|
||||
<Content className="m-6 flex flex-col">
|
||||
<div className="flex-1 bg-white rounded-xl shadow-sm p-6 min-h-[calc(100vh-160px)]">
|
||||
{children}
|
||||
</div>
|
||||
</Content>
|
||||
|
||||
<Footer className="bg-transparent text-center py-6 px-8 text-gray-400 text-sm flex flex-col md:flex-row justify-between items-center">
|
||||
<div>
|
||||
© {new Date().getFullYear()} Boonlive OA System. All Rights Reserved.
|
||||
</div>
|
||||
<div className="mt-4 md:mt-0">
|
||||
<Logo variant="secondary" />
|
||||
</div>
|
||||
</Footer>
|
||||
</Layout>
|
||||
</Layout>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminLayout;
|
||||
export default AdminLayout;
|
||||
|
||||
Reference in New Issue
Block a user