Skip to content

Commit

Permalink
feat: ai加上国际化的Provider (#1385)
Browse files Browse the repository at this point in the history
![image](https://github.com/user-attachments/assets/61f9a74d-5762-4108-b61b-be05f1c76741)
## 回归测试ai时发现没法打开shell页面,报错如图,缺少Provider
  • Loading branch information
OYX-1 authored Aug 6, 2024
1 parent 66a96ba commit 7ee40a1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-lemons-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scow/ai": patch
---

ai 加上国际化的 Provider
76 changes: 46 additions & 30 deletions apps/ai/src/app/clientLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import { usePathname } from "next/navigation";
import { ErrorBoundary } from "src/components/ErrorBoundary";
import { Loading } from "src/components/Loading";
import { TopProgressBar } from "src/components/TopProgressBar";
import { Provider } from "src/i18n";
import en from "src/i18n/en";
import zh_cn from "src/i18n/zh_cn";
import { AntdConfigProvider } from "src/layouts/AntdConfigProvider";
import { DarkModeCookie, DarkModeProvider } from "src/layouts/darkMode";
import { RootErrorContent } from "src/layouts/error/RootErrorContent";
Expand All @@ -28,6 +31,11 @@ import { trpc } from "src/utils/trpc";

import { UiConfigContext } from "./uiContext";

const languagesMap = {
"zh_cn": zh_cn,
"en": en,
};

export function ClientLayout(props: {
children: React.ReactNode,
initialDark?: DarkModeCookie,
Expand All @@ -49,36 +57,44 @@ export function ClientLayout(props: {
?? primaryColor?.defaultColor ?? uiConfig.defaultPrimaryColor;

return (
<StyleProvider hashPriority="high" transformers={[legacyLogicalPropertiesTransformer]}>
<StyledComponentsRegistry>
<AntdStyleRegistry>
<body>
{
useConfig.isLoading ?
<Loading />
: (
<DarkModeProvider initial={props.initialDark}>
<AntdConfigProvider color={color}>
<GlobalStyle />
<TopProgressBar />
<ErrorBoundary Component={RootErrorContent} pathname={pathname ?? ""}>
<UiConfigContext.Provider
value={{
hostname,
uiConfig,
}}
>
{props.children}
</UiConfigContext.Provider>
</ErrorBoundary>
</AntdConfigProvider>
</DarkModeProvider>
)
}
<Provider initialLanguage={{
// ai还未开发国际化,先直接写zh_cn
id: "zh_cn",
definitions: languagesMap.zh_cn,
}}
>
<StyleProvider hashPriority="high" transformers={[legacyLogicalPropertiesTransformer]}>
<StyledComponentsRegistry>
<AntdStyleRegistry>
<body>
{
useConfig.isLoading ?
<Loading />
: (
<DarkModeProvider initial={props.initialDark}>
<AntdConfigProvider color={color}>
<GlobalStyle />
<TopProgressBar />
<ErrorBoundary Component={RootErrorContent} pathname={pathname ?? ""}>
<UiConfigContext.Provider
value={{
hostname,
uiConfig,
}}
>
{props.children}
</UiConfigContext.Provider>
</ErrorBoundary>
</AntdConfigProvider>
</DarkModeProvider>
)
}

</body>
</AntdStyleRegistry>
</StyledComponentsRegistry>
</StyleProvider>
</Provider>

</body>
</AntdStyleRegistry>
</StyledComponentsRegistry>
</StyleProvider>
);
}

0 comments on commit 7ee40a1

Please sign in to comment.