Files
nj/docs/opendesign/screens/mood-tracker.html
iven b320641d9c
Some checks failed
Main Merge / backend (push) Has been cancelled
Main Merge / frontend (push) Has been cancelled
fix(app): 全链路验证修复 — 编译错误/CORS/迁移/启动脚本
前端修复:
- calendar_page: 移除不存在的 JournalEntry.content getter
- responsive_scaffold: 移除不存在的 notchThickness 参数
- splash_page: SingleTickerProvider → TickerProvider (多 AnimationController)
- profile_page: UserRoleType.name → .code (修复运行时崩溃)
- 导入缺失的 user.dart

后端修复:
- class_service: generate_class_code 取 UUID 后6位(随机部分)避免碰撞
- diary_role_seed: 移除不存在的 id 列,使用复合主键 ON CONFLICT

基础设施:
- config/default.toml: CORS 改为通配符(开发模式)
- scripts/dev.sh: 统一启动脚本(自动清理端口)
- docs/opendesign/: Open Design 设计规格 HTML 原型稿

验证结果: flutter analyze 0 error, cargo test 77/77 通过, 17个页面全部渲染正常
2026-06-02 01:03:58 +08:00

434 lines
14 KiB
HTML

<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=390, height=844, initial-scale=1, viewport-fit=cover">
<title>暖记 — 心情追踪</title>
<link href="https://fonts.googleapis.com/css2?family=Caveat:wght@400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../css/tokens.css">
<link rel="stylesheet" href="../css/components.css">
<style>
body {
width: 390px;
height: 844px;
overflow: hidden;
background: var(--bg);
position: relative;
}
/* Global focus styles */
button:focus-visible, a:focus-visible, [role="tab"]:focus-visible {
box-shadow: 0 0 0 3px var(--focus-ring);
outline: none;
}
.content-area {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: calc(var(--tab-height) + var(--safe-bottom));
overflow-y: auto;
padding: 0 var(--space-5);
padding-top: calc(var(--safe-top) + var(--space-2));
scrollbar-width: none;
}
.content-area::-webkit-scrollbar { display: none; }
.page-title {
font-family: var(--font-display);
font-size: var(--text-2xl);
font-weight: 700;
margin-bottom: var(--space-5);
}
/* Today mood card */
.today-mood-card {
background: linear-gradient(135deg, var(--accent), var(--tertiary));
border-radius: var(--radius-lg);
padding: var(--space-6);
margin-bottom: var(--space-5);
position: relative;
overflow: hidden;
}
.today-mood-card::before {
content: '';
position: absolute;
top: -20px;
right: -20px;
width: 100px;
height: 100px;
border-radius: 50%;
background: rgba(255,255,255,0.12);
}
.today-mood-card .label {
font-size: var(--text-sm);
color: rgba(255,248,240,0.85);
margin-bottom: var(--space-2);
}
.today-mood-card .big-mood {
font-size: 52px;
margin: var(--space-3) 0;
}
.today-mood-card .mood-text {
font-family: var(--font-display);
font-size: var(--text-xl);
font-weight: 700;
color: var(--accent-on);
margin-bottom: var(--space-1);
}
.today-mood-card .mood-sub {
font-size: var(--text-sm);
color: rgba(255,248,240,0.75);
}
/* Weather card */
.weather-card {
background: var(--surface);
border-radius: var(--radius-md);
padding: var(--space-5);
margin-bottom: var(--space-5);
box-shadow: var(--elev-soft);
border: 1px solid var(--border-soft);
}
.weather-card h4 {
font-family: var(--font-display);
font-size: var(--text-base);
font-weight: 600;
margin-bottom: var(--space-4);
}
.weather-row {
display: flex;
gap: var(--space-3);
}
.weather-opt {
flex: 1;
aspect-ratio: 1;
border-radius: var(--radius-md);
border: 2px solid var(--border);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 4px;
background: var(--surface);
cursor: pointer;
transition: all var(--motion-fast) var(--ease-bounce);
font-size: 28px;
min-width: 44px;
min-height: 44px;
}
.weather-opt span {
font-size: 11px;
color: var(--muted);
}
.weather-opt.selected {
border-color: var(--accent);
background: var(--surface-warm);
}
.weather-opt.selected span { color: var(--accent); font-weight: 600; }
.weather-opt:hover { transform: scale(1.05); }
/* Mood history chart */
.mood-chart-card {
background: var(--surface);
border-radius: var(--radius-md);
padding: var(--space-5);
margin-bottom: var(--space-5);
box-shadow: var(--elev-soft);
border: 1px solid var(--border-soft);
}
.mood-chart-card h4 {
font-family: var(--font-display);
font-size: var(--text-base);
font-weight: 600;
margin-bottom: var(--space-4);
}
.chart-period {
display: flex;
gap: var(--space-2);
margin-bottom: var(--space-5);
}
.period-btn {
padding: 6px 16px;
min-height: 44px;
border-radius: var(--radius-pill);
border: none;
font-size: var(--text-sm);
font-weight: 500;
background: var(--surface-warm);
color: var(--fg-2);
cursor: pointer;
transition: all var(--motion-fast);
}
.period-btn.active { background: var(--accent); color: var(--accent-on); }
/* Simple line chart visualization */
.mood-line-chart {
height: 120px;
display: flex;
align-items: flex-end;
gap: 3px;
margin-bottom: var(--space-4);
padding-bottom: 24px;
position: relative;
}
.mood-line-chart::after {
content: '';
position: absolute;
bottom: 20px;
left: 0;
right: 0;
height: 1px;
background: var(--border-soft);
}
.chart-bar {
flex: 1;
max-width: 14px;
border-radius: 7px 7px 0 0;
position: relative;
transition: height var(--motion-base) var(--ease-bounce);
cursor: pointer;
}
.chart-bar:hover { opacity: 0.8; }
.chart-bar .tooltip {
position: absolute;
bottom: calc(100% + 8px);
left: 50%;
transform: translateX(-50%);
background: var(--fg);
color: white;
font-size: 11px;
padding: 4px 8px;
border-radius: 6px;
white-space: nowrap;
opacity: 0;
pointer-events: none;
transition: opacity var(--motion-fast);
}
.chart-bar:hover .tooltip { opacity: 1; }
.chart-date {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
font-size: 9px;
color: var(--meta);
white-space: nowrap;
}
/* Stats grid */
.stats-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: var(--space-3);
margin-bottom: var(--space-5);
}
.stat-item {
background: var(--surface);
border-radius: var(--radius-md);
padding: var(--space-4);
box-shadow: var(--elev-soft);
border: 1px solid var(--border-soft);
text-align: center;
}
.stat-item .icon { font-size: 28px; margin-bottom: var(--space-2); }
.stat-item .value {
font-family: var(--font-display);
font-size: var(--text-xl);
font-weight: 700;
color: var(--fg);
}
.stat-item .desc {
font-size: var(--text-xs);
color: var(--muted);
margin-top: 2px;
}
/* Mood insights */
.insight-card {
background: var(--surface);
border-radius: var(--radius-md);
padding: var(--space-5);
margin-bottom: var(--space-5);
box-shadow: var(--elev-soft);
border: 1px solid var(--border-soft);
}
.insight-card h4 {
font-family: var(--font-display);
font-size: var(--text-base);
font-weight: 600;
margin-bottom: var(--space-4);
}
.insight-item {
display: flex;
align-items: center;
gap: var(--space-3);
padding: var(--space-3) 0;
border-bottom: 1px solid var(--border-soft);
}
.insight-item:last-child { border-bottom: none; }
.insight-icon {
width: 36px;
height: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
flex-shrink: 0;
}
.insight-text {
flex: 1;
}
.insight-text .title {
font-size: var(--text-sm);
font-weight: 600;
color: var(--fg);
margin-bottom: 2px;
}
.insight-text .detail {
font-size: var(--text-xs);
color: var(--muted);
}
.insight-badge {
padding: 4px 10px;
border-radius: var(--radius-pill);
font-size: 11px;
font-weight: 600;
}
</style>
</head>
<body>
<div class="content-area">
<div class="page-title anim-fade">心情与天气</div>
<!-- Today's mood - using standardized mood: happy -->
<div class="today-mood-card anim-slide" style="animation-delay: 0.1s">
<div class="label">今日心情 · 5月31日</div>
<div class="big-mood">😊</div>
<div class="mood-text">开心的一天</div>
<div class="mood-sub">在图书馆享受了安静的午后时光</div>
</div>
<!-- Weather -->
<div class="weather-card anim-fade" style="animation-delay: 0.15s">
<h4>今日天气</h4>
<div class="weather-row">
<button class="weather-opt selected" aria-label="晴天">☀️<span>晴天</span></button>
<button class="weather-opt" aria-label="多云"><span>多云</span></button>
<button class="weather-opt" aria-label="下雨">🌧<span>下雨</span></button>
<button class="weather-opt" aria-label="下雪">❄️<span>下雪</span></button>
<button class="weather-opt" aria-label="有风">🍃<span>有风</span></button>
</div>
</div>
<!-- Mood chart - using standardized 5 moods -->
<div class="mood-chart-card anim-fade" style="animation-delay: 0.2s">
<h4>心情趋势</h4>
<div class="chart-period">
<button class="period-btn active" aria-label="近7天">近7天</button>
<button class="period-btn" aria-label="近30天">近30天</button>
<button class="period-btn" aria-label="近3月">近3月</button>
</div>
<div class="mood-line-chart">
<div class="chart-bar" style="height:70%;background:var(--secondary)"><div class="tooltip">😊 开心</div><span class="chart-date">25日</span></div>
<div class="chart-bar" style="height:50%;background:var(--tertiary)"><div class="tooltip">😐 平静</div><span class="chart-date">26日</span></div>
<div class="chart-bar" style="height:85%;background:var(--secondary)"><div class="tooltip">😊 开心</div><span class="chart-date">27日</span></div>
<div class="chart-bar" style="height:75%;background:var(--secondary)"><div class="tooltip">😊 开心</div><span class="chart-date">28日</span></div>
<div class="chart-bar" style="height:90%;background:var(--secondary)"><div class="tooltip">😊 开心</div><span class="chart-date">29日</span></div>
<div class="chart-bar" style="height:65%;background:var(--secondary)"><div class="tooltip">😊 开心</div><span class="chart-date">30日</span></div>
<div class="chart-bar" style="height:88%;background:var(--secondary)"><div class="tooltip">😊 开心</div><span class="chart-date">31日</span></div>
</div>
</div>
<!-- Stats -->
<div class="stats-grid anim-fade" style="animation-delay: 0.25s">
<div class="stat-item">
<div class="icon">😊</div>
<div class="value">72%</div>
<div class="desc">本月好心情占比</div>
</div>
<div class="stat-item">
<div class="icon">🔥</div>
<div class="value">12天</div>
<div class="desc">最长连续记录</div>
</div>
<div class="stat-item">
<div class="icon">☀️</div>
<div class="value">18天</div>
<div class="desc">晴天记录次数</div>
</div>
<div class="stat-item">
<div class="icon">📝</div>
<div class="value">28篇</div>
<div class="desc">本月日记篇数</div>
</div>
</div>
<!-- Insights -->
<div class="insight-card anim-fade" style="animation-delay: 0.3s">
<h4>心情洞察</h4>
<div class="insight-item">
<div class="insight-icon" style="background: var(--secondary-soft)">🌟</div>
<div class="insight-text">
<div class="title">最佳心情日</div>
<div class="detail">5月14日 — 和朋友聚餐的日子</div>
</div>
<div class="insight-badge" style="background:var(--secondary-soft);color:#2D7D46">开心</div>
</div>
<div class="insight-item">
<div class="insight-icon" style="background: var(--tertiary-soft)">💡</div>
<div class="insight-text">
<div class="title">开心触发因素</div>
<div class="detail">你的好心情常与「朋友」「美食」「学习」相关</div>
</div>
</div>
<div class="insight-item">
<div class="insight-icon" style="background: var(--rose-soft)">📊</div>
<div class="insight-text">
<div class="title">心情较上月提升</div>
<div class="detail">好心情天数增加了 15%</div>
</div>
<div class="insight-badge" style="background:var(--secondary-soft);color:#2D7D46">+15%</div>
</div>
</div>
<div style="height: var(--space-8)"></div>
</div>
<!-- Tab bar -->
<nav class="tab-bar" role="tablist">
<button class="tab-item" role="tab" aria-label="首页" aria-selected="false">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>
<span>首页</span>
</button>
<button class="tab-item" role="tab" aria-label="日历" aria-selected="false">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>
<span>日历</span>
</button>
<button class="tab-item" role="tab" aria-label="写日记" aria-selected="false" style="position:relative">
<div style="width:44px;height:44px;border-radius:50%;background:var(--accent);display:flex;align-items:center;justify-content:center;margin-top:-16px;box-shadow:0 4px 12px var(--shadow-accent)">
<svg viewBox="0 0 24 24" fill="none" stroke="var(--accent-on)" stroke-width="2.5" stroke-linecap="round" style="width:22px;height:22px" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>
</div>
<span style="margin-top:2px">写日记</span>
</button>
<button class="tab-item" role="tab" aria-label="发现" aria-selected="false">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
<span>发现</span>
</button>
<button class="tab-item active" role="tab" aria-label="我的" aria-selected="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
<span>我的</span>
</button>
</nav>
<div class="dynamic-island" aria-hidden="true"></div>
<div class="home-indicator" style="position:absolute;bottom:8px;left:50%;transform:translateX(-50%);z-index:101" aria-hidden="true"></div>
<script src="../js/theme-switcher.js"></script>
</body>
</html>