feat(web): redesign fleet cards and instance workspace

This commit is contained in:
chick
2026-07-19 18:54:26 +08:00
parent f2803896a8
commit 49ee4e6570
9 changed files with 458 additions and 74 deletions
+65 -9
View File
@@ -102,6 +102,66 @@ function StructuredSection({ label, values }: { label: string; values: OverviewS
);
}
function ResourceSummary({ instance }: { instance: InstanceContext }) {
const resources = instance.resources;
const metric = (label: string, value: number | undefined) => (
<article className="overview-resource-card">
<span>{label}</span>
{value === undefined ? (
<strong></strong>
) : (
<>
<strong>{value.toFixed(1)}%</strong>
<meter min="0" max="100" value={value} aria-label={`${label}使用率`} />
</>
)}
</article>
);
return (
<section className="overview-operations" aria-label="运行状态与资源">
<h2></h2>
{instance.resourceSummaryState === 'loading' ? (
<p role="status" aria-label="资源摘要状态">
</p>
) : null}
{instance.resourceSummaryState === 'unavailable' ? (
<p role="status" aria-label="资源摘要状态">
使
</p>
) : null}
<div className="overview-resource-grid">
<article className="overview-resource-card">
<span></span>
<strong>
{instance.status === 'online'
? '在线'
: instance.status === 'offline'
? '离线'
: instance.status === 'auth-required'
? '需要认证'
: '未知'}
</strong>
</article>
{metric('CPU', resources?.cpuPercent)}
{metric('内存', resources?.memoryPercent)}
<article className="overview-resource-card">
<span></span>
<strong>
{resources?.maxTemperatureCelsius === undefined
? '暂未获取'
: `${resources.maxTemperatureCelsius.toFixed(1)} °C`}
</strong>
</article>
<article className="overview-resource-card overview-resource-phone">
<span></span>
<strong>{resources?.phoneNumbers?.join('、') || '暂未获取'}</strong>
</article>
</div>
</section>
);
}
export function OverviewSystemPage({
instance,
dataSource,
@@ -159,12 +219,7 @@ export function OverviewSystemPage({
</div>
);
if (!dataSource)
return (
<div className="state-panel" role="status" aria-label="概览不可用">
</div>
);
if (!dataSource) return <ResourceSummary instance={instance} />;
const retainedSnapshot =
state.kind === 'loading' || state.kind === 'error' ? state.snapshot : undefined;
@@ -191,6 +246,7 @@ export function OverviewSystemPage({
return (
<div className="overview-system">
<ResourceSummary instance={instance} />
{state.kind === 'loading' ? <p role="status"></p> : null}
{state.kind === 'error' ? (
<div className="state-panel state-error" role="alert">
@@ -211,10 +267,10 @@ export function OverviewSystemPage({
<StructuredSection key={key} label={label} values={snapshot[key]} />
))}
</div>
<section className="state-panel" aria-label="系统操作">
<h2></h2>
<details className="system-operation-note">
<summary></summary>
<p> R3 </p>
</section>
</details>
</div>
);
}