diff --git a/frontend/ai-dimension/src/App.vue b/frontend/ai-dimension/src/App.vue index 9ea99f6..03e11ab 100644 --- a/frontend/ai-dimension/src/App.vue +++ b/frontend/ai-dimension/src/App.vue @@ -27,7 +27,7 @@ function initTheme() { function applyTheme(theme) { try { - // H5 环境直接操作 document + // H5 环境:操作 document class const root = document.documentElement if (theme === 'dark') { root.classList.add('theme-dark') @@ -37,7 +37,31 @@ function applyTheme(theme) { root.classList.add('theme-light') } } catch (e) { - // 小程序环境:document 不存在,直接忽略 + // 小程序环境:document 不存在 + } + // 小程序 tabBar 原生组件同步切换 + applyTabBarTheme(theme) +} + +function applyTabBarTheme(theme) { + try { + if (theme === 'dark') { + uni.setTabBarStyle({ + color: 'rgba(255,255,255,0.25)', + selectedColor: '#b388ff', + backgroundColor: '#08080f', + borderStyle: 'black' + }) + } else { + uni.setTabBarStyle({ + color: 'rgba(0,0,0,0.35)', + selectedColor: '#7c4dff', + backgroundColor: '#ffffff', + borderStyle: 'white' + }) + } + } catch (e) { + // H5 环境 setTabBarStyle 可能不支持 } } diff --git a/frontend/ai-dimension/src/pages.json b/frontend/ai-dimension/src/pages.json index 2b2c9ba..a0a08c5 100644 --- a/frontend/ai-dimension/src/pages.json +++ b/frontend/ai-dimension/src/pages.json @@ -18,21 +18,21 @@ {"path": "pages/profile/profile", "style": {"navigationBarTitleText": "我的", "navigationStyle": "custom"}} ], "globalStyle": { - "navigationBarTextStyle": "white", + "navigationBarTextStyle": "black", "navigationBarTitleText": "宇之然AI维度", - "navigationBarBackgroundColor": "#050508", - "backgroundColor": "#050508", - "backgroundColorTop": "#050508", - "backgroundColorBottom": "#050508", + "navigationBarBackgroundColor": "#f5f5f7", + "backgroundColor": "#f5f5f7", + "backgroundColorTop": "#f5f5f7", + "backgroundColorBottom": "#f5f5f7", "app-plus": { - "background": "#050508" + "background": "#f5f5f7" } }, "tabBar": { - "color": "rgba(255,255,255,0.25)", - "selectedColor": "#b388ff", - "backgroundColor": "#08080f", - "borderStyle": "black", + "color": "rgba(0,0,0,0.35)", + "selectedColor": "#7c4dff", + "backgroundColor": "#ffffff", + "borderStyle": "white", "list": [ {"pagePath": "pages/index/index", "text": "探索"}, {"pagePath": "pages/chat/chat", "text": "问答"}, @@ -40,4 +40,4 @@ {"pagePath": "pages/profile/profile", "text": "我的"} ] } -} +} \ No newline at end of file diff --git a/frontend/ai-dimension/src/pages/settings/settings.vue b/frontend/ai-dimension/src/pages/settings/settings.vue index e75247e..c1c2f59 100644 --- a/frontend/ai-dimension/src/pages/settings/settings.vue +++ b/frontend/ai-dimension/src/pages/settings/settings.vue @@ -99,9 +99,19 @@ function applyTheme(theme) { root.classList.remove('theme-dark') root.classList.add('theme-light') } - } catch (e) { - // mini-program 忽略 - } + } catch (e) {} + // tabBar 同步 + applyTabBarTheme(theme) +} + +function applyTabBarTheme(theme) { + try { + if (theme === 'dark') { + uni.setTabBarStyle({ color: 'rgba(255,255,255,0.25)', selectedColor: '#b388ff', backgroundColor: '#08080f', borderStyle: 'black' }) + } else { + uni.setTabBarStyle({ color: 'rgba(0,0,0,0.35)', selectedColor: '#7c4dff', backgroundColor: '#ffffff', borderStyle: 'white' }) + } + } catch (e) {} } function showAbout() {