feat: implement PolyWeather dashboard with map UI, data collection, analysis, and comprehensive documentation.

This commit is contained in:
2569718930@qq.com
2026-03-10 09:02:56 +08:00
parent aab4477ab3
commit 396c373cba
18 changed files with 2398 additions and 634 deletions
@@ -33,7 +33,7 @@
/* Spacing */
--panel-width: 560px;
--header-height: 56px;
--sidebar-width: 280px;
--sidebar-width: 260px;
/* Effects */
--glass-blur: 20px;
@@ -328,6 +328,7 @@
}
.root :global(.city-item) {
width: 100%;
display: flex;
flex-direction: column;
gap: 4px;
@@ -336,6 +337,10 @@
cursor: pointer;
transition: var(--transition);
border: 1px solid transparent;
background: transparent;
color: inherit;
font-family: inherit;
text-align: left;
}
.root :global(.city-item:hover) {
background: rgba(99, 102, 241, 0.08);
@@ -722,6 +727,29 @@
background: rgba(99, 102, 241, 0.15);
}
.root :global(.prob-market-inline) {
min-width: 120px;
text-align: right;
font-size: 12px;
font-weight: 700;
border-radius: 999px;
padding: 4px 10px;
letter-spacing: 0.02em;
font-variant-numeric: tabular-nums;
}
.root :global(.prob-market-inline.yes) {
color: #4ade80;
background: rgba(74, 222, 128, 0.12);
border: 1px solid rgba(74, 222, 128, 0.3);
}
.root :global(.prob-market-inline.no) {
color: #fb7185;
background: rgba(251, 113, 133, 0.12);
border: 1px solid rgba(251, 113, 133, 0.26);
}
/* ── Model Bars ── */
.root :global(.model-bars) {
display: flex;
@@ -1386,6 +1414,41 @@
color: var(--text-primary);
margin: 0;
}
.root :global(.future-modal-title-with-actions) {
display: flex;
align-items: center;
gap: 12px;
}
.root :global(.future-refresh-btn) {
background: transparent;
border: none;
cursor: pointer;
color: var(--text-muted);
display: flex;
align-items: center;
justify-content: center;
padding: 6px;
border-radius: 6px;
transition: all 0.2s ease;
}
.root :global(.future-refresh-btn:hover) {
color: var(--accent-cyan);
background: rgba(34, 211, 238, 0.1);
}
.root :global(.future-refresh-btn.spinning svg) {
animation: spin 1s linear infinite;
color: var(--accent-cyan);
}
@keyframes spin {
100% {
transform: rotate(360deg);
}
}
.root :global(.modal-close) {
background: none;
border: none;
@@ -1435,6 +1498,14 @@
color: var(--text-primary);
}
.root :global(.h-stat-card .h-stat-note) {
display: block;
margin-top: 6px;
font-size: 11px;
color: var(--text-muted);
line-height: 1.35;
}
.root :global(.history-chart-wrapper) {
position: relative;
height: 300px;
@@ -1551,6 +1622,301 @@
padding-right: 14px;
}
.root :global(.future-v2-layout) {
display: grid;
grid-template-columns: 360px minmax(0, 1fr);
gap: 14px;
align-items: start;
}
.root :global(.future-v2-left) {
display: grid;
gap: 12px;
}
.root :global(.future-v2-right) {
display: grid;
gap: 14px;
}
.root :global(.future-v2-card) {
background: rgba(255, 255, 255, 0.02);
border: 1px solid var(--border-subtle);
border-radius: 14px;
padding: 14px;
}
.root :global(.future-v2-hero-card) {
background: linear-gradient(
180deg,
rgba(99, 102, 241, 0.12) 0%,
rgba(255, 255, 255, 0.02) 100%
);
}
.root :global(.future-v2-hero-title) {
margin: 0;
font-size: 18px;
font-weight: 700;
color: var(--text-primary);
letter-spacing: -0.01em;
}
.root :global(.future-v2-hero-main) {
display: flex;
align-items: center;
gap: 14px;
margin-top: 14px;
}
.root :global(.future-v2-hero-temp) {
font-size: 56px;
font-weight: 800;
letter-spacing: -0.04em;
line-height: 1;
color: #f8fafc;
text-shadow: 0 10px 30px rgba(34, 211, 238, 0.14);
}
.root :global(.future-v2-hero-divider) {
width: 1px;
height: 56px;
background: rgba(255, 255, 255, 0.12);
}
.root :global(.future-v2-hero-weather) {
display: grid;
gap: 4px;
font-size: 15px;
color: var(--text-secondary);
}
.root :global(.future-v2-hero-icon) {
display: inline-flex;
align-items: center;
line-height: 1;
}
.root :global(.future-v2-hero-obs) {
margin-top: 10px;
color: var(--text-secondary);
font-size: 26px;
font-weight: 500;
font-variant-numeric: tabular-nums;
}
.root :global(.future-v2-mini-grid) {
margin-top: 14px;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
}
.root :global(.future-v2-mini-grid.future-v2-mini-grid-tight) {
margin-top: 8px;
}
.root :global(.future-v2-mini-item) {
border-radius: 10px;
border: 1px solid var(--border-subtle);
background: rgba(255, 255, 255, 0.025);
padding: 10px;
display: grid;
gap: 4px;
}
.root :global(.future-v2-mini-item span) {
color: var(--text-muted);
font-size: 11px;
}
.root :global(.future-v2-mini-item strong) {
color: var(--text-primary);
font-size: 23px;
line-height: 1.15;
font-weight: 700;
}
.root :global(.future-v2-card-title) {
margin: 0;
color: var(--text-primary);
font-size: 13px;
font-weight: 700;
letter-spacing: 0.02em;
}
.root :global(.future-v2-market-v3) {
margin-top: 16px;
display: flex;
flex-direction: column;
gap: 16px;
position: relative;
}
.root :global(.market-layer-loading-overlay) {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(15, 23, 42, 0.6);
backdrop-filter: blur(2px);
z-index: 10;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border-radius: 8px;
color: var(--accent-cyan);
font-size: 13px;
font-weight: 500;
}
.root :global(.market-sub-title) {
color: var(--text-secondary);
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 8px;
font-weight: 600;
}
.root :global(.market-layer-target) {
background: rgba(34, 211, 238, 0.04);
border: 1px solid rgba(34, 211, 238, 0.15);
border-radius: 8px;
padding: 12px;
}
.root :global(.market-target-header) {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
font-size: 13px;
color: var(--text-secondary);
}
.root :global(.market-target-bucket) {
font-size: 16px;
color: var(--text-primary);
font-weight: 700;
}
.root :global(.market-edge-box) {
background: rgba(15, 23, 42, 0.4);
border-radius: 6px;
padding: 10px;
}
.root :global(.market-edge-header) {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
font-size: 12px;
color: var(--text-primary);
font-weight: 600;
}
.root :global(.market-edge-val) {
font-size: 15px;
font-weight: 700;
}
.root :global(.market-edge-val.positive) {
color: var(--accent-green);
}
.root :global(.market-edge-val.negative) {
color: var(--text-secondary);
}
.root :global(.market-edge-compare) {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
border-top: 1px solid rgba(255, 255, 255, 0.06);
padding-top: 8px;
}
.root :global(.edge-stat) {
display: flex;
flex-direction: column;
gap: 2px;
}
.root :global(.edge-label) {
font-size: 10px;
color: var(--text-muted);
}
.root :global(.edge-value) {
font-size: 13px;
color: var(--text-secondary);
font-weight: 600;
}
.root :global(.market-layer-book),
.root :global(.market-layer-context) {
padding: 0 4px;
}
.root :global(.market-book-row),
.root :global(.market-context-row) {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 13px;
padding: 6px 0;
border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}
.root :global(.market-book-row:last-child),
.root :global(.market-context-row:last-child) {
border-bottom: none;
}
.root :global(.book-label),
.root :global(.market-context-row span) {
color: var(--text-secondary);
}
.root :global(.book-quote strong),
.root :global(.market-context-row strong) {
color: var(--text-primary);
font-weight: 600;
}
.root :global(.book-quote span) {
color: var(--text-muted);
font-size: 11px;
}
.root :global(.book-spread) {
color: var(--text-muted);
font-size: 11px;
}
.root :global(.mt-3) {
margin-top: 12px;
}
.root :global(.future-v2-market-signal) {
margin-top: 10px;
padding: 8px 10px;
border-radius: 10px;
background: rgba(34, 211, 238, 0.08);
border: 1px solid rgba(34, 211, 238, 0.22);
color: var(--accent-cyan);
font-size: 12px;
font-weight: 600;
}
.root :global(.future-v2-main-chart) {
min-height: 340px;
}
.root :global(.future-modal-section) {
background: rgba(255, 255, 255, 0.02);
border: 1px solid var(--border-subtle);
@@ -1660,9 +2026,12 @@
border-radius: 999px;
background: linear-gradient(
90deg,
rgba(245, 158, 11, 0.35),
rgba(255, 255, 255, 0.06) 50%,
rgba(52, 211, 153, 0.35)
rgba(56, 189, 248, 0.4) 0%,
rgba(56, 189, 248, 0.4) 30%,
rgba(255, 255, 255, 0.06) 45%,
rgba(255, 255, 255, 0.06) 55%,
rgba(245, 158, 11, 0.4) 70%,
rgba(245, 158, 11, 0.4) 100%
);
overflow: hidden;
}
@@ -1675,9 +2044,11 @@
width: 14px;
height: 14px;
border-radius: 999px;
background: var(--accent-cyan);
background: var(--text-primary);
transform: translate(-50%, -50%);
box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.14);
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
z-index: 2;
transition: left 0.5s ease;
}
.root :global(.future-front-meta) {
@@ -1699,6 +2070,14 @@
}
@media (max-width: 960px) {
.root :global(.future-v2-layout) {
grid-template-columns: 1fr;
}
.root :global(.future-v2-mini-item strong) {
font-size: 18px;
}
.root :global(.future-modal-grid),
.root :global(.future-trend-grid) {
grid-template-columns: 1fr;
File diff suppressed because it is too large Load Diff
+419 -156
View File
@@ -5,7 +5,12 @@ import clsx from "clsx";
import { useChart } from "@/hooks/useChart";
import { useCityData, useDashboardStore } from "@/hooks/useDashboardStore";
import { useI18n } from "@/hooks/useI18n";
import { CityDetail } from "@/lib/dashboard-types";
import {
CityDetail,
MarketScan,
MarketTopBucket,
ProbabilityBucket,
} from "@/lib/dashboard-types";
import {
getHeroMetaItems,
getModelView,
@@ -17,7 +22,101 @@ import {
} from "@/lib/dashboard-utils";
function EmptyState({ text }: { text: string }) {
return <div style={{ color: "var(--text-muted)", fontSize: "13px" }}>{text}</div>;
return (
<div style={{ color: "var(--text-muted)", fontSize: "13px" }}>{text}</div>
);
}
function toPercent(value?: number | null) {
const numeric = Number(value);
if (!Number.isFinite(numeric)) return null;
return `${(numeric * 100).toFixed(1)}%`;
}
function toPriceCents(value?: number | null) {
const numeric = Number(value);
if (!Number.isFinite(numeric)) return null;
const normalized = numeric > 1 ? numeric / 100 : numeric;
const cents = normalized * 100;
const rounded = Math.round(cents * 10) / 10;
const text = Number.isInteger(rounded)
? String(rounded.toFixed(0))
: String(rounded);
return `${text}c`;
}
function parseTempFromText(value: unknown) {
const text = String(value || "");
const match = text.match(/(-?\d+(?:\.\d+)?)/);
if (!match) return null;
const numeric = Number(match[1]);
return Number.isFinite(numeric) ? numeric : null;
}
function getBucketTemp(bucket: ProbabilityBucket) {
const byValue = Number(bucket.value);
if (Number.isFinite(byValue)) return byValue;
return parseTempFromText(bucket.label || bucket.bucket || bucket.range);
}
function getMarketBucketTemp(scan?: MarketScan | null) {
if (!scan) return null;
const byBucketValue = Number(scan.temperature_bucket?.value);
if (Number.isFinite(byBucketValue)) return byBucketValue;
const byBucketLabel = parseTempFromText(
scan.temperature_bucket?.label ||
scan.temperature_bucket?.bucket ||
scan.temperature_bucket?.range,
);
if (byBucketLabel != null) return byBucketLabel;
const slug = String(scan.selected_slug || scan.primary_market?.slug || "");
const slugMatch = slug.match(/-(-?\d+(?:\.\d+)?)c(?:$|[^a-z0-9])/i);
if (slugMatch) {
const numeric = Number(slugMatch[1]);
if (Number.isFinite(numeric)) return numeric;
}
return parseTempFromText(scan.primary_market?.question);
}
function getMarketYesPrice(scan?: MarketScan | null) {
const preferred = Number(scan?.market_price);
if (Number.isFinite(preferred)) return preferred;
const implied = Number(scan?.yes_token?.implied_probability);
return Number.isFinite(implied) ? implied : null;
}
function getMarketNoPrice(scan?: MarketScan | null) {
const direct = Number(scan?.no_buy);
if (Number.isFinite(direct)) return direct;
const marketYes = getMarketYesPrice(scan);
if (marketYes != null) return Math.max(0, Math.min(1, 1 - marketYes));
return null;
}
function normalizeMarketProbability(value?: number | null) {
const numeric = Number(value);
if (!Number.isFinite(numeric)) return null;
if (numeric > 1) return Math.max(0, Math.min(1, numeric / 100));
return Math.max(0, Math.min(1, numeric));
}
function getMarketTopBuckets(scan?: MarketScan | null) {
const buckets = Array.isArray(scan?.top_buckets) ? scan.top_buckets : [];
if (!buckets.length) return [];
return buckets
.map((item) => ({
...item,
probability: normalizeMarketProbability(item.probability),
}))
.filter(
(item): item is MarketTopBucket & { probability: number } =>
item.probability != null,
);
}
export function HeroSummary() {
@@ -55,7 +154,9 @@ export function HeroSummary() {
</div>
<div className="hero-details">
<div className="hero-item">
<span className="label">{locale === "en-US" ? "Current Obs" : "当前实测"}</span>
<span className="label">
{locale === "en-US" ? "Current Obs" : "当前实测"}
</span>
<span className="value">
{current.temp != null
? `${current.temp}${data.temp_symbol} @${current.obs_time || "--"}`
@@ -73,7 +174,9 @@ export function HeroSummary() {
</span>
</div>
<div className="hero-item">
<span className="label">{locale === "en-US" ? "DEB Forecast" : "DEB 预测"}</span>
<span className="label">
{locale === "en-US" ? "DEB Forecast" : "DEB 预测"}
</span>
<span className="value">
{data.deb?.prediction != null
? `${data.deb.prediction}${data.temp_symbol}`
@@ -95,142 +198,141 @@ export function TemperatureChart() {
const { locale, t } = useI18n();
const chartData = data ? getTemperatureChartData(data, locale) : null;
const canvasRef = useChart(
() => {
if (!data || !chartData) {
return {
data: { datasets: [], labels: [] },
type: "line",
} satisfies ChartConfiguration<"line">;
}
const datasets: NonNullable<ChartConfiguration<"line">["data"]>["datasets"] = [];
if (chartData.datasets.hasMgmHourly) {
datasets.push({
backgroundColor: "rgba(234, 179, 8, 0.05)",
borderColor: "rgba(234, 179, 8, 0.8)",
borderWidth: 2,
data: chartData.datasets.mgmHourlyPoints,
fill: false,
label: locale === "en-US" ? "MGM Forecast" : "MGM 预报",
pointHoverRadius: 6,
pointRadius: 3,
spanGaps: true,
tension: 0.3,
});
} else {
datasets.push({
backgroundColor: "rgba(52, 211, 153, 0.05)",
borderColor: "rgba(52, 211, 153, 0.6)",
borderWidth: 1.5,
data: chartData.datasets.debPast,
fill: true,
label: locale === "en-US" ? "DEB Forecast" : "DEB 预报",
pointHoverRadius: 3,
pointRadius: 0,
tension: 0.3,
});
datasets.push({
borderColor: "rgba(52, 211, 153, 0.35)",
borderDash: [5, 3],
borderWidth: 1.5,
data: chartData.datasets.debFuture,
fill: false,
label: locale === "en-US" ? "DEB Forecast" : "DEB 预报",
pointRadius: 0,
tension: 0.3,
});
}
datasets.push({
backgroundColor: "#22d3ee",
borderColor: "#22d3ee",
borderWidth: 0,
data: chartData.datasets.metarPoints,
fill: false,
label: locale === "en-US" ? "METAR Observation" : "METAR 实测",
order: 0,
pointHoverRadius: 7,
pointRadius: 5,
});
if (chartData.datasets.mgmPoints.some((value) => value != null)) {
datasets.push({
backgroundColor: "#facc15",
borderColor: "#facc15",
borderWidth: 0,
data: chartData.datasets.mgmPoints,
fill: false,
label: locale === "en-US" ? "MGM Observation" : "MGM 实测",
order: -1,
pointHoverRadius: 9,
pointRadius: 7,
showLine: false,
});
}
if (
!chartData.datasets.hasMgmHourly &&
Math.abs(chartData.datasets.offset) > 0.3
) {
datasets.push({
borderColor: "rgba(99, 102, 241, 0.2)",
borderDash: [2, 4],
borderWidth: 1,
data: chartData.datasets.temps,
fill: false,
label: locale === "en-US" ? "OM Raw" : "OM 原始",
pointRadius: 0,
tension: 0.3,
});
}
const canvasRef = useChart(() => {
if (!data || !chartData) {
return {
data: {
datasets,
labels: chartData.times,
},
options: {
interaction: { intersect: false, mode: "index" },
maintainAspectRatio: false,
plugins: {
legend: { display: false },
tooltip: {
backgroundColor: "rgba(15, 23, 42, 0.9)",
borderColor: "rgba(52, 211, 153, 0.3)",
borderWidth: 1,
},
},
responsive: true,
scales: {
x: {
grid: { color: "rgba(255,255,255,0.04)" },
ticks: {
callback: (_value, index) =>
typeof index === "number" && index % 3 === 0
? chartData.times[index]
: "",
color: "#64748b",
maxRotation: 0,
},
},
y: {
grid: { color: "rgba(255,255,255,0.04)" },
max: chartData.max,
min: chartData.min,
ticks: {
callback: (value) => `${value}${data.temp_symbol || "°C"}`,
color: "#64748b",
},
},
},
},
data: { datasets: [], labels: [] },
type: "line",
} satisfies ChartConfiguration<"line">;
},
[data, chartData, locale],
);
}
const datasets: NonNullable<
ChartConfiguration<"line">["data"]
>["datasets"] = [];
if (chartData.datasets.hasMgmHourly) {
datasets.push({
backgroundColor: "rgba(234, 179, 8, 0.05)",
borderColor: "rgba(234, 179, 8, 0.8)",
borderWidth: 2,
data: chartData.datasets.mgmHourlyPoints,
fill: false,
label: locale === "en-US" ? "MGM Forecast" : "MGM 预报",
pointHoverRadius: 6,
pointRadius: 3,
spanGaps: true,
tension: 0.3,
});
} else {
datasets.push({
backgroundColor: "rgba(52, 211, 153, 0.05)",
borderColor: "rgba(52, 211, 153, 0.6)",
borderWidth: 1.5,
data: chartData.datasets.debPast,
fill: true,
label: locale === "en-US" ? "DEB Forecast" : "DEB 预报",
pointHoverRadius: 3,
pointRadius: 0,
tension: 0.3,
});
datasets.push({
borderColor: "rgba(52, 211, 153, 0.35)",
borderDash: [5, 3],
borderWidth: 1.5,
data: chartData.datasets.debFuture,
fill: false,
label: locale === "en-US" ? "DEB Forecast" : "DEB 预报",
pointRadius: 0,
tension: 0.3,
});
}
datasets.push({
backgroundColor: "#22d3ee",
borderColor: "#22d3ee",
borderWidth: 0,
data: chartData.datasets.metarPoints,
fill: false,
label: locale === "en-US" ? "METAR Observation" : "METAR 实测",
order: 0,
pointHoverRadius: 7,
pointRadius: 5,
});
if (chartData.datasets.mgmPoints.some((value) => value != null)) {
datasets.push({
backgroundColor: "#facc15",
borderColor: "#facc15",
borderWidth: 0,
data: chartData.datasets.mgmPoints,
fill: false,
label: locale === "en-US" ? "MGM Observation" : "MGM 实测",
order: -1,
pointHoverRadius: 9,
pointRadius: 7,
showLine: false,
});
}
if (
!chartData.datasets.hasMgmHourly &&
Math.abs(chartData.datasets.offset) > 0.3
) {
datasets.push({
borderColor: "rgba(99, 102, 241, 0.2)",
borderDash: [2, 4],
borderWidth: 1,
data: chartData.datasets.temps,
fill: false,
label: locale === "en-US" ? "OM Raw" : "OM 原始",
pointRadius: 0,
tension: 0.3,
});
}
return {
data: {
datasets,
labels: chartData.times,
},
options: {
interaction: { intersect: false, mode: "index" },
maintainAspectRatio: false,
plugins: {
legend: { display: false },
tooltip: {
backgroundColor: "rgba(15, 23, 42, 0.9)",
borderColor: "rgba(52, 211, 153, 0.3)",
borderWidth: 1,
},
},
responsive: true,
scales: {
x: {
grid: { color: "rgba(255,255,255,0.04)" },
ticks: {
callback: (_value, index) =>
typeof index === "number" && index % 3 === 0
? chartData.times[index]
: "",
color: "#64748b",
maxRotation: 0,
},
},
y: {
grid: { color: "rgba(255,255,255,0.04)" },
max: chartData.max,
min: chartData.min,
ticks: {
callback: (value) => `${value}${data.temp_symbol || "°C"}`,
color: "#64748b",
},
},
},
},
type: "line",
} satisfies ChartConfiguration<"line">;
}, [data, chartData, locale]);
return (
<section className="chart-section">
@@ -238,7 +340,9 @@ export function TemperatureChart() {
<div className="chart-wrapper">
<canvas ref={canvasRef} />
</div>
<div className="chart-legend">{chartData?.legendText || t("section.chartEmpty")}</div>
<div className="chart-legend">
{chartData?.legendText || t("section.chartEmpty")}
</div>
</section>
);
}
@@ -247,13 +351,28 @@ export function ProbabilityDistribution({
detail,
hideTitle = false,
targetDate,
marketScan,
}: {
detail: CityDetail;
hideTitle?: boolean;
targetDate?: string | null;
marketScan?: MarketScan | null;
}) {
const { t } = useI18n();
const { locale, t } = useI18n();
const view = getProbabilityView(detail, targetDate);
const marketBucketTemp = getMarketBucketTemp(marketScan);
const marketYesPrice = getMarketYesPrice(marketScan);
const marketNoPrice = getMarketNoPrice(marketScan);
const marketYesText = toPercent(marketYesPrice);
const marketNoText = toPercent(marketNoPrice);
const isToday = !targetDate || targetDate === detail.local_date;
const marketTopBuckets = isToday ? getMarketTopBuckets(marketScan) : [];
const sortedMarketTopBuckets = [...marketTopBuckets]
.sort((a, b) => Number(b.probability || 0) - Number(a.probability || 0))
.slice(0, 4);
const useMarketTopBuckets =
marketScan?.available && sortedMarketTopBuckets.length > 0;
const topMarketBucketText = toPercent(sortedMarketTopBuckets[0]?.probability);
return (
<section className="prob-section">
@@ -261,7 +380,11 @@ export function ProbabilityDistribution({
<div className="prob-bars">
{view.mu != null && (
<div
style={{ color: "var(--text-muted)", fontSize: "11px", marginBottom: "6px" }}
style={{
color: "var(--text-muted)",
fontSize: "11px",
marginBottom: "6px",
}}
>
{t("section.mu", {
unit: detail.temp_symbol || "",
@@ -269,16 +392,62 @@ export function ProbabilityDistribution({
})}
</div>
)}
{view.probabilities.length === 0 ? (
<EmptyState text={t("section.noProb")} />
) : (
view.probabilities.slice(0, 6).map((bucket, index) => {
const probability = Math.round(Number(bucket.probability || 0) * 100);
{marketScan?.available && (topMarketBucketText || marketYesText) && (
<div
style={{
color: "var(--text-secondary)",
fontSize: "11px",
marginBottom: "6px",
}}
>
{useMarketTopBuckets
? locale === "en-US"
? `Market top-4 buckets (top): ${topMarketBucketText}`
: `市场概率(前4温度桶):最高 ${topMarketBucketText}`
: locale === "en-US"
? `Market probability (this bucket): ${marketYesText}`
: `市场概率(该温度桶): ${marketYesText}`}
</div>
)}
{useMarketTopBuckets ? (
sortedMarketTopBuckets.map((bucket, index) => {
const probability = Math.round(
Number(bucket.probability || 0) * 100,
);
let bucketLabel =
bucket.label ||
(bucket.value != null
? `${bucket.value}${detail.temp_symbol}`
: `${bucket.temp ?? "--"}${detail.temp_symbol}`);
if (bucketLabel) {
let str = String(bucketLabel).toUpperCase().replace(/\s+/g, "");
str = str.replace(/°?C($|\+|-)/g, "℃$1");
if (!str.includes("℃") && /[0-9]/.test(str)) {
str += "℃";
}
bucketLabel = str;
}
const buyYesText = toPriceCents(
bucket.yes_buy ?? bucket.market_price ?? bucket.probability,
);
const buyNoText = toPriceCents(bucket.no_buy);
const marketTag = buyYesText
? locale === "en-US"
? `Buy Yes: ${buyYesText}`
: `买 Yes: ${buyYesText}`
: buyNoText
? locale === "en-US"
? `Buy No: ${buyNoText}`
: `买 No: ${buyNoText}`
: null;
return (
<div key={`${bucket.label || bucket.value || index}`} className="prob-row">
<div className="prob-label">
{bucket.label || `${bucket.value}${detail.temp_symbol}`}
</div>
<div
key={`${bucket.slug || bucket.label || index}`}
className="prob-row"
>
<div className="prob-label">{bucketLabel}</div>
<div className="prob-bar-track">
<div
className={clsx("prob-bar-fill", `rank-${index}`)}
@@ -287,6 +456,82 @@ export function ProbabilityDistribution({
{probability}%
</div>
</div>
{marketTag && (
<div className={clsx("prob-market-inline", "yes")}>
{marketTag}
</div>
)}
</div>
);
})
) : view.probabilities.length === 0 ? (
<EmptyState text={t("section.noProb")} />
) : (
view.probabilities.slice(0, 6).map((bucket, index) => {
const probability = Math.round(
Number(bucket.probability || 0) * 100,
);
const bucketTemp = getBucketTemp(bucket);
const isMarketBucket =
marketYesText != null &&
marketBucketTemp != null &&
bucketTemp != null &&
Math.abs(bucketTemp - marketBucketTemp) < 0.26;
const marketTag = isMarketBucket
? locale === "en-US"
? `Buy Yes: ${marketYesText || "--"}`
: `买 Yes: ${marketYesText || "--"}`
: marketNoText
? locale === "en-US"
? `Buy No: ${marketNoText}`
: `买 No: ${marketNoText}`
: null;
const yesPriceText = toPriceCents(marketYesPrice);
const noPriceText = toPriceCents(marketNoPrice);
const marketTagFinal = isMarketBucket
? locale === "en-US"
? `Buy Yes: ${yesPriceText || "--"}`
: `买 Yes: ${yesPriceText || "--"}`
: noPriceText
? locale === "en-US"
? `Buy No: ${noPriceText}`
: `买 No: ${noPriceText}`
: marketTag;
let bucketLabel =
bucket.label || `${bucket.value}${detail.temp_symbol}`;
if (bucketLabel) {
let str = String(bucketLabel).toUpperCase().replace(/\s+/g, "");
str = str.replace(/°?C($|\+|-)/g, "℃$1");
if (!str.includes("℃") && /[0-9]/.test(str)) {
str += "℃";
}
bucketLabel = str;
}
return (
<div
key={`${bucket.label || bucket.value || index}`}
className="prob-row"
>
<div className="prob-label">{bucketLabel}</div>
<div className="prob-bar-track">
<div
className={clsx("prob-bar-fill", `rank-${index}`)}
style={{ width: `${Math.max(probability, 8)}%` }}
>
{probability}%
</div>
</div>
{marketTagFinal && (
<div
className={clsx(
"prob-market-inline",
isMarketBucket ? "yes" : "no",
)}
>
{marketTagFinal}
</div>
)}
</div>
);
})
@@ -313,8 +558,12 @@ export function ModelForecast({
const numericValues = modelEntries.map(([, value]) => Number(value));
const comparisonValues =
view.deb != null ? [...numericValues, Number(view.deb)] : numericValues;
const minValue = comparisonValues.length ? Math.min(...comparisonValues) - 1 : 0;
const maxValue = comparisonValues.length ? Math.max(...comparisonValues) + 1 : 1;
const minValue = comparisonValues.length
? Math.min(...comparisonValues) - 1
: 0;
const maxValue = comparisonValues.length
? Math.max(...comparisonValues) + 1
: 1;
const range = Math.max(maxValue - minValue, 1);
return (
@@ -341,12 +590,18 @@ export function ModelForecast({
{name}
</div>
<div className="model-bar-track">
<div className="model-bar-fill" style={{ width: `${width}%` }}>
<div
className="model-bar-fill"
style={{ width: `${width}%` }}
>
{numeric}
{detail.temp_symbol}
</div>
{debLine != null && (
<div className="model-deb-line" style={{ left: `${debLine}%` }} />
<div
className="model-deb-line"
style={{ left: `${debLine}%` }}
/>
)}
</div>
</div>
@@ -410,13 +665,19 @@ export function ForecastTable() {
<button
key={day.date}
type="button"
className={clsx("forecast-day", isToday && "today", isSelected && "selected")}
className={clsx(
"forecast-day",
isToday && "today",
isSelected && "selected",
)}
onClick={() => {
store.openFutureModal(day.date);
}}
>
<div className="f-date">
{isToday ? t("forecast.today") : day.date.substring(5).replace("-", "/")}
{isToday
? t("forecast.today")
: day.date.substring(5).replace("-", "/")}
</div>
<div className="f-temp">
{day.max_temp}
@@ -471,7 +732,9 @@ export function RiskInfo() {
<h3>{t("section.risk")}</h3>
<div className="risk-info">
{!risk.airport ? (
<span style={{ color: "var(--text-muted)" }}>{t("section.noRiskProfile")}</span>
<span style={{ color: "var(--text-muted)" }}>
{t("section.noRiskProfile")}
</span>
) : (
<>
<div className="risk-row">