This is an automated email from the ASF dual-hosted git repository.
shuai pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/answer.git
The following commit(s) were added to refs/heads/test by this push:
new 59a06ad6 fix: Compatibility default value is colored or light before
v1.5.1
59a06ad6 is described below
commit 59a06ad696948661710e4bbae11ac3bf139eee3d
Author: shuai <[email protected]>
AuthorDate: Wed May 28 11:31:42 2025 +0800
fix: Compatibility default value is colored or light before v1.5.1
---
ui/src/components/Header/index.tsx | 1 +
ui/src/pages/Admin/Themes/index.tsx | 4 +++-
ui/src/stores/themeSetting.ts | 4 ++++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/ui/src/components/Header/index.tsx
b/ui/src/components/Header/index.tsx
index 1003220e..bd2296b4 100644
--- a/ui/src/components/Header/index.tsx
+++ b/ui/src/components/Header/index.tsx
@@ -85,6 +85,7 @@ const Header: FC = () => {
let themeMode = 'light';
const { theme, theme_config } = themeSettingStore((_) => _);
if (theme_config?.[theme]?.navbar_style) {
+ // const color = theme_config[theme].navbar_style.startsWith('#')
themeMode = isLight(theme_config[theme].navbar_style) ? 'light' : 'dark';
console.log('isLightTheme', themeMode);
navbarStyle = `theme-${themeMode}`;
diff --git a/ui/src/pages/Admin/Themes/index.tsx
b/ui/src/pages/Admin/Themes/index.tsx
index 63a49055..94eccbca 100644
--- a/ui/src/pages/Admin/Themes/index.tsx
+++ b/ui/src/pages/Admin/Themes/index.tsx
@@ -166,7 +166,9 @@ const Index: FC = () => {
const themeConfig = setting.theme_config[themeName];
const formMeta = { ...formData };
formMeta.themes.value = themeName;
- formMeta.navbar_style.value = themeConfig?.navbar_style;
+ formMeta.navbar_style.value = themeConfig?.navbar_style.startsWith('#')
+ ? themeConfig?.navbar_style
+ : DEFAULT_THEME_COLOR;
formMeta.primary_color.value = themeConfig?.primary_color;
formData.color_scheme.value = setting?.color_scheme || 'system';
setFormData({ ...formMeta });
diff --git a/ui/src/stores/themeSetting.ts b/ui/src/stores/themeSetting.ts
index 9f6802b8..4b13d818 100644
--- a/ui/src/stores/themeSetting.ts
+++ b/ui/src/stores/themeSetting.ts
@@ -42,6 +42,10 @@ const store = create<IType>((set) => ({
},
update: (params) =>
set((state) => {
+ // Compatibility default value is colored or light before v1.5.1
+ if (!params.theme_config.default.navbar_style.startsWith('#')) {
+ params.theme_config.default.navbar_style = DEFAULT_THEME_COLOR;
+ }
return {
...state,
...params,