This commit is contained in:
gs committed 2026-09-26 01:09:06 +08:00
1 parent dc23ea53ed
commit 8c7a9040d2
106 files changed
+5668 -9910

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
<script setup lang="ts">
const tabs = [
{ to: '/today', label: '今日' },
{ to: '/timeline', label: '流水' },
{ to: '/stats', label: '统计' },
{ to: '/settings', label: '设置' }
]
</script>
<template>
<div class="app-shell">
<main class="app-main">
<RouterView />
</main>
<nav class="bottom-nav">
<RouterLink v-for="tab in tabs" :key="tab.to" :to="tab.to" class="bottom-nav__item">
{{ tab.label }}
</RouterLink>
</nav>
</div>
</template>
+119
View File
@@ -0,0 +1,119 @@
import type { ApiResponse, BabyProfile, CareRecord, DailySummary, FamilyContext, FeedingMethod } from '../types/domain'
async function request<T>(url: string, options: RequestInit = {}): Promise<T> {
const response = await fetch(url, {
headers: {
'Content-Type': 'application/json',
...(options.headers || {})
},
...options
})
const body = (await response.json()) as ApiResponse<T>
if (!response.ok || !body.success) {
throw new Error(body.error?.message || '请求失败')
}
return body.data
}
export function getCurrentBaby() {
return request<BabyProfile>('/api/v1/babies/current')
}
export function getFamilyContext() {
return request<FamilyContext>('/api/v1/families/current-context')
}
export function updateCurrentBaby(payload: Pick<BabyProfile, 'name' | 'gender' | 'birthDate' | 'deliveryType'>) {
return request<BabyProfile>('/api/v1/babies/current', {
method: 'PUT',
body: JSON.stringify(payload)
})
}
export function updateBaby(babyId: string, payload: Pick<BabyProfile, 'name' | 'gender' | 'birthDate' | 'deliveryType'>) {
return request<BabyProfile>(`/api/v1/babies/${encodeURIComponent(babyId)}`, {
method: 'PUT',
body: JSON.stringify(payload)
})
}
export function getDailySummary(babyId: string) {
return request<DailySummary>(`/api/v1/summary/daily?babyId=${encodeURIComponent(babyId)}`)
}
export function getRecords(babyId: string) {
return request<CareRecord[]>(`/api/v1/records?babyId=${encodeURIComponent(babyId)}`)
}
export function createFeeding(payload: {
babyId: string
feedingMethod: FeedingMethod
amountMl?: number
breastSide?: 'left' | 'right'
operatorName: string
}) {
return request<CareRecord>('/api/v1/records/feeding', {
method: 'POST',
body: JSON.stringify(payload)
})
}
export function startFeeding(payload: {
babyId: string
breastSide: 'left' | 'right'
operatorName: string
}) {
return request<CareRecord>('/api/v1/records/feeding/start', {
method: 'POST',
body: JSON.stringify({
...payload,
feedingMethod: 'breastfeed'
})
})
}
export function endFeeding(payload: {
babyId: string
breastSide: 'left' | 'right'
operatorName: string
}) {
return request<CareRecord>('/api/v1/records/feeding/end', {
method: 'POST',
body: JSON.stringify({
...payload,
feedingMethod: 'breastfeed'
})
})
}
export function startSleep(payload: { babyId: string; operatorName: string }) {
return request<CareRecord>('/api/v1/records/sleep/start', {
method: 'POST',
body: JSON.stringify(payload)
})
}
export function endSleep(payload: { babyId: string; operatorName: string }) {
return request<CareRecord>('/api/v1/records/sleep/end', {
method: 'POST',
body: JSON.stringify(payload)
})
}
export function createPee(payload: { babyId: string; operatorName: string }) {
return request<CareRecord>('/api/v1/records/pee', {
method: 'POST',
body: JSON.stringify(payload)
})
}
export function createPoop(payload: { babyId: string; operatorName: string }) {
return request<CareRecord>('/api/v1/records/poop', {
method: 'POST',
body: JSON.stringify(payload)
})
}
export function deleteRecord(recordId: string) {
return request<void>(`/api/v1/records/${recordId}`, { method: 'DELETE' })
}
+9
View File
@@ -0,0 +1,9 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import Vant from 'vant'
import 'vant/lib/index.css'
import App from './App.vue'
import router from './router'
import './style.css'
createApp(App).use(Vant).use(createPinia()).use(router).mount('#app')
+142
View File
@@ -0,0 +1,142 @@
<script setup lang="ts">
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { showToast } from 'vant'
import { useCareStore } from '../stores/careStore'
const store = useCareStore()
const activeTab = ref('baby')
const form = reactive({
name: '',
gender: 'boy',
birthDate: '',
deliveryType: 'natural',
operatorName: store.operatorName
})
const currentBabyLabel = computed(() => store.baby ? `${store.baby.name} · ${store.baby.ageText}` : '未选择宝宝')
onMounted(async () => {
await store.load()
syncBabyForm()
})
watch(() => store.baby?.babyId, () => {
syncBabyForm()
})
watch(() => form.operatorName, value => {
store.setOperatorName(value)
})
function syncBabyForm() {
if (!store.baby) return
form.name = store.baby.name
form.gender = store.baby.gender
form.birthDate = store.baby.birthDate
form.deliveryType = store.baby.deliveryType
}
async function save() {
await store.saveBaby({
name: form.name,
gender: form.gender,
birthDate: form.birthDate,
deliveryType: form.deliveryType
})
showToast({ message: '宝宝信息已保存', type: 'success' })
}
</script>
<template>
<section class="page">
<header class="page-header">
<p class="eyebrow">设置</p>
<h1>家庭照护维护</h1>
<p>{{ currentBabyLabel }}</p>
</header>
<van-tabs v-model:active="activeTab" shrink>
<van-tab title="宝宝" name="baby">
<section class="panel form-panel">
<label>
宝宝昵称
<input v-model="form.name" />
</label>
<label>
出生日期
<input v-model="form.birthDate" type="date" />
</label>
<label>
性别
<select v-model="form.gender">
<option value="boy">男宝</option>
<option value="girl">女宝</option>
</select>
</label>
<label>
分娩方式
<select v-model="form.deliveryType">
<option value="natural">顺产</option>
<option value="c_section">剖宫产</option>
<option value="unknown">暂不设置</option>
</select>
</label>
<button class="save-button" @click="save">保存宝宝信息</button>
</section>
</van-tab>
<van-tab title="家庭" name="family">
<section class="panel">
<div class="settings-list">
<div>
<span>家庭名称</span>
<strong>{{ store.context?.family.name || '新生儿照护家庭' }}</strong>
</div>
<div>
<span>邀请码</span>
<strong>{{ store.context?.family.inviteCode || '暂未设置' }}</strong>
</div>
<div>
<span>宝宝数量</span>
<strong>{{ store.babies.length }}</strong>
</div>
</div>
</section>
</van-tab>
<van-tab title="成员" name="members">
<section class="panel form-panel">
<label>
当前记录人
<input v-model="form.operatorName" />
</label>
<div class="settings-list">
<div v-for="member in store.members" :key="member.memberId">
<span>{{ member.roleName }}</span>
<strong>{{ member.roleType === 'owner' ? '家庭管理员' : '照护成员' }}</strong>
</div>
</div>
</section>
</van-tab>
<van-tab title="行为" name="actions">
<section class="panel">
<div class="settings-list">
<div>
<span>亲喂</span>
<strong>支持计时、左右侧切换、一键记录</strong>
</div>
<div>
<span>瓶喂</span>
<strong>支持调整奶量</strong>
</div>
<div>
<span>快速反馈</span>
<strong>记录成功后显示温馨提示</strong>
</div>
</div>
</section>
</van-tab>
</van-tabs>
</section>
</template>
+52
View File
@@ -0,0 +1,52 @@
<script setup lang="ts">
import { onMounted } from 'vue'
import { useCareStore } from '../stores/careStore'
import { formatMinutes } from '../utils/format'
const store = useCareStore()
onMounted(() => {
store.load()
})
</script>
<template>
<section class="page">
<header class="page-header">
<p class="eyebrow">每日统计</p>
<h1>今天是否记录完整</h1>
<p>当前只展示明确事实统计,不做医疗判断。</p>
</header>
<section class="panel">
<div class="stat-row">
<span>今日喂奶次数</span>
<strong>{{ store.summary?.feedingCount ?? 0 }} 次</strong>
</div>
<div class="stat-row">
<span>今日睡眠总时长</span>
<strong>{{ formatMinutes(store.summary?.sleepTotalMinutes ?? 0) }}</strong>
</div>
<div class="stat-row">
<span>今日小便次数</span>
<strong>{{ store.summary?.peeCount ?? 0 }} 次</strong>
</div>
<div class="stat-row">
<span>今日大便次数</span>
<strong>{{ store.summary?.poopCount ?? 0 }} 次</strong>
</div>
</section>
<section class="panel">
<div class="panel-title">
<h2>喂奶方式</h2>
</div>
<div class="stat-row" v-for="(count, method) in store.summary?.feedingMethodCounts || {}" :key="method">
<span>{{ method }}</span>
<strong>{{ count }} 次</strong>
</div>
<p v-if="!Object.keys(store.summary?.feedingMethodCounts || {}).length" class="empty">暂无喂奶记录。</p>
</section>
</section>
</template>
+43
View File
@@ -0,0 +1,43 @@
<script setup lang="ts">
import { onMounted } from 'vue'
import { deleteRecord } from '../api/client'
import { useCareStore } from '../stores/careStore'
import { formatMinutes, formatTime, recordLabel } from '../utils/format'
const store = useCareStore()
onMounted(() => {
store.load()
})
async function remove(recordId: string) {
await deleteRecord(recordId)
await store.refreshSummary()
}
</script>
<template>
<section class="page">
<header class="page-header">
<p class="eyebrow">今日记录</p>
<h1>照护流水</h1>
</header>
<div class="timeline">
<article v-for="record in store.summary?.timeline || []" :key="record.recordId" class="timeline-item">
<div>
<strong>{{ recordLabel(record.recordType, record.feedingMethod || record.excretionType) }}</strong>
<p>
{{ formatTime(record.startTime) }}
<span v-if="record.durationMinutes"> · {{ formatMinutes(record.durationMinutes) }}</span>
<span v-if="record.amountMl"> · {{ record.amountMl }}ml</span>
</p>
<small>{{ record.operatorName }}</small>
</div>
<button class="text-button" @click="remove(record.recordId)">删除</button>
</article>
<p v-if="!store.summary?.timeline?.length" class="empty">今天还没有记录。</p>
</div>
</section>
</template>
+180
View File
@@ -0,0 +1,180 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { showToast } from 'vant'
import { useCareStore } from '../stores/careStore'
import { formatMinutes, formatTime } from '../utils/format'
const store = useCareStore()
const bottleAmount = ref(30)
const breastSide = ref<'left' | 'right'>('left')
const babyOptions = computed(() => store.babies.map(baby => ({
text: `${baby.name} · ${baby.ageText}`,
value: baby.babyId
})))
const memberOptions = computed(() => store.members.map(member => ({
text: member.roleName,
value: member.roleName
})))
const activeFeedingText = computed(() => {
const active = store.summary?.activeFeeding
return active ? `亲喂中 · ${formatTime(active.startTime)}` : '未计时'
})
onMounted(() => {
store.load()
})
async function runWithTip(action: () => Promise<void>, message: string) {
await action()
showToast({ message, type: 'success', duration: 1400 })
}
</script>
<template>
<section class="page">
<header class="hero clean-hero">
<div>
<p class="eyebrow">{{ store.context?.family.name || '新生儿照护家庭' }}</p>
<h1>{{ store.baby?.name || '宝宝' }}</h1>
<p>{{ store.baby?.ageText || '出生第 3 天' }} · {{ store.operatorName }}记录中</p>
</div>
</header>
<p v-if="store.error" class="notice error">{{ store.error }}</p>
<p v-if="store.loading" class="notice">正在加载今日记录...</p>
<section class="context-panel">
<van-dropdown-menu>
<van-dropdown-item
:model-value="store.baby?.babyId"
:options="babyOptions"
title="宝宝"
@update:model-value="value => store.selectBaby(String(value))"
/>
<van-dropdown-item
:model-value="store.operatorName"
:options="memberOptions"
title="记录人"
@update:model-value="value => store.setOperatorName(String(value))"
/>
</van-dropdown-menu>
</section>
<section class="summary-grid">
<article class="metric-card">
<span>喂奶</span>
<strong>{{ store.summary?.feedingCount ?? 0 }}</strong>
<small>今日次数</small>
</article>
<article class="metric-card">
<span>睡眠</span>
<strong>{{ formatMinutes(store.summary?.sleepTotalMinutes ?? 0) }}</strong>
<small>累计时长</small>
</article>
<article class="metric-card">
<span>小便</span>
<strong>{{ store.summary?.peeCount ?? 0 }}</strong>
<small>今日次数</small>
</article>
<article class="metric-card">
<span>大便</span>
<strong>{{ store.summary?.poopCount ?? 0 }}</strong>
<small>今日次数</small>
</article>
</section>
<section class="panel">
<div class="panel-title">
<h2>亲喂</h2>
<p>可以计时,也可以一键记录,之后再补调时间。</p>
</div>
<van-segmented v-model="breastSide" :options="[
{ label: '左侧', value: 'left' },
{ label: '右侧', value: 'right' }
]" />
<div class="feeding-status">
<span>{{ activeFeedingText }}</span>
<strong v-if="store.summary?.activeFeeding">{{ breastSide === 'left' ? '左侧' : '右侧' }}</strong>
</div>
<div class="two-actions">
<van-button
block
round
type="primary"
@click="runWithTip(() => store.toggleBreastfeedTimer(breastSide), store.summary?.activeFeeding ? '已结束本次亲喂,辛苦啦' : '已开始亲喂计时')"
>
{{ store.summary?.activeFeeding ? '结束亲喂' : '开始亲喂' }}
</van-button>
<van-button
block
round
plain
type="primary"
@click="runWithTip(() => store.logFeeding('breastfeed', undefined, breastSide), '已记录一次亲喂')"
>
一键记录
</van-button>
</div>
</section>
<section class="panel">
<div class="panel-title">
<h2>瓶喂</h2>
<p>奶量可调整,默认按当前数值记录。</p>
</div>
<div class="amount-row">
<span>奶量</span>
<van-stepper v-model="bottleAmount" :min="5" :max="300" :step="5" integer />
<strong>{{ bottleAmount }} ml</strong>
</div>
<van-button
block
round
type="success"
@click="runWithTip(() => store.logFeeding('bottle', bottleAmount), `已记录瓶喂 ${bottleAmount}ml`)"
>
记录瓶喂
</van-button>
</section>
<section class="panel">
<div class="panel-title">
<h2>快速记录</h2>
<p>尿尿、便便和睡眠优先保证动作清晰。</p>
</div>
<div class="action-grid compact-actions">
<button class="primary-action sleep" @click="runWithTip(() => store.toggleSleep(), store.summary?.activeSleep ? '已结束睡眠记录' : '已开始睡眠记录')">
<strong>{{ store.summary?.activeSleep ? '结束睡眠' : '开始睡眠' }}</strong>
<span>{{ store.summary?.activeSleep ? '自动计算时长' : '宝宝睡下了' }}</span>
</button>
<button class="primary-action pee" @click="runWithTip(() => store.logPee(), '已记录一次小便')">
<strong>小便</strong>
<span>记录一次</span>
</button>
<button class="primary-action poop" @click="runWithTip(() => store.logPoop(), '已记录一次大便')">
<strong>大便</strong>
<span>记录一次</span>
</button>
</div>
</section>
<section class="panel">
<div class="panel-title">
<h2>最近状态</h2>
</div>
<div class="status-list">
<div>
<span>上次喂奶</span>
<strong>{{ formatTime(store.summary?.lastFeeding?.startTime) }}</strong>
</div>
<div>
<span>睡眠状态</span>
<strong>{{ store.summary?.activeSleep ? `睡眠中 · ${formatTime(store.summary.activeSleep.startTime)}` : '清醒中' }}</strong>
</div>
</div>
</section>
</section>
</template>
+17
View File
@@ -0,0 +1,17 @@
import { createRouter, createWebHistory } from 'vue-router'
import TodayPage from './pages/TodayPage.vue'
import TimelinePage from './pages/TimelinePage.vue'
import StatsPage from './pages/StatsPage.vue'
import SettingsPage from './pages/SettingsPage.vue'
export default createRouter({
history: createWebHistory(),
routes: [
{ path: '/', redirect: '/today' },
{ path: '/today', component: TodayPage },
{ path: '/timeline', component: TimelinePage },
{ path: '/stats', component: StatsPage },
{ path: '/settings', component: SettingsPage }
]
})
+111
View File
@@ -0,0 +1,111 @@
import { defineStore } from 'pinia'
import {
createFeeding,
createPee,
createPoop,
endFeeding,
endSleep,
getFamilyContext,
getDailySummary,
startFeeding,
updateBaby,
startSleep,
updateCurrentBaby
} from '../api/client'
import type { BabyProfile, DailySummary, FamilyContext, FamilyMember, FeedingMethod } from '../types/domain'
export const useCareStore = defineStore('care', {
state: () => ({
context: null as FamilyContext | null,
babies: [] as BabyProfile[],
members: [] as FamilyMember[],
selectedBabyId: localStorage.getItem('selectedBabyId') || '',
baby: null as BabyProfile | null,
summary: null as DailySummary | null,
operatorName: localStorage.getItem('operatorName') || '宝妈',
loading: false,
error: ''
}),
actions: {
async load() {
this.loading = true
this.error = ''
try {
this.context = await getFamilyContext()
this.babies = this.context.babies
this.members = this.context.members
if (!this.selectedBabyId && this.babies[0]) {
this.selectedBabyId = this.babies[0].babyId
}
const selected = this.babies.find(baby => baby.babyId === this.selectedBabyId) || this.babies[0]
this.baby = selected || null
if (this.baby) {
localStorage.setItem('selectedBabyId', this.baby.babyId)
this.summary = await getDailySummary(this.baby.babyId)
}
} catch (error) {
this.error = error instanceof Error ? error.message : '加载失败'
} finally {
this.loading = false
}
},
async refreshSummary() {
if (!this.baby) return
this.summary = await getDailySummary(this.baby.babyId)
},
async selectBaby(babyId: string) {
this.selectedBabyId = babyId
localStorage.setItem('selectedBabyId', babyId)
this.baby = this.babies.find(baby => baby.babyId === babyId) || this.baby
await this.refreshSummary()
},
setOperatorName(name: string) {
this.operatorName = name || '宝妈'
localStorage.setItem('operatorName', this.operatorName)
},
async saveBaby(payload: Pick<BabyProfile, 'name' | 'gender' | 'birthDate' | 'deliveryType'>) {
this.baby = this.baby ? await updateBaby(this.baby.babyId, payload) : await updateCurrentBaby(payload)
this.babies = this.babies.map(baby => baby.babyId === this.baby?.babyId ? this.baby : baby)
await this.refreshSummary()
},
async logFeeding(method: FeedingMethod, amountMl?: number, breastSide?: 'left' | 'right') {
if (!this.baby) return
await createFeeding({
babyId: this.baby.babyId,
feedingMethod: method,
amountMl,
breastSide,
operatorName: this.operatorName
})
await this.refreshSummary()
},
async toggleBreastfeedTimer(breastSide: 'left' | 'right') {
if (!this.baby) return
if (this.summary?.activeFeeding) {
await endFeeding({ babyId: this.baby.babyId, breastSide, operatorName: this.operatorName })
} else {
await startFeeding({ babyId: this.baby.babyId, breastSide, operatorName: this.operatorName })
}
await this.refreshSummary()
},
async toggleSleep() {
if (!this.baby) return
if (this.summary?.activeSleep) {
await endSleep({ babyId: this.baby.babyId, operatorName: this.operatorName })
} else {
await startSleep({ babyId: this.baby.babyId, operatorName: this.operatorName })
}
await this.refreshSummary()
},
async logPee() {
if (!this.baby) return
await createPee({ babyId: this.baby.babyId, operatorName: this.operatorName })
await this.refreshSummary()
},
async logPoop() {
if (!this.baby) return
await createPoop({ babyId: this.baby.babyId, operatorName: this.operatorName })
await this.refreshSummary()
}
}
})
+386
View File
@@ -0,0 +1,386 @@
:root {
color: #1f2933;
background: #f6f5f2;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
}
button,
input,
select {
font: inherit;
}
button {
border: 0;
}
.app-shell {
min-height: 100vh;
max-width: 880px;
margin: 0 auto;
background: #fffdfa;
}
.app-main {
min-height: 100vh;
padding-bottom: 84px;
}
.page {
padding: 18px;
}
.hero {
display: flex;
justify-content: space-between;
gap: 16px;
padding: 22px;
border-radius: 24px;
background: linear-gradient(135deg, #fff4da, #e9f7f1);
border: 1px solid #efe3ca;
}
.clean-hero {
border-radius: 8px;
}
.hero h1,
.page-header h1 {
margin: 4px 0;
font-size: 28px;
}
.hero p,
.page-header p,
.panel-title p {
margin: 0;
color: #65707d;
}
.eyebrow {
font-size: 12px;
font-weight: 800;
color: #aa6b18;
}
.operator-pill {
align-self: flex-start;
padding: 8px 12px;
border-radius: 999px;
background: white;
font-weight: 800;
}
.context-panel {
margin: 12px 0 16px;
overflow: hidden;
border: 1px solid #ebe4d8;
border-radius: 8px;
background: white;
}
.summary-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
margin: 16px 0;
}
.metric-card,
.panel {
border: 1px solid #ebe4d8;
border-radius: 18px;
background: white;
box-shadow: 0 10px 28px rgba(80, 64, 43, 0.06);
}
.metric-card {
padding: 16px;
}
.metric-card span,
.metric-card small,
.status-list span,
.stat-row span {
color: #65707d;
}
.metric-card strong {
display: block;
margin: 8px 0 2px;
font-size: 24px;
}
.panel {
margin-top: 14px;
padding: 16px;
}
.panel,
.metric-card {
border-radius: 8px;
}
.panel-title {
margin-bottom: 12px;
}
.panel-title h2 {
margin: 0 0 4px;
font-size: 18px;
}
.action-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
}
.compact-actions {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.primary-action {
min-height: 92px;
padding: 14px;
border-radius: 8px;
text-align: left;
color: #17202a;
}
.primary-action strong {
display: block;
font-size: 20px;
}
.primary-action span {
display: block;
margin-top: 4px;
}
.feeding {
background: #fff1cf;
}
.sleep {
background: #eee9ff;
}
.pee {
background: #dff4ff;
}
.poop {
background: #e8f7df;
}
.status-list,
.settings-list,
.stat-row,
.timeline-item {
display: flex;
justify-content: space-between;
gap: 12px;
padding: 12px 0;
border-bottom: 1px solid #f0ece5;
}
.status-list {
display: grid;
}
.settings-list {
display: grid;
}
.settings-list div {
display: flex;
justify-content: space-between;
gap: 12px;
padding: 12px 0;
border-bottom: 1px solid #f0ece5;
}
.settings-list div:last-child {
border-bottom: 0;
}
.settings-list span {
color: #65707d;
}
.settings-list strong {
text-align: right;
}
.feeding-status,
.amount-row,
.two-actions {
display: grid;
gap: 10px;
margin-top: 12px;
}
.feeding-status,
.amount-row {
grid-template-columns: 1fr auto auto;
align-items: center;
padding: 12px;
border-radius: 8px;
background: #faf7f1;
}
.feeding-status span,
.amount-row span {
color: #65707d;
}
.two-actions {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.timeline-item:last-child,
.stat-row:last-child {
border-bottom: 0;
}
.timeline-item p,
.timeline-item small {
margin: 4px 0 0;
color: #65707d;
}
.page-header {
margin-bottom: 18px;
}
.bottom-nav {
position: fixed;
left: 50%;
bottom: 0;
width: min(880px, 100%);
transform: translateX(-50%);
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 6px;
padding: 10px 14px max(10px, env(safe-area-inset-bottom));
background: rgba(255, 253, 250, 0.96);
border-top: 1px solid #e7ded0;
backdrop-filter: blur(16px);
}
.bottom-nav__item {
padding: 10px;
border-radius: 14px;
color: #65707d;
text-align: center;
text-decoration: none;
font-weight: 800;
}
.bottom-nav__item.router-link-active {
color: #8a540d;
background: #fff1cf;
}
.notice {
padding: 10px 12px;
border-radius: 12px;
background: #eef6ff;
}
.notice.error {
background: #fff0f0;
color: #b42318;
}
.empty {
color: #65707d;
text-align: center;
}
.text-button {
align-self: center;
background: #fff0f0;
color: #b42318;
border-radius: 999px;
padding: 8px 12px;
font-weight: 800;
}
.form-panel {
display: grid;
gap: 14px;
}
.form-panel label {
display: grid;
gap: 6px;
color: #65707d;
font-weight: 800;
}
.form-panel input,
.form-panel select {
width: 100%;
border: 1px solid #ded6c8;
border-radius: 8px;
padding: 12px;
background: #fffdfa;
color: #1f2933;
}
.save-button {
padding: 14px;
border-radius: 14px;
background: #1f7a5c;
color: white;
font-weight: 900;
}
@media (min-width: 720px) {
.summary-grid {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
.action-grid {
grid-template-columns: repeat(5, minmax(0, 1fr));
}
.compact-actions {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
@media (max-width: 420px) {
.page {
padding: 12px;
}
.hero {
padding: 18px;
}
.hero h1,
.page-header h1 {
font-size: 24px;
}
.compact-actions,
.two-actions {
grid-template-columns: 1fr;
}
.feeding-status,
.amount-row {
grid-template-columns: 1fr;
}
}
+74
View File
@@ -0,0 +1,74 @@
export type FeedingMethod = 'breastfeed' | 'bottle' | 'formula' | 'mixed' | 'other'
export type RecordType = 'feeding' | 'sleep' | 'excretion'
export type ExcretionType = 'pee' | 'poop'
export interface BabyProfile {
babyId: string
familyId: string
name: string
gender: string
birthDate: string
deliveryType: string
ageDays: number
ageText: string
}
export interface FamilyInfo {
familyId: string
name: string
inviteCode?: string | null
}
export interface FamilyMember {
memberId: string
familyId: string
userId?: string | null
roleName: string
roleType: string
defaultOperator: boolean
}
export interface FamilyContext {
family: FamilyInfo
babies: BabyProfile[]
members: FamilyMember[]
}
export interface CareRecord {
recordId: string
familyId: string
babyId: string
recordType: RecordType
startTime: string
endTime?: string | null
durationMinutes?: number | null
feedingMethod?: FeedingMethod | null
amountMl?: number | null
excretionType?: ExcretionType | null
operatorName: string
note?: string | null
createdAt: string
}
export interface DailySummary {
babyId: string
date: string
feedingCount: number
feedingMethodCounts: Record<string, number>
sleepTotalMinutes: number
peeCount: number
poopCount: number
lastFeeding?: CareRecord | null
activeFeeding?: CareRecord | null
activeSleep?: CareRecord | null
timeline: CareRecord[]
}
export interface ApiResponse<T> {
success: boolean
data: T
error?: {
code: string
message: string
}
}
+31
View File
@@ -0,0 +1,31 @@
export function formatTime(value?: string | null) {
if (!value) return '--'
const date = new Date(value)
return `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`
}
export function formatMinutes(minutes: number) {
const h = Math.floor(minutes / 60)
const m = minutes % 60
if (h <= 0) return `${m} 分钟`
if (m === 0) return `${h} 小时`
return `${h} 小时 ${m} 分钟`
}
export function recordLabel(type: string, sub?: string | null) {
if (type === 'feeding') {
const map: Record<string, string> = {
breastfeed: '亲喂',
bottle: '瓶喂',
formula: '配方奶',
mixed: '混合',
other: '其他'
}
return `喂奶 · ${map[sub || 'other'] || '其他'}`
}
if (type === 'sleep') return '睡眠'
if (type === 'excretion' && sub === 'pee') return '小便'
if (type === 'excretion' && sub === 'poop') return '大便'
return '记录'
}