Add dynamic homepage study guidance

This commit is contained in:
Codex committed 2026-09-17 12:49:43 +08:00
1 parent 310087ad84
commit f752add369
2 files changed
+8

No files matched your search

+7
View File
@@ -32,6 +32,12 @@ export default function CheckinClient() {
const dates = Array.from({ length }, (_, i) => "2026-" + String(month + 1).padStart(2, "0") + "-" + String(i + 1).padStart(2, "0"));
const seconds = Math.max(0, Math.floor((new Date("2026-12-12T15:00:00+08:00").getTime() - now) / 1000));
const remaining = { days: Math.floor(seconds / 86400), hours: Math.floor(seconds % 86400 / 3600), minutes: Math.floor(seconds % 3600 / 60) };
const localHour = Number(new Intl.DateTimeFormat("en-US", { hour: "2-digit", hourCycle: "h23", timeZone: "Asia/Shanghai" }).format(new Date(now)));
const greeting = localHour < 6 ? "夜深了,今天不必追赶进度,稳稳完成一件事就很好。" : localHour < 11 ? "早上好,先从最清晰的一项开始,把节奏带起来。" : localHour < 18 ? "下午好,接着把计划往前推进,专注下一步就够了。" : "晚上好,给今天留一次扎实的收尾,让明天更轻松。";
const taskNarrative = day.tasks.map(task => task.text).join(",接着");
const countdownNarrative = remaining.days > 60 ? `距离六级笔试还有 ${remaining.days} 天,现在最重要的是把每天的复习节奏走稳。` : remaining.days > 30 ? `距离六级笔试还有 ${remaining.days} 天,该让专项练习更有针对性了。` : remaining.days > 14 ? `距离六级笔试还有 ${remaining.days} 天,真题和时间分配会成为接下来的重点。` : remaining.days > 7 ? `距离六级笔试还有 ${remaining.days} 天,开始把易错点收拢成自己的清单。` : remaining.days > 0 ? `距离六级笔试只剩 ${remaining.days} 天,保持手感、相信已完成的积累。` : "考试日已到,按自己的节奏完成最后准备。";
const progressNarrative = done.length === day.tasks.length ? "今天的清单已经全部完成,可以安心收尾。" : done.length === 0 ? "今天还没有开始,先完成第一项就已经在前进。" : `你已经完成 ${done.length} 项,还剩 ${day.tasks.length - done.length} 项。`;
const smartTip = `${greeting}${countdownNarrative}${isToday ? "今天" : `你正在查看 ${fmt(day.date)},当天`}的安排是:${taskNarrative}。${progressNarrative}`;
useEffect(() => { const id = window.setInterval(() => setNow(Date.now()), 30000); return () => window.clearInterval(id); }, []);
useEffect(() => { const today = new Intl.DateTimeFormat("en-CA", { timeZone: "Asia/Shanghai" }).format(new Date()); if (localStorage.getItem("cet6-countdown-notice") !== today) setShowCountdown(true); }, []);
@@ -42,6 +48,7 @@ export default function CheckinClient() {
const closeCountdown = () => { const today = new Intl.DateTimeFormat("en-CA", { timeZone: "Asia/Shanghai" }).format(new Date()); localStorage.setItem("cet6-countdown-notice", today); setShowCountdown(false); };
return <main><Dialog open={showCountdown} onOpenChange={open => { if (!open) closeCountdown(); }}><DialogContent className="countdown-dialog" showCloseButton={false}><DialogHeader><p className="dialog-kicker">CET-6 · 考试倒计时</p><DialogTitle>今天也离目标更近一步</DialogTitle><DialogDescription>2026 年 12 月 12 日 15:00 笔试</DialogDescription></DialogHeader><div className="dialog-time"><b>{remaining.days}</b><span>天</span><b>{String(remaining.hours).padStart(2, "0")}</b><span>时</span><b>{String(remaining.minutes).padStart(2, "0")}</b><span>分</span></div><p className="dialog-note">今天的任务,完成一项就是一次推进。</p><button className="dialog-button" onClick={closeCountdown}>开始今天的打卡</button></DialogContent></Dialog><div className="shell">
<header><div><p className="eyebrow">CET-6 · 2026</p><h1>大学英语六级 · 90天打卡</h1><p className="sub">从今天的一件事开始,完成比完美重要。</p></div><div className="header-actions"><a className="overview-link" href="/tasks"><LayoutList size={17} />任务总览</a><a className="overview-link" href="/stats"><BarChart3 size={17} />数据统计</a><a className="overview-link" href="/review">复盘与冲刺</a><p className="sync"><Cloud size={16} />{saving ? "正在云端保存…" : status}</p></div></header>
<section className="smart-tip" aria-live="polite"><div><p className="eyebrow">TODAY'S NOTE</p><h2>今天怎么推进</h2></div><p>{smartTip}</p></section>
<section className="stats"><Stat icon={<CheckCircle2 />} value={Math.round(finished / total * 100) + "%"} label="总体完成度" detail={finished + " / " + total + " 项任务"} /><Stat icon={<CalendarDays />} value={complete + " 天"} label="完整完成" detail="目标共 90 天" /><Stat icon={<CheckCircle2 />} value={day.phase} label="当前阶段" detail="12 月 12 日笔试" /><div className="countdown"><span><Timer size={19} /></span><p>距离六级笔试</p><strong>{remaining.days}<em>天</em> {remaining.hours}<em>时</em> {remaining.minutes}<em>分</em></strong><small>2026 年 12 月 12 日 15:00</small></div></section>
<section className="layout"><article className="card"><div className="hero"><button className="round" aria-label="前一天" onClick={() => setSelected(n => Math.max(0, n - 1))} disabled={!selected}><ChevronLeft /></button><div><p>{day.phase} · {day.week}</p><h2>{fmt(day.date)}</h2><small>{isFuture ? "未来日期,暂不可打卡" : isMakeup ? "补打卡 · 已完成项目不可取消" : "今日打卡"} · 已完成 {done.length} / {day.tasks.length} 项</small></div><button className="round" aria-label="后一天" onClick={() => setSelected(n => Math.min(89, n + 1))} disabled={selected === 89}><ChevronRight /></button><Progress value={done.length / day.tasks.length * 100} /></div><div className="body"><div className="task-toolbar"><span>{isToday ? "正在处理今天的任务" : "正在查看 " + fmt(day.date)}</span>{!isToday && <button className="today-button" onClick={() => { setSelected(todayIndex); setMonth(new Date(plan[todayIndex].date + "T00:00:00Z").getUTCMonth()); }}>回到今天</button>}</div><div className="tasks">{day.tasks.map(t => { const locked = isFuture || (isMakeup && done.includes(t.key)); return <label className={(done.includes(t.key) ? "task done " : "task ") + (locked ? "locked" : "")} key={t.key}><Checkbox disabled={locked} checked={done.includes(t.key)} onCheckedChange={v => toggle(t.key, v === true)} /><b>{t.label}</b><span>{t.text}</span>{isMakeup && done.includes(t.key) && <small className="locked-note">已完成,已锁定</small>}</label>; })}</div><div className="review"><p>今日状态</p><div>{["专注", "平稳", "有点累", "需要调整"].map(m => <button disabled={isFuture} className={record.mood === m ? "pill active" : "pill"} key={m} onClick={() => void save({ ...record, mood: record.mood === m ? "" : m })}>{m}</button>)}</div><label>一句复盘(可选)<textarea disabled={isFuture} value={record.note} onChange={e => setRecords(x => ({ ...x, [day.date]: { ...record, note: e.target.value } }))} onBlur={() => void save(record)} placeholder={isFuture ? "未到此日期,暂不能修改。" : "今天的收获、卡住的地方,或明天要调整的一点。"} /></label></div></div></article><aside><section className="calendar side-calendar"><div className="calendar-head"><div><p className="eyebrow">CHECK-IN</p><h2>打卡日历</h2></div><div className="month-tabs">{[8, 9, 10, 11].map(m => <button aria-label={`查看${m + 1}月`} className={month === m ? "active" : ""} onClick={() => setMonth(m)} key={m}>{m + 1}月</button>)}</div></div><div className="weekdays">{["日", "一", "二", "三", "四", "五", "六"].map(x => <span key={x}>{x}</span>)}</div><div className="calendar-grid">{blanks.map((_, i) => <span key={"e" + i} />)}{dates.map(date => { const idx = plan.findIndex(p => p.date === date), p = plan[idx], n = parseTasks(records[date]?.doneTasks).length, full = !!p && n === p.tasks.length, partial = !!p && n > 0 && !full, makeup = records[date]?.checkinType === "makeup"; return <button disabled={!p} key={date} onClick={() => { if (p) { setSelected(idx); setMonth(new Date(date + "T00:00:00Z").getUTCMonth()); } }} className={"calendar-day " + (idx === selected ? "chosen " : "") + (full ? "full " : partial ? "partial " : "") + (makeup ? "makeup " : "") + (p ? "" : "outside")}><b>{Number(date.slice(-2))}</b>{p && <small>{full ? makeup ? "补打卡" : "完成" : partial ? n + "/" + p.tasks.length : date > today ? "未到" : "待打卡"}</small>}</button>; })}</div><p className="calendar-note"><i className="full-dot" />完成 <i className="partial-dot" />进行中 <i className="makeup-dot" />补打卡</p></section><div className="dark"><p>{isFuture ? "日期限制" : isMakeup ? "补打卡" : "当前阶段"}</p><h2>{isFuture ? "暂未开放" : isMakeup ? "补做未完成项目" : day.phase}</h2><p>{isFuture ? "当天到来后即可正常打卡。" : isMakeup ? "已有完成项已锁定,只能勾选此前未完成的项目。" : "每天稳步推进,答案会慢慢变得清楚。"}</p></div><div className="side"><b>90 天阶段</b>{["Ⅰ 恢复期 · 9/13–10/5", "Ⅱ 专项期 · 10/6–11/2", "Ⅲ 真题期 · 11/3–11/29", "Ⅳ 冲刺期 · 11/30–12/11"].map(x => <p key={x}>{x}</p>)}</div></aside></section>
</div></main>;
+1
View File
@@ -157,6 +157,7 @@ h1{letter-spacing:-.04em;font-size:clamp(2rem,4vw,2.85rem)}
.sync{border:1px solid #d8e5ff;box-shadow:0 8px 22px #bfdbfe88}
.overview-link{box-shadow:0 6px 16px #dbeafe99;transition:.18s transform,.18s box-shadow}
.overview-link:hover{transform:translateY(-1px);box-shadow:0 10px 22px #bfdbfe}
.smart-tip{display:grid;grid-template-columns:190px minmax(0,1fr);gap:24px;align-items:center;margin:0 0 16px;padding:20px 22px;border:1px solid #cfe0ff;border-radius:20px;background:radial-gradient(circle at 92% 12%,#cfe2ff 0,transparent 26%),linear-gradient(120deg,#edf5ff,#fff 70%);box-shadow:0 12px 28px #dbeafe80}.smart-tip h2{margin:5px 0 0;font-size:1.25rem;letter-spacing:-.025em}.smart-tip>p{margin:0;color:#334155;font-size:1rem;line-height:1.75}
.stats{gap:16px}
.stat,.countdown{border-radius:20px;box-shadow:0 12px 28px #dbeafe80}
.stat{border-color:#e0eaff;background:linear-gradient(145deg,#fff,#f9fbff)}