diff --git a/apps/web/src/App.vue b/apps/web/src/App.vue index d3161de..a50d7be 100644 --- a/apps/web/src/App.vue +++ b/apps/web/src/App.vue @@ -1,6 +1,6 @@ - - - 每日统计 - 今天是否记录完整 - 当前只展示明确事实统计,不做医疗判断。 + + + + 照护统计 + 这几天的照护节奏 + + {{ rangeLabel }} · {{ latestRecordTime }} - - - 今日喂奶次数 - {{ store.summary?.feedingCount ?? 0 }} 次 + + + {{ option.label }} + + + + + + 开始 + + + + 结束 + + + + + 正在整理统计... + + + + {{ totalCareEvents }} + 照护记录 - - 今日睡眠总时长 - {{ formatMinutes(store.summary?.sleepTotalMinutes ?? 0) }} - - - 今日小便次数 - {{ store.summary?.peeCount ?? 0 }} 次 - - - 今日大便次数 - {{ store.summary?.poopCount ?? 0 }} 次 + + + 喂养 + {{ totals.feedingCount }}次 + + + 睡眠 + {{ formatMinutes(totals.sleepMinutes) }} + + + 排泄 + {{ totals.peeCount + totals.poopCount }}次 + - - - 喂奶方式 + + + 喂养趋势 - - {{ formatFeedingMethod(method as string) }} - {{ count }} 次 + + + {{ row.feedingCount }} + + + + {{ row.label }} + + + + 有效亲喂 {{ formatMinutes(totals.effectiveFeedingMinutes) }} + 奶量 {{ totals.milkMl }}ml + 左右 {{ totals.leftMinutes }} / {{ totals.rightMinutes }}分 + 暂停 {{ totals.pauseCount }}次 + + + + {{ formatFeedingMethod(method) }} {{ count }}次 + + + + + + + 睡眠趋势 + {{ totals.sleepCount }}段 · 平均 {{ formatMinutes(avgSleepMinutes) }} + + + + + + + + + {{ point.label }} + + + + + + + 排泄趋势 + 小便 {{ totals.peeCount }} · 大便 {{ totals.poopCount }} + + + + {{ row.label }} + + + + 无记录 + + {{ row.peeCount + row.poopCount }} + - 暂无喂奶记录。 - diff --git a/apps/web/src/pages/TodayPage.vue b/apps/web/src/pages/TodayPage.vue index 4ad2b26..9427a7c 100644 --- a/apps/web/src/pages/TodayPage.vue +++ b/apps/web/src/pages/TodayPage.vue @@ -30,8 +30,6 @@ const breastSide = ref<'left' | 'right'>(store.preferences.defaultBreastSide || const showBabyPicker = ref(false) const showMemberPicker = ref(false) -// 一次性亲喂配置 -const breastSideMode = ref<'left' | 'right' | 'both'>('both') const oneClickDuration = ref(20) watch( @@ -102,13 +100,6 @@ function formatSec(seconds: number) { return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}` } -function formatTotalBfTime() { - const total = store.bfLeftSeconds + store.bfRightSeconds - const m = Math.floor(total / 60) - const s = total % 60 - return `${m}分${String(s).padStart(2, '0')}秒` -} - function handleCardClick(side: 'left' | 'right') { if (store.bfTimerActive) { store.switchBreastfeedSide(side) @@ -167,18 +158,10 @@ async function handleOneClickBreastfeeding() { const startTime = `${getLocalDateStr(startDate)}T${getLocalTimeStr(startDate)}:00` const endTime = `${getLocalDateStr(now)}T${getLocalTimeStr(now)}:00` - let leftDur: number | undefined - let rightDur: number | undefined - if (breastSideMode.value === 'both') { - leftDur = Math.floor(dur / 2) - rightDur = Math.ceil(dur / 2) - } else if (breastSideMode.value === 'left') { - leftDur = dur - rightDur = 0 - } else { - leftDur = 0 - rightDur = dur - } + const firstSideMinutes = Math.ceil(dur / 2) + const secondSideMinutes = Math.floor(dur / 2) + const leftDur = breastSide.value === 'left' ? firstSideMinutes : secondSideMinutes + const rightDur = breastSide.value === 'right' ? firstSideMinutes : secondSideMinutes const startStr = `${String(startDate.getHours()).padStart(2, '0')}:${String(startDate.getMinutes()).padStart(2, '0')}` const endStr = `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}` @@ -192,7 +175,7 @@ async function handleOneClickBreastfeeding() { leftDurationMinutes: leftDur, rightDurationMinutes: rightDur, effectiveFeedingMinutes: dur, - breastSide: breastSideMode.value + breastSide: breastSide.value }), `已记录亲喂 ${dur}分钟(${startStr} ~ ${endStr})` ) @@ -269,7 +252,6 @@ async function handleOneClickBreastfeeding() { 喂养 亲喂进行中 - 支持亲喂、挤出母乳、配方奶与混合喂养多模式快捷记录。 @@ -313,16 +295,9 @@ async function handleOneClickBreastfeeding() { {{ formatSec(store.bfLeftSeconds) }} @@ -348,80 +323,33 @@ async function handleOneClickBreastfeeding() { {{ formatSec(store.bfRightSeconds) }} - - - 本次亲喂总计:{{ formatTotalBfTime() }} - (左侧 {{ formatSec(store.bfLeftSeconds) }} · 右侧 {{ formatSec(store.bfRightSeconds) }}{{ store.bfPaused ? ' · 已暂停' : '' }}) - - - + - - 亲喂模式 - - - 双侧均喂 - - - 仅左侧 - - - 仅右侧 - - - - - - 一次性记录时长 - + + 快速补记 + - {{ d }}分钟 + {{ d }}分 - - 💡 一键记录将按 - - {{ breastSideMode === 'both' ? `左侧 ${Math.floor(oneClickDuration / 2)}分 + 右侧 ${Math.ceil(oneClickDuration / 2)}分(总计 ${oneClickDuration}分)` : breastSideMode === 'left' ? `左侧 ${oneClickDuration}分钟` : `右侧 ${oneClickDuration}分钟` }} - - 自动推导起止时间并入库 + + 一键补记会按当前优先侧分配:左侧 {{ breastSide === 'left' ? Math.ceil(oneClickDuration / 2) : Math.floor(oneClickDuration / 2) }}分 · 右侧 {{ breastSide === 'right' ? Math.ceil(oneClickDuration / 2) : Math.floor(oneClickDuration / 2) }}分 @@ -433,9 +361,9 @@ async function handleOneClickBreastfeeding() { type="primary" :loading="operating" :disabled="operating" - @click="runWithTip(() => store.startBreastfeedTimer(breastSideMode === 'right' ? 'right' : 'left'), `已开始亲喂计时(${breastSideMode === 'right' ? '右侧开始' : '左侧开始'})`)" + @click="runWithTip(() => store.startBreastfeedTimer(breastSide), `已开始亲喂计时(${breastSide === 'right' ? '右侧开始' : '左侧开始'})`)" > - 开始亲喂 ({{ breastSideMode === 'right' ? '右侧开始' : '左侧开始' }}) + 开始亲喂 - 一键记录 {{ oneClickDuration }}分钟 + 补记 {{ oneClickDuration }}分钟 - - - ⇄ {{ store.bfPaused ? '切换并继续' : '切换到' }}{{ store.bfActiveSide === 'left' ? '右侧' : '左侧' }} - + 快速记录 - 尿尿、便便和睡眠优先保证动作清晰。 span { + color: #475569; + font-size: 13px; + font-weight: 800; +} + +.bf-duration-chips { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 8px; +} + +.bf-duration-chip { + border: 0; + min-height: 38px; + border-radius: 999px; + background: #ffffff; + color: #475569; + font-size: 13px; + font-weight: 800; + box-shadow: inset 0 0 0 1px #e2e8f0; +} + +.bf-duration-chip.active { + background: #a46208; + color: #ffffff; + box-shadow: 0 8px 16px rgba(164, 98, 8, 0.18); +} + +.bf-quick-hint { margin-top: 10px; + border-radius: 12px; + background: #ffffff; + color: #64748b; + font-size: 12px; + line-height: 1.5; + padding: 9px 10px; + box-shadow: inset 0 0 0 1px #e8eef6; +} + +.bf-live-actions { + grid-template-columns: 1fr; } .bf-live-badge { @@ -1149,6 +1170,352 @@ button { margin-bottom: 18px; } +.stats-page { + display: grid; + gap: 14px; +} + +.stats-header { + display: flex; + align-items: flex-end; + justify-content: space-between; + gap: 12px; +} + +.stats-header h1 { + margin: 4px 0 0; + color: #071b35; + font-size: 28px; + line-height: 1.18; +} + +.stats-updated { + flex: 0 0 auto; + color: #64748b; + font-size: 12px; + font-weight: 700; + padding-bottom: 4px; +} + +.stats-range-tabs { + display: grid; + grid-template-columns: repeat(4, 1fr); + gap: 6px; + border-radius: 18px; + background: #eef3f8; + padding: 5px; +} + +.stats-range-tabs button { + border: 0; + min-height: 42px; + border-radius: 14px; + background: transparent; + color: #64748b; + font-size: 14px; + font-weight: 800; +} + +.stats-range-tabs button.active { + background: #ffffff; + color: #9a5f08; + box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08); +} + +.stats-custom-range { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 10px; + margin-top: -4px; +} + +.stats-custom-range label { + display: grid; + gap: 6px; + color: #64748b; + font-size: 12px; + font-weight: 800; +} + +.stats-custom-range input { + width: 100%; + min-height: 42px; + box-sizing: border-box; + border: 1px solid #e2e8f0; + border-radius: 14px; + background: #ffffff; + color: #071b35; + font-size: 14px; + font-weight: 800; + padding: 0 10px; +} + +.stats-rhythm { + display: grid; + grid-template-columns: 124px 1fr; + align-items: center; + gap: 18px; + padding: 10px 0 4px; +} + +.rhythm-orbit { + --feeding: 0; + --sleep: 0; + --excretion: 0; + display: grid; + place-items: center; + align-content: center; + width: 118px; + height: 118px; + border-radius: 999px; + background: + radial-gradient(circle at center, #fffaf1 0 54%, transparent 55%), + conic-gradient(#2b8cff 0 40%, #8b7cf6 40% 70%, #84cc16 70% 100%); + box-shadow: 0 16px 34px rgba(51, 36, 16, 0.08); +} + +.rhythm-orbit strong { + color: #071b35; + font-size: 30px; + line-height: 1; +} + +.rhythm-orbit span { + margin-top: 4px; + color: #64748b; + font-size: 12px; + font-weight: 800; +} + +.rhythm-metrics { + display: grid; + gap: 12px; +} + +.rhythm-metrics div { + display: grid; + grid-template-columns: 52px 1fr; + align-items: baseline; + gap: 10px; + border-bottom: 1px solid #eee7dc; + padding-bottom: 10px; +} + +.rhythm-metrics div:last-child { + border-bottom: 0; + padding-bottom: 0; +} + +.rhythm-metrics span { + color: #64748b; + font-size: 13px; + font-weight: 800; +} + +.rhythm-metrics strong { + color: #071b35; + font-size: 18px; +} + +.graph-section { + display: grid; + gap: 14px; + border-top: 1px solid #eee7dc; + padding-top: 18px; +} + +.graph-title { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 12px; +} + +.graph-title h2 { + margin: 0; + color: #071b35; + font-size: 21px; +} + +.graph-title span { + color: #64748b; + font-size: 12px; + font-weight: 800; + white-space: nowrap; +} + +.feeding-column-chart { + display: grid; + grid-template-columns: repeat(var(--days, 7), minmax(22px, 1fr)); + align-items: end; + gap: 8px; + min-height: 176px; + padding: 8px 0 0; +} + +.feeding-column { + display: grid; + grid-template-rows: 24px 118px 20px; + align-items: end; + gap: 7px; + min-width: 0; + text-align: center; +} + +.feeding-column > strong { + color: #071b35; + font-size: 12px; +} + +.feeding-column > div { + display: flex; + align-items: end; + justify-content: center; + height: 118px; + border-radius: 999px; + background: #eef3f8; + overflow: hidden; +} + +.feeding-column i { + display: block; + width: 100%; + min-height: 8px; + border-radius: inherit; + background: linear-gradient(180deg, #73b7ff 0%, #2b8cff 100%); +} + +.feeding-column span { + color: #64748b; + font-size: 11px; + font-weight: 800; +} + +.graph-facts { + display: flex; + gap: 8px; + overflow-x: auto; + padding-bottom: 2px; +} + +.graph-facts span { + flex: 0 0 auto; + border-radius: 999px; + background: #f8fafc; + color: #475569; + font-size: 12px; + font-weight: 800; + padding: 8px 10px; +} + +.sleep-line-chart { + display: grid; + gap: 8px; +} + +.sleep-line-chart svg { + width: 100%; + height: 178px; + overflow: visible; +} + +.sleep-area { + fill: rgba(139, 124, 246, 0.12); + stroke: none; +} + +.sleep-line { + fill: none; + stroke: #8b7cf6; + stroke-width: 4; + stroke-linecap: round; + stroke-linejoin: round; + vector-effect: non-scaling-stroke; +} + +.sleep-line-chart circle { + fill: #ffffff; + stroke: #8b7cf6; + stroke-width: 3; + vector-effect: non-scaling-stroke; +} + +.sleep-axis { + display: flex; + justify-content: space-between; + color: #64748b; + font-size: 11px; + font-weight: 800; +} + +.method-pills { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.method-pills span { + border-radius: 999px; + background: #fff7e8; + color: #925f12; + font-size: 12px; + font-weight: 800; + padding: 7px 10px; +} + +.excretion-list { + display: grid; + gap: 12px; +} + +.excretion-list > div { + display: grid; + grid-template-columns: 42px 1fr 34px; + align-items: center; + gap: 10px; +} + +.excretion-list span { + color: #64748b; + font-size: 12px; + font-weight: 800; +} + +.excretion-list strong { + color: #071b35; + font-size: 13px; + text-align: right; +} + +.excretion-dots { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 6px; + min-height: 20px; +} + +.excretion-dots i { + width: 10px; + height: 10px; + border-radius: 999px; +} + +.excretion-dots .pee { + background: #38bdf8; +} + +.excretion-dots .poop { + background: #84cc16; +} + +.excretion-dots em { + color: #94a3b8; + font-size: 12px; + font-style: normal; + font-weight: 700; +} + .bottom-nav { position: fixed; left: 50%; diff --git a/doc/2026-09-28-stats-range-summary-redesign.md b/doc/2026-09-28-stats-range-summary-redesign.md new file mode 100644 index 0000000..9ba927e --- /dev/null +++ b/doc/2026-09-28-stats-range-summary-redesign.md @@ -0,0 +1,22 @@ +# 统计页跨天汇总重设计 + +## 背景 + +原统计页只展示今日喂养、睡眠、大小便次数,与今日页顶部卡片重复。统计页应承担跨天汇总与趋势回顾,而不是再次展示今日操作概览。 + +## 设计目标 + +- 统计页默认展示近 7 天数据,并支持近 3 天、近 7 天、近 14 天切换。 +- 保留事实汇总,不做医疗判断。 +- 聚焦家庭真正会回看的内容: + - 总览汇总:喂养、睡眠、排泄总量; + - 喂养趋势:每日喂养次数、奶量、亲喂有效时长、左右侧累计; + - 睡眠趋势:每日睡眠时长、睡眠段数、平均单段时长; + - 排泄趋势:每日小便、大便记录。 +- 移动端优先,使用大触控分段按钮、紧凑趋势条和少量高价值指标。 + +## 暂不处理 + +- 暂不新增后端跨天统计接口,前端先基于现有按日期查询记录接口聚合。 +- 暂不展示记录完整度日历。 +- 暂不做医疗建议或异常判断。 diff --git a/doc/README.md b/doc/README.md index 72a83ec..19adf32 100644 --- a/doc/README.md +++ b/doc/README.md @@ -29,6 +29,7 @@ - [2026-09-26-server-shanghai-timezone-and-timeline-grouping.md](./2026-09-26-server-shanghai-timezone-and-timeline-grouping.md): 照护记录页面按日分组优化与服务端上海时区校准设计方案。 - [2026-09-26-care-rule-quick-manual-log.md](./2026-09-26-care-rule-quick-manual-log.md): 常用规则补记照护与多条明细草稿确认方案。 - [2026-09-26-family-home-and-onboarding.md](./2026-09-26-family-home-and-onboarding.md): 家庭页入口合并、多宝宝/多成员层级与新用户创建/加入家庭闭环设计。 +- [2026-09-28-stats-range-summary-redesign.md](./2026-09-28-stats-range-summary-redesign.md): 统计页从今日重复数据调整为跨天汇总与趋势回顾。 ## 记录原则
每日统计
当前只展示明确事实统计,不做医疗判断。
照护统计
正在整理统计...
暂无喂奶记录。
支持亲喂、挤出母乳、配方奶与混合喂养多模式快捷记录。
尿尿、便便和睡眠优先保证动作清晰。