feat: implement AI city forecast streaming hook and utility functions for scan terminal

This commit is contained in:
2569718930@qq.com
2026-04-27 00:54:24 +08:00
parent 97719a7ff0
commit 7e66b026b9
2 changed files with 3 additions and 10 deletions
@@ -281,14 +281,7 @@ export function pickMarketBucketForWeatherCenter(
}
if (roundedMatch) return roundedMatch;
if (!nearest) return isReasonableFallback(selectedBucket) ? selectedBucket : null;
const comparable = normalizeMarketComparableTemp(expectedHigh, tempSymbol, nearest);
const unit = String(nearest.unit || "").toUpperCase();
const maxReasonableDelta = unit === "F" ? 16 : 8;
if (
comparable != null &&
Number.isFinite(nearestDelta) &&
nearestDelta <= maxReasonableDelta
) {
if (Number.isFinite(nearestDelta) && isReasonableFallback(nearest)) {
return nearest;
}
return isReasonableFallback(selectedBucket) ? selectedBucket : null;
@@ -16,7 +16,7 @@ import { normalizeCityKey } from "./decision-utils";
const AI_CITY_FORECAST_CACHE_PREFIX = "polyWeather_aiCityForecast_v3";
const AI_CITY_FORECAST_CACHE_TTL_MS = 60 * 60 * 1000;
const CITY_MARKET_SCAN_CACHE_PREFIX = "polyWeather_cityMarketScan_v2";
const CITY_MARKET_SCAN_CACHE_PREFIX = "polyWeather_cityMarketScan_v3";
const CITY_MARKET_SCAN_CACHE_TTL_MS = 10 * 60 * 1000;
const pendingAiCityForecastRequests = new Map<
string,
@@ -504,7 +504,7 @@ export function useCityMarketScan({
const cacheKey = buildStorageKey(CITY_MARKET_SCAN_CACHE_PREFIX, [
normalizeCityKey(detailCityName),
detail.local_date || "",
"lite",
"full",
]);
let cancelled = false;
if (detail.market_scan) {