Let temperature formatting ship without dashboard bulk

Temperature formatting was embedded in the large dashboard utility module, so small scan-terminal views had to import the heavy utility surface for simple labels. This moves the pure temperature helpers into a lightweight module while keeping dashboard-utils re-exports for compatibility.

Constraint: Preserve existing temperature text output and all dashboard-utils import compatibility.

Rejected: Split chart, pace, and model helpers in the same pass | those helpers have wider coupling and should move one boundary at a time.

Confidence: high

Scope-risk: narrow

Reversibility: clean

Tested: TypeScript diagnostics for temperature-utils, dashboard-utils, and OpportunityTable

Tested: npm run build

Not-tested: Bundle analyzer size comparison.
This commit is contained in:
2569718930@qq.com
2026-04-28 11:32:03 +08:00
parent 8d05812a7e
commit be41becb30
8 changed files with 58 additions and 44 deletions
@@ -9,13 +9,15 @@ import type {
} from "@/lib/dashboard-types";
import { getLocalizedCityName } from "@/lib/dashboard-home-copy";
import {
formatTemperatureValue,
getModelView,
getProbabilityView,
getTodayPaceView,
} from "@/lib/dashboard-utils";
import {
formatTemperatureValue,
normalizeTemperatureLabel,
normalizeTemperatureSymbol,
} from "@/lib/dashboard-utils";
} from "@/lib/temperature-utils";
type PhaseMeta = {
label: string;
@@ -1,5 +1,6 @@
import type { CityDetail, ScanOpportunityRow } from "@/lib/dashboard-types";
import { formatTemperatureValue, getTodayPaceView } from "@/lib/dashboard-utils";
import { getTodayPaceView } from "@/lib/dashboard-utils";
import { formatTemperatureValue } from "@/lib/temperature-utils";
import { getPeakWindowLabel } from "@/components/dashboard/scan-terminal/decision-utils";
export function AiForecastKPIBar({
@@ -21,7 +21,8 @@ import {
useCityMarketScan,
} from "@/components/dashboard/scan-terminal/use-ai-city-card-data";
import type { CityDetail, ScanOpportunityRow } from "@/lib/dashboard-types";
import { formatTemperatureValue, getModelView, getTodayPaceView } from "@/lib/dashboard-utils";
import { getModelView, getTodayPaceView } from "@/lib/dashboard-utils";
import { formatTemperatureValue } from "@/lib/temperature-utils";
function toFiniteDecisionNumber(value: unknown) {
if (value == null || value === "") return null;
@@ -2,7 +2,7 @@ import { memo, useEffect, useMemo, useState } from "react";
import { getWindowPhaseMeta } from "@/components/dashboard/OpportunityTable";
import type { ScanOpportunityRow } from "@/lib/dashboard-types";
import { getLocalizedCityName } from "@/lib/dashboard-home-copy";
import { formatTemperatureValue } from "@/lib/dashboard-utils";
import { formatTemperatureValue } from "@/lib/temperature-utils";
import {
formatShortDate,
getPeakCountdownMeta,
@@ -1,7 +1,7 @@
import { memo, useMemo } from "react";
import clsx from "clsx";
import type { ScanOpportunityRow, ScanTerminalResponse } from "@/lib/dashboard-types";
import { formatTemperatureValue } from "@/lib/dashboard-utils";
import { formatTemperatureValue } from "@/lib/temperature-utils";
import { LoadingSignal } from "@/components/dashboard/scan-terminal/LoadingSignal";
import {
formatRowPrice,
@@ -1,9 +1,9 @@
import type { MarketScan, MarketTopBucket } from "@/lib/dashboard-types";
import { getTodayPaceView } from "@/lib/dashboard-utils";
import {
formatTemperatureValue,
getTodayPaceView,
normalizeTemperatureLabel,
} from "@/lib/dashboard-utils";
} from "@/lib/temperature-utils";
import type { AiCityForecastPayload } from "@/components/dashboard/scan-terminal/types";
export type WeatherDecisionView = {