Co-authored-by: sealday <sealday@gmail.com> Reviewed-on: daoyoucloud/tachybase#1558
This commit is contained in:
parent
588a02fedc
commit
eff5bc3890
@ -14,8 +14,8 @@ const defaultTheme: ThemeConfig = {
|
||||
|
||||
// UI 配置组件
|
||||
colorSettings: '#2196f3',
|
||||
colorBgSettingsHover: 'rgba(241, 139, 98, 0.06)',
|
||||
colorBorderSettingsHover: 'rgba(241, 139, 98, 0.3)',
|
||||
colorBgSettingsHover: 'rgba(33,150,243, 0.06)',
|
||||
colorBorderSettingsHover: 'rgba(33,150,243, 0.3)',
|
||||
motionUnit: 0.03,
|
||||
motion: !process.env.__E2E__,
|
||||
},
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { createContext, useCallback, useMemo, useRef } from 'react';
|
||||
import React, { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react';
|
||||
|
||||
import { theme as antdTheme, ConfigProvider } from 'antd';
|
||||
import _ from 'lodash';
|
||||
@ -29,11 +29,11 @@ const GlobalThemeContext = createContext<GlobalThemeContextProps>(null);
|
||||
GlobalThemeContext.displayName = 'GlobalThemeContext';
|
||||
|
||||
export const useGlobalTheme = () => {
|
||||
return React.useContext(GlobalThemeContext) || ({ theme: {}, isDarkTheme: false } as GlobalThemeContextProps);
|
||||
return useContext(GlobalThemeContext) || ({ theme: {}, isDarkTheme: false } as GlobalThemeContextProps);
|
||||
};
|
||||
|
||||
export const GlobalThemeProvider = ({ children, theme: themeFromProps }) => {
|
||||
const [theme, setTheme] = React.useState<ThemeConfig>(themeFromProps || defaultTheme);
|
||||
const [theme, setTheme] = useState<ThemeConfig>(themeFromProps || defaultTheme);
|
||||
const currentSettingThemeRef = useRef<ThemeConfig>(null);
|
||||
const currentEditingThemeRef = useRef<ThemeItem>(null);
|
||||
|
||||
@ -82,7 +82,9 @@ export const GlobalThemeProvider = ({ children, theme: themeFromProps }) => {
|
||||
|
||||
return (
|
||||
<GlobalThemeContext.Provider value={value}>
|
||||
<ConfigProvider theme={defaultTheme}>
|
||||
<ConfigProvider theme={theme}>{children}</ConfigProvider>
|
||||
</ConfigProvider>
|
||||
</GlobalThemeContext.Provider>
|
||||
);
|
||||
};
|
||||
|
@ -33,6 +33,5 @@ export interface ThemeConfig extends _ThemeConfig {
|
||||
}
|
||||
|
||||
declare module 'antd-style' {
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface CustomToken extends TachybaseToken {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user