From eff5bc3890e3605fab7288eda2567877c86abe17 Mon Sep 17 00:00:00 2001 From: sealday Date: Mon, 23 Sep 2024 16:28:48 +0800 Subject: [PATCH] fix: theme error, close #1557 (#1558) Co-authored-by: sealday Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1558 --- packages/core/client/src/style/theme/defaultTheme.ts | 4 ++-- packages/core/client/src/style/theme/index.tsx | 10 ++++++---- packages/core/client/src/style/theme/type.ts | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/core/client/src/style/theme/defaultTheme.ts b/packages/core/client/src/style/theme/defaultTheme.ts index 2309614bd..2e12caa91 100644 --- a/packages/core/client/src/style/theme/defaultTheme.ts +++ b/packages/core/client/src/style/theme/defaultTheme.ts @@ -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__, }, diff --git a/packages/core/client/src/style/theme/index.tsx b/packages/core/client/src/style/theme/index.tsx index b7deec1a7..a584acc59 100644 --- a/packages/core/client/src/style/theme/index.tsx +++ b/packages/core/client/src/style/theme/index.tsx @@ -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(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(themeFromProps || defaultTheme); + const [theme, setTheme] = useState(themeFromProps || defaultTheme); const currentSettingThemeRef = useRef(null); const currentEditingThemeRef = useRef(null); @@ -82,7 +82,9 @@ export const GlobalThemeProvider = ({ children, theme: themeFromProps }) => { return ( - {children} + + {children} + ); }; diff --git a/packages/core/client/src/style/theme/type.ts b/packages/core/client/src/style/theme/type.ts index 60d55f4bd..acb5b042c 100644 --- a/packages/core/client/src/style/theme/type.ts +++ b/packages/core/client/src/style/theme/type.ts @@ -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 {} }