1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
| import React from 'react'; import { LaptopOutlined, NotificationOutlined, UserOutlined, DownOutlined, SmileOutlined } from '@ant-design/icons'; import { Breadcrumb, Layout, Menu, theme, Dropdown, Space, Flex, Steps, Carousel } from 'antd';
const { Header, Content, Sider } = Layout; const items1 = ['1', '2', '3'].map(key => ({ key, label: `nav ${key}`, })); const items2 = [UserOutlined, LaptopOutlined, NotificationOutlined].map((icon, index) => { const key = String(index + 1); return { key: `sub${key}`, icon: React.createElement(icon), label: `subnav ${key}`, children: Array.from({ length: 4 }).map((_, j) => { const subKey = index * 4 + j + 1; return { key: subKey, label: `option${subKey}`, }; }), }; }); const items = [ { key: '1', label: ( <a target="_blank" rel="noopener noreferrer" href="https://www.antgroup.com"> 1111 </a> ), }, { key: '2', label: ( <a target="_blank" rel="noopener noreferrer" href="https://www.aliyun.com"> 2222 (disabled) </a> ), icon: <SmileOutlined />, disabled: true, }, { key: '3', label: ( <a target="_blank" rel="noopener noreferrer" href="https://www.luohanacademy.com"> 3333 (disabled) </a> ), disabled: true, }, { key: '4', danger: true, label: '4444-danger', }, ]; const App = () => { const { token: { colorBgContainer, borderRadiusLG }, } = theme.useToken(); return ( <Layout style={{height: '100vh'}}> {/* 设置整体布局为视口的 100% */} <Header style={{ display: 'flex', alignItems: 'center' }}> <div className="demo-logo" style={{ color: "white" }}>Logo</div> <Menu theme="dark" mode="horizontal" defaultSelectedKeys={['2']} items={items1} style={{ flex: 1, minWidth: 0 }} /> </Header> <Layout> <Sider width={200} style={{ background: colorBgContainer }}> <Menu mode="inline" defaultSelectedKeys={['1']} defaultOpenKeys={['sub1']} style={{ height: '100%', borderInlineEnd: 0 }} items={items2} /> </Sider> <Layout style={{ padding: '0 24px 24px' }}> <Breadcrumb items={[{ title: 'Home' }, { title: 'List' }, { title: 'App' }]} style={{ margin: '16px 0' }} /> <Content style={{ padding: 24, margin: 0, minHeight: 280, background: colorBgContainer, borderRadius: borderRadiusLG, }} > {/* 内容区域 */} <div>Content</div> {/* 下拉框 */} <div> <Dropdown menu={{ items }}> <a onClick={e => e.preventDefault()}> <Space> Hover me <DownOutlined /> </Space> </a> </Dropdown> </div> {/* 步骤条 */} <div> <StepApp></StepApp> </div> {/* 轮播 */} <div style={{width:'500px'}}> <CarouselApp></CarouselApp> </div> </Content> </Layout> </Layout> </Layout> ); }; export default App;
const content = 'This is a content.'; const stepItems = [ { title: 'Finished', content, }, { title: 'In Progress', content, subTitle: 'Left 00:00:08', }, { title: 'Waiting', content, }, ]; const StepApp = () => ( <Flex vertical gap="large"> <Steps current={1} items={stepItems} /> </Flex> );
const contentStyle = { margin: 0, height: '160px', color: '#fff', lineHeight: '160px', textAlign: 'center', background: '#364d79', }; const CarouselApp = () => ( <Carousel autoplay> <div> <h3 style={contentStyle}>1</h3> </div> <div> <h3 style={contentStyle}>2</h3> </div> <div> <h3 style={contentStyle}>3</h3> </div> <div> <h3 style={contentStyle}>4</h3> </div> </Carousel> );
|