diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index 22f9133..3bb4c30 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -86,7 +86,7 @@ export default async function RootLayout({ const { t, resources } = await initTranslations(locale, i18nNamespaces) - console.log(".layout.tsx..............locale: ", {locale}); + console.log("layout.tsx..............locale: ", {locale}); return ( diff --git a/components/utility/global-state.tsx b/components/utility/global-state.tsx index 126babf..369ab7e 100644 --- a/components/utility/global-state.tsx +++ b/components/utility/global-state.tsx @@ -3,6 +3,8 @@ "use client" import { ChatbotUIContext } from "@/context/context" +import { usePathname } from "next/navigation" + import { getProfileByUserId } from "@/db/profile" import { getWorkspaceImageFromStorage } from "@/db/storage/workspace-images" import { getWorkspacesByUserId } from "@/db/workspaces" @@ -162,7 +164,11 @@ export const GlobalState: FC = ({ children }) => { setProfile(profile) if (!profile.has_onboarded) { - return router.push("/setup") + // 提取当前路径中的 locale 部分 + const locale = pathname.split("/")[1] || "en" // 获取路径中的 locale 部分,如果没有则默认为 "en" + + // 强制跳转到带有 locale 的 setup 页面 + return router.push(`/${locale}/setup`) } const workspaces = await getWorkspacesByUserId(user.id)