Ver código fonte

fix(cockpit): 基础设施页设施图例行宽与总览对齐

ChenJZ 4 horas atrás
pai
commit
67230665c9
1 arquivos alterados com 16 adições e 13 exclusões
  1. 16 13
      src/modules/cockpit/components/MapCanvas.vue

+ 16 - 13
src/modules/cockpit/components/MapCanvas.vue

@@ -703,6 +703,12 @@ onBeforeUnmount(() => {
    ③颜色语义清晰、不靠降低不透明度压存在感。故两组共用同一张网格模板与同一档行尺寸,
    颜色用语义色描边 + 低透明底板(不降行本身 opacity),视野占用靠几何尺寸而非淡化。 */
 .map-holo__legend-bar {
+    /* 图例行宽的唯一来源(维护者 2026-11-18:基础设施页的设施图例比总览小了一圈)。
+       总览里两组各占半条、组内 5 列 1fr 会把行**拉伸填满**半条(≈120u);
+       单组模式若用 max-content,每行只剩自身文字宽(≈90u),于是小一圈且参差。
+       这里把行宽钉成同一档设计像素,两种模式都读它 —— 大小由结构保证一致,不靠巧合。
+       120u 的取值:半条图例(约 612u)减去 4 个 3u 间隙后均分 5 列 ≈ 120u。 */
+    --legend-row-w: calc(120 * var(--u, 1px));
     display: grid;
     grid-template-columns: repeat(2, minmax(0, 1fr));
     gap: calc(10 * var(--u, 1px));
@@ -734,19 +740,21 @@ onBeforeUnmount(() => {
 }
 
 /* 两组并排时(总体概览)共用同一张 5 列网格:设施类型 9 项 → 5+4,设备状态 7 项 → 5+2。
-   行宽由列宽决定,两组行尺寸完全一致(以设施类型的行为准)。 */
+   列宽取共享的 --legend-row-w(不是 1fr):半条图例刚好等于 5 × 行宽时视觉不变,
+   半条更宽时也不会把行拉得比单组模式更大 —— 两种模式的行宽因此恒等。 */
 .map-holo__legend-grid {
     display: grid;
-    grid-template-columns: repeat(5, minmax(0, 1fr));
+    grid-template-columns: repeat(5, minmax(0, var(--legend-row-w)));
     gap: calc(3 * var(--u, 1px));
     min-width: 0;
+    justify-content: start;
 }
 
 /* 单组模式(基础设施 / 运行监测 / 预警处置):该组独占图例条。
    · 图例条从「两列、内容宽、居中」改成「一列、整条满宽、靠左」——
      原先只渲染一组时它仍被塞进第一列(半宽)并被居中,看起来既没左对齐、尺寸也比总览小;
-   · 组内改成**单行**(grid-auto-flow: column + 内容宽度),一行排开不再换行;
-     列宽用 max-content 而不是 1fr:保持与总览里同一档行宽,两组大小由此对应。 */
+   · 组内**单行**排开(grid-auto-flow: column),列宽同样取 --legend-row-w,
+     与总览逐格等宽;行数 9 项 × 120u ≈ 1104u < 中央区,一行放得下。 */
 .map-holo__legend-bar--single {
     grid-template-columns: minmax(0, 1fr);
     width: 100%;
@@ -757,7 +765,8 @@ onBeforeUnmount(() => {
 .map-holo__legend-bar--single .map-holo__legend-grid {
     grid-template-columns: none;
     grid-auto-flow: column;
-    grid-auto-columns: max-content;
+    /* min 端留 0:中央区偏窄时列宽等比收缩,仍保持一行,不横向溢出。 */
+    grid-auto-columns: minmax(0, var(--legend-row-w));
     justify-content: start;
 }
 
@@ -777,14 +786,8 @@ onBeforeUnmount(() => {
     }
 }
 
-/* 单组且中央区偏窄时,单行内容宽会横向溢出:退回到 5 列换行(仍是同一档行宽)。 */
-@container (max-width: 820px) {
-    .map-holo__legend-bar--single .map-holo__legend-grid {
-        grid-template-columns: repeat(5, minmax(0, 1fr));
-        grid-auto-flow: row;
-        grid-auto-columns: auto;
-    }
-}
+/* 单组模式不再需要「窄屏退回换行」的兜底:列宽已用 minmax(0, --legend-row-w),
+   中央区偏窄时各列等比收缩、始终一行,既不换行(维护者要求一字排开)也不横向溢出。 */
 
 /* 票 14:状态栏行是**按钮**(全局筛选入口)。抹掉按钮默认外观,保留可聚焦/hover/选中反馈。 */
 .map-holo__legend-row {