fix recipe ig post can't load problem

This commit is contained in:
2025-11-02 21:01:52 +08:00
parent 2f4e90f0c4
commit 144a362a16
4 changed files with 145 additions and 26 deletions

View File

@@ -82,19 +82,29 @@ function Header({ showMenu = false }: HeaderProps) {
return;
}
router.navigate({
to: '/',
hash: targetId,
replace: location.pathname === '/',
});
if (typeof window !== 'undefined') {
window.sessionStorage.setItem('pendingScrollSection', targetId);
window.dispatchEvent(new CustomEvent('pending-scroll-section'));
}
if (!isOnMainPage) {
router.navigate({ to: '/' });
}
};
const handleMenuClick = (itemId: string) => {
if (itemId === 'recipes') {
router.navigate({
to: '/recipe',
replace: location.pathname === '/recipe',
});
const isOnRecipePage = location.pathname === '/recipe';
if (isOnRecipePage) {
// Already on recipe page, just close drawer
setIsDrawerOpen(false);
return;
}
// Navigate from main page - force reload to ensure Instagram embeds work
window.location.href = '/recipe';
return;
} else {
scrollToSection(itemId);
}