{trendChart.legendText ||
@@ -825,10 +893,21 @@ function HomeIntelligencePanel({ snapshots }: { snapshots: CitySnapshot[] }) {
);
}
-function OpportunityStrip({ snapshots }: { snapshots: CitySnapshot[] }) {
+function OpportunityStrip({
+ snapshots,
+ recentCityNames,
+}: {
+ snapshots: CitySnapshot[];
+ recentCityNames: string[];
+}) {
const store = useDashboardStore();
const { locale } = useI18n();
- const items = snapshots.slice(0, 4);
+ const items = recentCityNames
+ .map((cityName) =>
+ snapshots.find((snapshot) => snapshot.city.name === cityName) || null,
+ )
+ .filter((snapshot): snapshot is CitySnapshot => snapshot != null)
+ .slice(0, 4);
if (!items.length) return null;
@@ -838,9 +917,9 @@ function OpportunityStrip({ snapshots }: { snapshots: CitySnapshot[] }) {
aria-label={locale === "en-US" ? "Opportunity strip" : "机会条"}
>
- {locale === "en-US" ? "Today focus" : "今日焦点"}
+ {locale === "en-US" ? "Recently opened" : "最近打开"}
- {locale === "en-US" ? "Cities worth opening first" : "优先打开的城市"}
+ {locale === "en-US" ? "Recently opened cities" : "最近打开的城市"}
@@ -884,6 +963,7 @@ function DashboardScreen() {
const { t } = useI18n();
const didAutoFocusRef = useRef(false);
const preloadedOpportunityRef = useRef
>(new Set());
+ const [recentCityNames, setRecentCityNames] = useState([]);
const activeSummary = store.selectedCity
? store.citySummariesByName[store.selectedCity] || null
: null;
@@ -945,6 +1025,19 @@ function DashboardScreen() {
const showHomepageChrome =
!store.historyState.isOpen && !store.futureModalDate;
+ useEffect(() => {
+ if (typeof window === "undefined") return;
+ try {
+ const raw = window.localStorage.getItem(RECENT_OPENED_CITIES_STORAGE_KEY);
+ if (!raw) return;
+ const parsed = JSON.parse(raw);
+ if (!Array.isArray(parsed)) return;
+ setRecentCityNames(
+ parsed.map((item) => String(item || "").trim()).filter(Boolean).slice(0, 8),
+ );
+ } catch {}
+ }, []);
+
useEffect(() => {
if (didAutoFocusRef.current) return;
if (!showHomepageChrome) return;
@@ -968,6 +1061,26 @@ function DashboardScreen() {
});
}, [homepageSnapshots, showHomepageChrome, store]);
+ useEffect(() => {
+ const selectedCity = store.selectedCity;
+ if (!selectedCity) return;
+ setRecentCityNames((current) => {
+ const next = [
+ selectedCity,
+ ...current.filter((name) => name !== selectedCity),
+ ].slice(0, 8);
+ if (typeof window !== "undefined") {
+ try {
+ window.localStorage.setItem(
+ RECENT_OPENED_CITIES_STORAGE_KEY,
+ JSON.stringify(next),
+ );
+ } catch {}
+ }
+ return next;
+ });
+ }, [store.selectedCity]);
+
return (
-
+ snapshot.city.name)
+ }
+ />
>
) : null}
{showCitySyncToast ? (