侧边栏增加场站
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Outlet, useNavigate, useLocation } from 'react-router-dom';
|
||||
import {
|
||||
Layout, Menu, Button, Space, ConfigProvider, theme, Select, Avatar
|
||||
Layout, Menu, Button, Space, ConfigProvider, theme, Select, Avatar, Card, Tag
|
||||
} from 'antd';
|
||||
import zhCN from 'antd/locale/zh_CN';
|
||||
import {
|
||||
@@ -106,7 +106,6 @@ export default function AppLayout() {
|
||||
token: {
|
||||
colorPrimary: '#1890ff',
|
||||
borderRadius: 2,
|
||||
// 全局紧凑设置
|
||||
padding: 12,
|
||||
paddingLG: 16,
|
||||
margin: 12,
|
||||
@@ -116,17 +115,17 @@ export default function AppLayout() {
|
||||
Layout: { headerBg: '#fff', siderBg: '#fff' },
|
||||
Menu: { itemBg: '#fff', itemSelectedBg: '#e6f4ff' },
|
||||
Card: {
|
||||
paddingLG: 12, // 减小 Card 默认内边距
|
||||
paddingLG: 12,
|
||||
},
|
||||
Table: {
|
||||
padding: 8, // 减小 Table 单元格边距
|
||||
padding: 8,
|
||||
paddingXS: 4,
|
||||
},
|
||||
Form: {
|
||||
itemMarginBottom: 12, // 减小表单项间距
|
||||
itemMarginBottom: 12,
|
||||
},
|
||||
Space: {
|
||||
gap: 8, // 减小 Space 间距
|
||||
gap: 8,
|
||||
}
|
||||
}
|
||||
}}
|
||||
@@ -135,18 +134,17 @@ export default function AppLayout() {
|
||||
<Header style={{
|
||||
background: '#0837a8',
|
||||
color: '#fff',
|
||||
minHeight: "40px", // 减小 Header 高度
|
||||
minHeight: "40px",
|
||||
height: "auto",
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
padding: '2px 12px', // 减小 Header 边距
|
||||
padding: '2px 12px',
|
||||
flexWrap: 'wrap',
|
||||
gap: '4px'
|
||||
}}>
|
||||
<Space size="large" style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap', height: "100%", justifyContent: "center" }}>
|
||||
|
||||
{/* ====================== 收起/展开按钮 ====================== */}
|
||||
<Button
|
||||
type="text"
|
||||
icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
|
||||
@@ -212,13 +210,55 @@ export default function AppLayout() {
|
||||
theme="light"
|
||||
style={{ borderRight: '1px solid #e5e7eb' }}
|
||||
>
|
||||
<Menu
|
||||
mode="inline"
|
||||
theme="light"
|
||||
selectedKeys={[location.pathname]}
|
||||
items={menuItems}
|
||||
onClick={({ key }) => navigate(key)}
|
||||
/>
|
||||
{/* 关键:用Layout实现上下分布 */}
|
||||
<Layout style={{ height: '100%', flexDirection: 'column', background: '#fff' }}>
|
||||
<Menu
|
||||
mode="inline"
|
||||
theme="light"
|
||||
selectedKeys={[location.pathname]}
|
||||
items={menuItems}
|
||||
onClick={({ key }) => navigate(key)}
|
||||
style={{ flex: 1, overflowY: 'auto', borderRight: 0 }}
|
||||
/>
|
||||
|
||||
{/* 场站信息卡片:仅在侧边栏展开时显示 */}
|
||||
{!collapsed && currentStation && (
|
||||
<Card
|
||||
size="small"
|
||||
style={{
|
||||
border: '1px solid #e5e7eb',
|
||||
borderRadius: 8,
|
||||
//borderLeft: 0,
|
||||
//borderRight: 0,
|
||||
//borderBottom: 0,
|
||||
margin: 4,
|
||||
marginBottom: 50
|
||||
}}
|
||||
styles={{ body: { padding: '12px 8px' } }}
|
||||
>
|
||||
<div style={{ textAlign: 'left' }}>
|
||||
<div style={{ fontSize: 14, fontWeight: 600, marginBottom: 8 }}>
|
||||
{currentStation.siteName || '1MW 光伏电站'}
|
||||
</div>
|
||||
{/* 这里可以放电站图片,用你自己的电站图片地址替换 */}
|
||||
<img style={{ width: '100%', borderRadius: "8px", marginBottom: 8 }} src="https://images.unsplash.com/photo-1509391366360-2e959784a276?ixlib=rb-1.2.1&auto=format&fit=crop&w=1200&q=80" />
|
||||
|
||||
{/* <img src="电站图片地址" style={{ width: '100%', borderRadius: 4, marginBottom: 8 }} alt="电站" /> */}
|
||||
<div style={{ fontSize: 10, color: '#666', lineHeight: 1.8 }}>
|
||||
<div>装机容量:{currentStation.capacity || '1.00'} MWp</div>
|
||||
<div>并网时间:{currentStation.gridTime || '2024-01-15'}</div>
|
||||
<div>电站地址:{currentStation.address || '浙江省杭州市'}</div>
|
||||
<div>电站类型:{currentStation.type || '地面电站'}</div>
|
||||
<div style={{ marginTop: 4, display: 'flex', alignItems: 'center' }}>
|
||||
<span style={{ color: '#52c41a' }}>运行状态</span>
|
||||
<span style={{ color: '#52c41a' }}>●</span>
|
||||
<span style={{ color: '#52c41a', marginLeft: 4 }}>正常运行</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
</Layout>
|
||||
</Sider>
|
||||
|
||||
<Content style={{ background: '#f4f7f9', overflowY: 'auto', padding: '4px 8px' }}>
|
||||
|
||||
@@ -414,7 +414,7 @@ export default function AlarmCenterPage() {
|
||||
trend: (() => {
|
||||
const now = todayData.total ?? 0;
|
||||
const last = yesterdayData.total ?? 0;
|
||||
if (last === 0) return '较昨日 无数据';
|
||||
if (last === 0) return '较昨日 无变化';
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
const rateStr = rateNum.toFixed(1);
|
||||
return rateNum > 0 ? `较昨日 +${rateStr}% ↑` : rateNum < 0 ? `较昨日 ${rateStr}% ↓` : '较昨日 0%';
|
||||
@@ -437,7 +437,7 @@ export default function AlarmCenterPage() {
|
||||
trend: (() => {
|
||||
const now = todayData.levelStats?.[1] ?? 0;
|
||||
const last = yesterdayData.levelStats?.[1] ?? 0;
|
||||
if (last === 0) return '较昨日 无数据';
|
||||
if (last === 0) return '较昨日 无变化';
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
const rateStr = rateNum.toFixed(1);
|
||||
return rateNum > 0 ? `较昨日 +${rateStr}% ↑` : rateNum < 0 ? `较昨日 ${rateStr}% ↓` : '较昨日 0%';
|
||||
@@ -460,7 +460,7 @@ export default function AlarmCenterPage() {
|
||||
trend: (() => {
|
||||
const now = todayData.processing ?? 0;
|
||||
const last = yesterdayData.processing ?? 0;
|
||||
if (last === 0) return '较昨日 无数据';
|
||||
if (last === 0) return '较昨日 无变化';
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
const rateStr = rateNum.toFixed(1);
|
||||
return rateNum > 0 ? `较昨日 +${rateStr}% ↑` : rateNum < 0 ? `较昨日 ${rateStr}% ↓` : '较昨日 0%';
|
||||
@@ -483,7 +483,7 @@ export default function AlarmCenterPage() {
|
||||
trend: (() => {
|
||||
const now = todayData.closed ?? 0;
|
||||
const last = yesterdayData.closed ?? 0;
|
||||
if (last === 0) return '较昨日 无数据';
|
||||
if (last === 0) return '较昨日 无变化';
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
const rateStr = rateNum.toFixed(1);
|
||||
return rateNum > 0 ? `较昨日 +${rateStr}% ↑` : rateNum < 0 ? `较昨日 ${rateStr}% ↓` : '较昨日 0%';
|
||||
|
||||
Reference in New Issue
Block a user