初始化

This commit is contained in:
SunYF
2026-08-28 14:07:22 +08:00
parent a185247ab1
commit b34325a16f
971 changed files with 291 additions and 220360 deletions
-91
View File
@@ -1,91 +0,0 @@
import { useEffect } from 'react';
import { useStore } from './store/useStore';
import { color } from './theme/tokens';
import KPICards from './components/KPICards';
import EquipmentGrid from './components/EquipmentGrid';
import ProductionChart from './components/ProductionChart';
import AlarmTable from './components/AlarmTable';
import TrendChart from './components/TrendChart';
import YieldRateChart from './components/YieldRateChart';
import { AppHeader } from './components/AppHeader';
import { Panel } from './components/ui/Panel';
export default function App() {
const fetchAll = useStore((s) => s.fetchAll);
const refresh = useStore((s) => s.refresh);
useEffect(() => {
fetchAll();
const t = setInterval(refresh, 10000);
return () => clearInterval(t);
}, [fetchAll, refresh]);
// 订阅 MES SSE:看板相关事件(dashboard_update)实时触发刷新
// 断线时浏览器会自动重连,轮询(10s)作为兜底
useEffect(() => {
const es = new EventSource('/sse');
const onUpdate = () => refresh();
es.addEventListener('dashboard_update', onUpdate);
return () => es.close();
}, [refresh]);
// 装配线看板:仅产线概览(扫码枪+拧紧枪工位,无 CNC/清洗机)
return (
<div style={{
width: '100vw', height: '100vh',
display: 'flex', flexDirection: 'column',
padding: '8px 12px 12px',
gap: 10, overflow: 'hidden',
color: color.text.primary,
}}>
<AppHeader />
<main style={{
flex: 1, minHeight: 0, display: 'flex',
flexDirection: 'column', gap: 10,
animation: 'fade-in-up 300ms ease',
}}>
{/* KPI Row */}
<div style={{ flexShrink: 0 }}>
<KPICards />
</div>
{/* Middle Row: Equipment | Production | Alarms */}
<div style={{
flex: 3, display: 'grid',
gridTemplateColumns: '1fr 1.4fr 1fr',
gap: 10, minHeight: 0,
}}>
<Panel title="工位状态" subtitle="STATION STATUS" padding={8}>
<EquipmentGrid />
</Panel>
<Panel title="生产进度" subtitle="WORK ORDERS" padding={4}>
<ProductionChart />
</Panel>
<Panel
title="活跃报警"
subtitle="LIVE ALARMS"
accent={color.status.danger}
padding={8}
>
<AlarmTable />
</Panel>
</div>
{/* Bottom Row */}
<div style={{
flex: 2, display: 'grid',
gridTemplateColumns: '1.4fr 1fr',
gap: 10, minHeight: 0,
}}>
<Panel title="近10日产量趋势" subtitle="10-DAY OUTPUT" padding={4}>
<TrendChart />
</Panel>
<Panel title="近10日合格率统计" subtitle="10-DAY YIELD" padding={4}>
<YieldRateChart />
</Panel>
</div>
</main>
</div>
);
}