diff --git a/packages/client/src/antd-config-provider/demos/demo1.tsx b/packages/client/src/antd-config-provider/demos/demo1.tsx new file mode 100644 index 000000000..dd79a424e --- /dev/null +++ b/packages/client/src/antd-config-provider/demos/demo1.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Table } from 'antd'; +import { i18n, compose, APIClient, APIClientProvider, AntdConfigProvider } from '@nocobase/client'; +import MockAdapter from 'axios-mock-adapter'; +import { I18nextProvider } from 'react-i18next'; + +const apiClient = new APIClient({ + baseURL: `${location.protocol}//${location.host}/api/`, +}); + +const mock = new MockAdapter(apiClient.axios); + +mock.onGet('/app:getLang').reply(200, { + data: { lang: 'zh-CN' }, +}); + +const providers = [ + [APIClientProvider, { apiClient }], + [I18nextProvider, { i18n }], + [AntdConfigProvider, { remoteLocale: true }], +]; + +export default compose(...providers)(() => { + return
diff --git a/packages/client/src/antd-config-provider/index.tsx b/packages/client/src/antd-config-provider/index.tsx
index 4cb2df6cd..f2ddeec9f 100644
--- a/packages/client/src/antd-config-provider/index.tsx
+++ b/packages/client/src/antd-config-provider/index.tsx
@@ -3,8 +3,31 @@ import { I18nextProvider, useTranslation } from 'react-i18next';
import { ConfigProvider, Spin } from 'antd';
import enUS from 'antd/lib/locale/en_US';
import zhCN from 'antd/lib/locale/zh_CN';
+import { useRequest } from '../api-client';
export function AntdConfigProvider(props) {
+ const { remoteLocale, ...others } = props;
const { i18n } = useTranslation();
- return