Skip to content

Commit

Permalink
fix(components): unuse theme import
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Sep 6, 2022
1 parent e8ea80c commit bcac384
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions packages/provider/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ts-ignore
import { ConfigProvider as AntdConfigProvider, theme as antdTheme } from 'antd';
import * as antd from 'antd';
import zh_CN from 'antd/es/locale/zh_CN';
import React, { useContext, useEffect } from 'react';
import { SWRConfig, useSWRConfig } from 'swr';
Expand Down Expand Up @@ -27,7 +27,7 @@ import viVN from './locale/vi_VN';
import zhCN from './locale/zh_CN';
import zhTW from './locale/zh_TW';

const { useToken } = antdTheme || {
const { useToken } = antd.theme || {
useToken: () => {
return {
hashId: '',
Expand Down Expand Up @@ -270,6 +270,8 @@ const CacheClean = () => {
return null;
};

const AntdConfigProvider = antd.ConfigProvider;

/**
* 如果没有配置 locale,这里组件会根据 antd 的 key 来自动选择
*
Expand Down
12 changes: 9 additions & 3 deletions packages/utils/src/useStyle/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { CSSInterpolation, CSSObject } from '@ant-design/cssinjs';
import { useStyleRegister } from '@ant-design/cssinjs';
import { TinyColor } from '@ctrl/tinycolor';
// @ts-ignore
import { ConfigProvider, theme as antdTheme } from 'antd';

import * as antd from 'antd';

import type React from 'react';
import { useContext } from 'react';
Expand Down Expand Up @@ -37,7 +37,11 @@ export type GenerateStyle<
/**
* 如果 antd 里面没有,就用我 mock 的,这样 antd@4 和 antd@5 可以兼容
*/
const { useToken } = { ...batToken, ...antdTheme } as unknown as typeof batToken;
const { useToken } = {
...batToken,
// @ts-ignore
...antd.antdTheme,
} as unknown as typeof batToken;

export { useToken };

Expand Down Expand Up @@ -88,6 +92,8 @@ export const operationUnit = (token: ProAliasToken): CSSObject => ({
},
});

const { ConfigProvider } = antd;

/**
* 封装了一下 antd 的 useStyle,支持了一下antd@4
* @param componentName {string} 组件的名字
Expand Down

0 comments on commit bcac384

Please sign in to comment.