fix: update theme import and algorithm handling in App component
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { customValueTypeMap } from '@components';
|
||||
import { ConfigProvider, App as TocoApp, theme, ProConfigProvider } from '@toco-design/components';
|
||||
import { ConfigProvider, App as TocoApp, theme as antTheme, ProConfigProvider } from '@toco-design/components';
|
||||
import { Router } from '@remix-run/router';
|
||||
import enUS from 'antd/locale/en_US';
|
||||
import zhCN from 'antd/locale/zh_CN';
|
||||
@@ -13,7 +13,7 @@ import * as langs from './langs';
|
||||
import { store } from './store';
|
||||
import appTheme from './theme';
|
||||
|
||||
const { darkAlgorithm } = theme;
|
||||
const { darkAlgorithm } = antTheme;
|
||||
|
||||
const AppInternal: React.FC<{ router: Router }> = (props) => {
|
||||
const { router } = props;
|
||||
@@ -32,8 +32,19 @@ const AppInternal: React.FC<{ router: Router }> = (props) => {
|
||||
};
|
||||
|
||||
const themeConfig = useMemo(() => {
|
||||
const algorithmArr = Array.isArray(appTheme.algorithm) ? appTheme.algorithm : appTheme.algorithm ? [appTheme.algorithm] : [];
|
||||
if (theme === Theme.DARK) {
|
||||
if (!algorithmArr.includes(antTheme.darkAlgorithm)) {
|
||||
algorithmArr.push(antTheme.darkAlgorithm);
|
||||
}
|
||||
} else {
|
||||
const index = algorithmArr.indexOf(antTheme.darkAlgorithm);
|
||||
if (index > -1) {
|
||||
algorithmArr.splice(index, 1);
|
||||
}
|
||||
}
|
||||
return {
|
||||
algorithm: (theme === Theme.DARK ? [darkAlgorithm] : []).concat(appTheme.algorithm ?? []),
|
||||
algorithm: algorithmArr,
|
||||
cssVar: appTheme.cssVar ?? true,
|
||||
token: primaryColor
|
||||
? {
|
||||
|
||||
Reference in New Issue
Block a user