重构单位导入路径,优化代码结构

This commit is contained in:
JIANG
2026-03-07 17:31:14 +08:00
parent ddb02cc688
commit b4ab3e287b
11 changed files with 39 additions and 26 deletions
@@ -11,9 +11,6 @@ export const AREA_COLORS = [
"#be123c",
];
export const FLOW_DISPLAY_UNIT = "m³/h";
const M3H_FACTOR = 3600;
export const getAreaColor = (areaId: string | number | undefined) => {
const text = String(areaId ?? "");
let hash = 0;
@@ -22,17 +19,3 @@ export const getAreaColor = (areaId: string | number | undefined) => {
}
return AREA_COLORS[hash % AREA_COLORS.length];
};
export const toM3h = (value: number, sourceUnit: string = "m³/s") => {
if (!Number.isFinite(value)) return Number.NaN;
const normalizedUnit = sourceUnit.trim().toLowerCase();
if (normalizedUnit === "m³/h") return value;
return value * M3H_FACTOR;
};
export const toM3s = (value: number, sourceUnit: string = "m³/h") => {
if (!Number.isFinite(value)) return Number.NaN;
const normalizedUnit = sourceUnit.trim().toLowerCase();
if (normalizedUnit === "m³/s") return value;
return value / M3H_FACTOR;
};