From 8653187a04eae6e1afb05be80e40d4b1189820ef Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 17 Apr 2025 13:34:05 +0800 Subject: [PATCH] . --- components/ui/language-switcher.tsx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/components/ui/language-switcher.tsx b/components/ui/language-switcher.tsx index 295c096..b841a95 100644 --- a/components/ui/language-switcher.tsx +++ b/components/ui/language-switcher.tsx @@ -39,13 +39,19 @@ export function LanguageSwitcher() { const newPath = '/' + segments.join('/') - startTransition(() => { - if (pathname !== newPath) { - router.push(newPath) - } else { - router.refresh() - } - }) + + // 🔥 核心修复:延迟 router.push,确保 cookie 写入完成再跳转 + setTimeout(() => { + startTransition(() => { + if (pathname !== newPath) { + router.push(newPath) + } else { + router.refresh() + } + }) + }, 0) + + } return (