/** 连续血量条:长度对应 0–100 血,右侧镜像后从画面中心向外缩短。未接入时保留空条与说明。 */ import { teamColor } from "../lib/format"; import type { HealthConfig, TeamHealthDto } from "../lib/types"; interface Props { health: TeamHealthDto; config: HealthConfig; /** 挂在画面哪一角。`right` 会把条整个镜像过来(含缺血的退向)。 */ align: "left" | "right"; /** 这一格是谁:用户端用「我方 / 对手」把两条同色的血区分开。 */ tag?: string; /** 休眠态:只留数字,标签与提示退到背景里。 */ asleep?: boolean; } export function HealthBar({ health, config, align, tag, asleep = false }: Props) { // 脉动交给 CSS,减少动态效果时仍保留低血颜色,停止闪动。 const pulsing = config.pulse && health.available && health.critical; const color = health.critical ? "var(--error)" : teamColor(health.team); const raw = health.available ? Math.max(0, Math.min(100, health.hp ?? 0)) : 0; const showThreshold = config.lowThreshold > 0 && config.lowThreshold < 100; // 宽度按配置收窄。它挂在画面角上,太宽会盖住画面本身。 const width = `${Math.round(config.width * 100)}%`; return (