fix(theme-editor): fix color of UI settings and Header
This commit is contained in:
parent
08b2f374c8
commit
8196e164a5
@ -1,5 +1,6 @@
|
|||||||
import { TinyColor } from '@ctrl/tinycolor';
|
import { TinyColor } from '@ctrl/tinycolor';
|
||||||
import { useEffect, useMemo } from 'react';
|
import { useEffect, useMemo } from 'react';
|
||||||
|
import { defaultTheme } from '../global-theme';
|
||||||
import { useToken } from '../style';
|
import { useToken } from '../style';
|
||||||
|
|
||||||
const CSSVariableProvider = ({ children }) => {
|
const CSSVariableProvider = ({ children }) => {
|
||||||
@ -38,9 +39,15 @@ const CSSVariableProvider = ({ children }) => {
|
|||||||
document.body.style.setProperty('--colorBgScrollBarHover', colorBgScrollBarHover);
|
document.body.style.setProperty('--colorBgScrollBarHover', colorBgScrollBarHover);
|
||||||
document.body.style.setProperty('--colorBgScrollBarActive', colorBgScrollBarActive);
|
document.body.style.setProperty('--colorBgScrollBarActive', colorBgScrollBarActive);
|
||||||
document.body.style.setProperty('--colorBgDrawer', colorBgDrawer);
|
document.body.style.setProperty('--colorBgDrawer', colorBgDrawer);
|
||||||
document.body.style.setProperty('--colorSettings', token.colorSettings);
|
document.body.style.setProperty('--colorSettings', token.colorSettings || defaultTheme.token.colorSettings);
|
||||||
document.body.style.setProperty('--colorBgSettingsHover', token.colorBgSettingsHover);
|
document.body.style.setProperty(
|
||||||
document.body.style.setProperty('--colorBorderSettingsHover', token.colorBorderSettingsHover);
|
'--colorBgSettingsHover',
|
||||||
|
token.colorBgSettingsHover || defaultTheme.token.colorBgSettingsHover,
|
||||||
|
);
|
||||||
|
document.body.style.setProperty(
|
||||||
|
'--colorBorderSettingsHover',
|
||||||
|
token.colorBorderSettingsHover || defaultTheme.token.colorBorderSettingsHover,
|
||||||
|
);
|
||||||
|
|
||||||
// 设置登录页面的背景色
|
// 设置登录页面的背景色
|
||||||
document.body.style.setProperty('background-color', token.colorBgContainer);
|
document.body.style.setProperty('background-color', token.colorBgContainer);
|
||||||
|
@ -24,6 +24,7 @@ const ToEditTheme = () => {
|
|||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCurrentSettingTheme(theme);
|
setCurrentSettingTheme(theme);
|
||||||
|
setTheme(compatOldTheme(theme));
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
m.destroy();
|
m.destroy();
|
||||||
}}
|
}}
|
||||||
|
@ -2,7 +2,7 @@ import { ThemeConfig, defaultTheme } from '@nocobase/client';
|
|||||||
|
|
||||||
// 兼容旧主题
|
// 兼容旧主题
|
||||||
function compatOldTheme(theme: ThemeConfig) {
|
function compatOldTheme(theme: ThemeConfig) {
|
||||||
if (!theme.token.colorSettings) {
|
if (!theme.token?.colorSettings) {
|
||||||
theme.token = { ...theme.token, ...defaultTheme.token };
|
theme.token = { ...theme.token, ...defaultTheme.token };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user