- 添加日夜主题CSS变量定义,支持琥珀夜光和暖白琥珀两种风格 - 实现主题切换逻辑,根据时间自动切换白天(light)和夜间(dark)主题 - 在App.vue中集成主题初始化和token恢复功能 - 更新全局样式类应用主题颜色变量,包括卡片、文本、边框等 - 创建主题混入(mixin)供各页面使用,确保主题同步更新 - 实现导航栏和TabBar主题动态切换,提升用户体验 - 添加API服务层封装HaveADrink SDK,统一处理认证和请求 - 优化DrinkCard组件显示饮酒感受信息,丰富打卡记录展示 - 更新项目依赖配置,集成新的API客户端库
29 lines
630 B
JavaScript
29 lines
630 B
JavaScript
/* 喝了么 - 主题混入 (Theme Mixin)
|
|
* 每个页面混入此mixin,自动在onShow时刷新日夜主题
|
|
* 页面根视图需绑定 :class="themeClass"
|
|
*/
|
|
import { getCurrentTheme, applyTheme } from './utils'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
themeClass: 'theme-dark',
|
|
currentTheme: 'dark'
|
|
}
|
|
},
|
|
created() {
|
|
this._refreshTheme()
|
|
},
|
|
onShow() {
|
|
this._refreshTheme()
|
|
},
|
|
methods: {
|
|
_refreshTheme() {
|
|
const theme = getCurrentTheme()
|
|
this.currentTheme = theme
|
|
this.themeClass = theme === 'light' ? 'theme-light' : 'theme-dark'
|
|
applyTheme(theme)
|
|
}
|
|
}
|
|
}
|