diff --git a/chatdesk-ui/app/[locale]/[workspaceid]/layout.tsx b/chatdesk-ui/app/[locale]/[workspaceid]/layout.tsx index 1679786..b61ed4e 100644 --- a/chatdesk-ui/app/[locale]/[workspaceid]/layout.tsx +++ b/chatdesk-ui/app/[locale]/[workspaceid]/layout.tsx @@ -34,8 +34,8 @@ export default function WorkspaceLayout({ children }: WorkspaceLayoutProps) { const pathname = usePathname() // 获取当前路径 // 提取当前路径中的 locale 部分 - //const locale = pathname.split("/")[1] || "en" - const match = pathname.match(/^\/([a-z]{2})(\/|$)/) + //const match = pathname.match(/^\/([a-z]{2})(\/|$)/) + const match = pathname ? pathname.match(/^\/([a-z]{2})(\/|$)/) : null; const locale = match ? match[1] : "en"