diff --git a/packages/design/src/config-provider/__tests__/theme.test.tsx b/packages/design/src/config-provider/__tests__/theme.test.tsx
index 2e9068bfb..444ac0916 100644
--- a/packages/design/src/config-provider/__tests__/theme.test.tsx
+++ b/packages/design/src/config-provider/__tests__/theme.test.tsx
@@ -109,4 +109,37 @@ describe('ConfigProvider theme', () => {
);
});
+
+ it('isAliyun', () => {
+ const Child1 = () => {
+ const { token } = useToken();
+ expect(token.colorPrimary).toBe(defaultTheme.token.colorPrimary);
+ return
;
+ };
+ const Child2 = () => {
+ const { token } = useToken();
+ expect(token.colorPrimary).toBe('#0064c8');
+ return ;
+ };
+ const Child3 = () => {
+ const { token } = useToken();
+ expect(token.colorPrimary).toBe('#0064c8');
+ return ;
+ };
+ render(
+
+
+
+
+
+
+
+
+
+ );
+ });
});
diff --git a/packages/design/src/config-provider/index.tsx b/packages/design/src/config-provider/index.tsx
index b715fd86c..1a897447a 100644
--- a/packages/design/src/config-provider/index.tsx
+++ b/packages/design/src/config-provider/index.tsx
@@ -108,14 +108,14 @@ const ConfigProvider: ConfigProviderType = ({
const parentExtendedContext =
React.useContext(ExtendedConfigContext);
const { isDark, isAliyun } = merge({}, parentContext.theme, theme);
- const currentTheme = isAliyun
- ? aliyunTheme
- : isDark
- ? darkTheme
- : parentContext.theme
- ? {}
- : defaultTheme;
- const mergedTheme = merge({}, parentContext.theme, currentTheme, theme);
+ const customTheme = isAliyun ? aliyunTheme : isDark ? darkTheme : undefined;
+ const mergedTheme = merge(
+ {},
+ customTheme ? {} : defaultTheme,
+ parentContext.theme,
+ customTheme,
+ theme
+ );
const { token } = themeConfig.useToken();
const fontFamily = mergedTheme.token?.fontFamily || token.fontFamily;