refactor(theme): 统一应用深色主题替换日夜切换功能

- 移除白天主题相关样式定义和切换逻辑
- 将主题系统固定为深色主题(琥珀夜光)
- 更新页面背景色设置为统一深色
- 简化导航栏和标签栏主题应用逻辑
- 移除白天主题的颜色变量和样式类
- 更新主题混入文件以支持单一深色主题
```
This commit is contained in:
cg
2026-08-16 22:45:10 +08:00
parent 9fa22d5d1b
commit 06ec10cf10
5 changed files with 34 additions and 96 deletions
+6 -6
View File
@@ -1,8 +1,8 @@
/* 碰盏日记 - 主题混入 (Theme Mixin)
* 每个页面混入此mixin,自动在onShow时刷新日夜主题
* 全局统一深色主题(琥珀夜光),已移除白天主题
* 页面根视图需绑定 :class="themeClass"
*/
import { getCurrentTheme, applyTheme } from './utils'
import { applyTheme } from './utils'
export default {
data() {
@@ -19,10 +19,10 @@ export default {
},
methods: {
_refreshTheme() {
const theme = getCurrentTheme()
this.currentTheme = theme
this.themeClass = theme === 'light' ? 'theme-light' : 'theme-dark'
applyTheme(theme)
// 固定深色主题
this.currentTheme = 'dark'
this.themeClass = 'theme-dark'
applyTheme('dark')
}
}
}
+23 -38
View File
@@ -278,13 +278,10 @@ export function calcLocalStreak(records) {
}
/**
* 主题系统:日夜自动切换
* 白天:6:00-16:00 → light
* 夜间:16:00-6:00 → dark
* 主题系统:全局统一使用深色主题(琥珀夜光),已移除白天主题
*/
export function getCurrentTheme() {
const hour = new Date().getHours()
return (hour >= 6 && hour < 16) ? 'light' : 'dark'
return 'dark'
}
export function applyTheme(theme) {
@@ -296,15 +293,11 @@ export function applyTheme(theme) {
}
export function applyNavBarTheme(theme) {
const colors = {
dark: { backgroundColor: '#0B0B14', frontColor: '#ffffff' },
light: { backgroundColor: '#F2F5F9', frontColor: '#000000' }
}
const c = colors[theme] || colors.dark
// 仅深色主题
try {
uni.setNavigationBarColor({
frontColor: c.frontColor,
backgroundColor: c.backgroundColor,
frontColor: '#ffffff',
backgroundColor: '#0B0B14',
animation: { duration: 300, timingFunc: 'easeInOut' }
})
} catch (e) {}
@@ -336,21 +329,13 @@ export function applyTabBarTheme(theme) {
const currentPath = pages[pages.length - 1].route
if (!tabBarPages.includes(currentPath)) return
const styles = {
dark: {
color: '#9494AC',
selectedColor: '#E8A838',
backgroundColor: '#151520',
borderStyle: 'black'
},
light: {
color: '#9BA8BA',
selectedColor: '#E09B2D',
backgroundColor: '#FFFFFF',
borderStyle: 'white'
}
// 仅深色主题
const s = {
color: '#9494AC',
selectedColor: '#E8A838',
backgroundColor: '#151520',
borderStyle: 'black'
}
const s = styles[theme] || styles.dark
try {
uni.setTabBarStyle({
color: s.color,
@@ -365,19 +350,19 @@ export function applyTabBarTheme(theme) {
}
export function getThemeColors(theme) {
const isDark = theme !== 'light'
// 仅保留深色主题色值(参数保留以兼容既有调用)
return {
textPrimary: isDark ? '#FFFFFF' : '#16233C',
textSecondary: isDark ? '#C0C0D2' : '#5D6B82',
textTertiary: isDark ? '#9494AC' : '#9BA8BA',
amber: isDark ? '#E8A838' : '#E09B2D',
bgBase: isDark ? '#0B0B14' : '#F2F5F9',
bgCard: isDark ? '#1A1A28' : '#FFFFFF',
cardGradStart: isDark ? '#1A1510' : '#F8FAFD',
cardGradEnd: isDark ? '#0D0B08' : '#EFF3F9',
borderSubtle: isDark ? 'rgba(232,168,56,0.15)' : 'rgba(224,155,45,0.18)',
bgPlaceholder: isDark ? 'rgba(255,255,255,0.03)' : 'rgba(22,40,70,0.04)',
emojiBg: isDark ? 'rgba(232,168,56,0.08)' : 'rgba(224,155,45,0.10)'
textPrimary: '#FFFFFF',
textSecondary: '#C0C0D2',
textTertiary: '#9494AC',
amber: '#E8A838',
bgBase: '#0B0B14',
bgCard: '#1A1A28',
cardGradStart: '#1A1510',
cardGradEnd: '#0D0B08',
borderSubtle: 'rgba(232,168,56,0.15)',
bgPlaceholder: 'rgba(255,255,255,0.03)',
emojiBg: 'rgba(232,168,56,0.08)'
}
}