feat(theme): 实现日夜主题自动切换功能

- 添加日夜主题CSS变量定义,支持琥珀夜光和暖白琥珀两种风格
- 实现主题切换逻辑,根据时间自动切换白天(light)和夜间(dark)主题
- 在App.vue中集成主题初始化和token恢复功能
- 更新全局样式类应用主题颜色变量,包括卡片、文本、边框等
- 创建主题混入(mixin)供各页面使用,确保主题同步更新
- 实现导航栏和TabBar主题动态切换,提升用户体验
- 添加API服务层封装HaveADrink SDK,统一处理认证和请求
- 优化DrinkCard组件显示饮酒感受信息,丰富打卡记录展示
- 更新项目依赖配置,集成新的API客户端库
This commit is contained in:
cg
2026-07-16 22:47:38 +08:00
parent 145976f221
commit 860136bceb
22 changed files with 7051 additions and 155 deletions
+54 -18
View File
@@ -1,5 +1,5 @@
<template>
<view class="page-container record-page safe-bottom">
<view :class="themeClass" class="page-container record-page safe-bottom">
<!-- 顶部进度 -->
<view class="step-header">
<view class="step-back" @click="handleBack">
@@ -336,9 +336,12 @@ import {
FEELINGS, VISIBILITY_OPTIONS
} from '../../common/constants'
import { calcStandardCups, unitToMl, formatDate } from '../../common/utils'
import client from '../../common/api'
import { addRecord } from '../../common/mock-data'
import themeMixin from '../../common/theme-mixin'
export default {
mixins: [themeMixin],
data() {
return {
currentStep: 1,
@@ -548,25 +551,48 @@ export default {
}
if (this.currentStep < this.totalSteps) this.currentStep++
},
publishRecord() {
async publishRecord() {
const allDrinks = this.allDrinks.length > 0 ? this.allDrinks : this.drinks
const record = {
const recordData = {
date: this.backfillDate || formatDate(new Date(), 'YYYY-MM-DD'),
mode: 'drank',
drinks: allDrinks,
food: this.selectedFood ? { category: this.selectedFood, name: this.foodName } : null,
drinks: allDrinks.map(d => ({
category: d.category,
brand: d.brand,
product: d.product || '',
amount: d.amount,
unit: d.unit,
degree: d.degree,
standardCups: d.standardCups
})),
food: this.selectedFood ? { category: this.selectedFood, name: this.foodName || '' } : null,
feeling: this.selectedFeeling || null,
photos: this.photos,
photos: [],
visibility: 'friends',
standardCupsTotal: this.totalCups
quote: ''
}
const saved = addRecord(record)
try {
uni.showLoading({ title: '保存中...' })
// 调用后端创建记录
const resp = await client.CreateRecord(recordData)
const saved = resp.data || resp
uni.hideLoading()
// 跳转到卡片页,传递记录ID
uni.redirectTo({
url: `/pages/card/card?recordId=${saved.id}`
})
// 跳转到卡片页,传递记录ID
uni.redirectTo({
url: `/pages/card/card?recordId=${saved.id}`
})
} catch (e) {
uni.hideLoading()
console.warn('创建记录失败,降级本地保存:', e)
uni.showToast({ title: e.msg || '保存失败,已本地保存', icon: 'none', duration: 2000 })
// 降级:本地保存
const saved = addRecord(recordData)
uni.redirectTo({
url: `/pages/card/card?recordId=${saved.id}`
})
}
}
}
}
@@ -575,6 +601,7 @@ export default {
<style lang="scss" scoped>
.record-page {
padding: $sp-lg;
color: $text-primary;
display: flex;
flex-direction: column;
}
@@ -639,6 +666,7 @@ export default {
display: block;
font-size: $fs-2xl;
font-weight: $fw-black;
color: $text-primary;
margin-bottom: $sp-xs;
}
@@ -687,6 +715,7 @@ export default {
.category-name {
font-size: $fs-sm;
font-weight: $fw-medium;
color: $text-primary;
}
.brand-section {
@@ -718,7 +747,7 @@ export default {
padding: $sp-md $sp-lg;
color: $text-primary;
font-size: $fs-base;
border: 2rpx solid rgba(255,255,255,0.06);
border: 2rpx solid var(--border-faint, rgba(255, 255, 255, 0.08));
}
.input-placeholder {
@@ -840,6 +869,7 @@ export default {
.standard-cup-value {
font-size: $fs-xl;
font-weight: $fw-bold;
color: $text-primary;
}
/* 标准杯说明弹窗 */
@@ -849,7 +879,7 @@ export default {
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.7);
background: var(--overlay-modal, rgba(0, 0, 0, 0.7));
display: flex;
align-items: center;
justify-content: center;
@@ -874,6 +904,7 @@ export default {
.cup-info-title {
font-size: $fs-lg;
font-weight: $fw-bold;
color: $text-primary;
}
.cup-info-close {
@@ -924,7 +955,7 @@ export default {
justify-content: space-between;
align-items: center;
padding: $sp-sm 0;
border-bottom: 2rpx solid rgba(255, 255, 255, 0.04);
border-bottom: 2rpx solid var(--border-micro, rgba(255, 255, 255, 0.05));
}
.cup-info-cell {
@@ -1034,6 +1065,7 @@ export default {
.food-name {
font-size: $fs-sm;
font-weight: $fw-medium;
color: $text-primary;
}
.food-detail {
@@ -1077,6 +1109,7 @@ export default {
.feeling-name {
font-size: $fs-lg;
font-weight: $fw-bold;
color: $text-primary;
margin-bottom: $sp-xs;
}
@@ -1116,7 +1149,7 @@ export default {
right: $sp-sm;
width: 44rpx;
height: 44rpx;
background: rgba(0,0,0,0.6);
background: var(--overlay-mask, rgba(0, 0, 0, 0.6));
border-radius: $radius-full;
display: flex;
align-items: center;
@@ -1133,7 +1166,7 @@ export default {
flex-direction: column;
align-items: center;
justify-content: center;
border: 3rpx dashed rgba(255,255,255,0.1);
border: 3rpx dashed var(--border-dashed, rgba(255, 255, 255, 0.12));
&:active {
background: $bg-card-alt;
@@ -1142,6 +1175,7 @@ export default {
.photo-add-icon {
font-size: $fs-3xl;
color: $text-tertiary;
margin-bottom: $sp-sm;
opacity: 0.5;
}
@@ -1153,6 +1187,7 @@ export default {
.photo-tip {
text-align: center;
color: $text-secondary;
}
/* Step 6: 发布 */
@@ -1200,6 +1235,7 @@ export default {
display: block;
font-size: $fs-base;
font-weight: $fw-medium;
color: $text-primary;
}
.visibility-desc {
@@ -1236,7 +1272,7 @@ export default {
justify-content: space-between;
align-items: center;
padding-top: $sp-md;
border-top: 2rpx solid rgba(255,255,255,0.06);
border-top: 2rpx solid var(--border-faint, rgba(255, 255, 255, 0.08));
}
/* 保存提示卡片 */