用户 2026-10-04 第 11 批,7 大条: - #1 首页:未来七天过滤掉「农历」(每日一条会淹掉真日程);右侧日历本标签 从灰字(.dash-tag)改成**实心色块**(底色=日历色、白字、text-shadow 兜底浅色)。 - #2 名册:分组改**居中模态框**(用户要"像选观影人一样")。修掉"点第二次失效" ——根因是旧实现用**捕获阶段**监听 document click 做"点外面就关",与触发按钮 的 click 打架;模态把关闭收敛到遮罩/✕/取消。卡片「编辑」后加「删除」 (→ people/destroy);详情页底部删除改成 btn-danger + btn-block-lg 大红按钮 + 两步确认。 - #3 名册详情页重排:.detail(260px+1fr) → .pcard(头像左上 + 右侧姓名/标签) + .detail-stack 全宽往下。旧布局头像卡比右栏矮,头像下留一大片空白。 - #4 观影:影院下拉换**自定义组件**(原生 <option> 画不了色块)——按钮+列表、 每行色点,值仍写隐藏 input[name=cinema_id];「管理影院」→「新建影院」弹框 (带 back=movies/new,存完回本页并 ?cinema=<id> 自动选中)。 修「开始/结束时间标签跑到控件下面」:upgradeRange 原来 insertBefore(host, group.firstChild) 把控件插到了 label 之上 —— 改成插在第一个原生控件之前。 - #5 裁剪改 **Cropper.js**(assets/vendor/cropper/,按需加载走 fb-cropper meta): 弹框 overflow:hidden + 固定画布(**无滚动条**)、**去掉缩放条**改滚轮 wheelZoomRatio、 viewMode:1 + autoCropArea 保证框小于画布、8 个触点全露。 结果仍写 *_crop = 归一化 x,y,w,h(提交契约不变)。 - #6 日程:内置节假日原来每天只标**一天**(国庆只出一条)→ FIXED 改成 [名字, 放假天数] 按区间铺;月视图从周日改**周一**起(表头同步); 跳转日期从"长条+原生框"改成**单个 btn-icon**,点开弹 Semi 日期选择器。 - #7 财务:单条曲线无盘点时只回一个点(图看着像全 0)→ 改成"从创建日(0)画到今天"; 图下条目从"每账目一张小图卡"改成**一张 chart_multi 多线图 + 颜色图例** (Ledger::LEGEND_COLORS 按 id 取模,保证颜色稳定);账目页卡顿同源治理 (行上只留按钮、表单全页一份 #ledPanels);修改按钮改弹框并回填归属人。 ## 顺带修的真 bug(本批最要紧的三条) 1. **观影表单提交静默失效**:「新建影院」弹框被误嵌在观影主表单 <form> 内。 HTML 不允许 form 嵌套 → 浏览器拆开内层,弹框里 required 的"影院名称"变成 主表单必填项、又因 hidden 无法聚焦 → 点「记下这场电影」什么都不发生 (Chrome: invalid form control with name='name' is not focusable)。 → 弹框移到主表单之后。部署脚本加防线:按顺序配平 form 开闭判断是否嵌套。 2. **裁剪取消没清空文件框**(换 Cropper 时丢)→ close(cancelled),4 个取消入口 传 true 清空;否则"点了取消"仍会把没裁的原图传上去。 3. **裁剪预览退化成原图**(同批丢)→ 用 canvas 按 Cropper 的原图像素矩形重画, toDataURL 写回预览,恢复"所见即所得"。 ## 连带修复:选人组件懒渲染(线上实测的必要性) 线上真实数据下账目页 6939 KB / 16788 个 input、观影表单 1194 个 input —— 根因是 _person_picker.php 首屏就把**全部候选人**渲成 <label>+<input>。 改成:首屏只留「不选」+ data-pp-people(JSON),**打开弹框时**才 buildList(); 无 JS 兜底走 <noscript>(HTML5 规定启用脚本时其内容按纯文本解析,不产生节点)。 新增 window.ppSetSelected / decorateItems(动态项要补算首字母)。 实测账目页 6939 KB → 544 KB。新增 _fb_picker_lazy_check.py(11/0 + 反向 2 红)。 验证:e2e 786/0、交互 90/0、半集成 27/0、batch_e 91/0、batch10 46/0、batch9 38/0、 crop 17/0(+反向)、picker_unify 28/0、picker_lazy 11/0(+反向)、formbloat 9/0、 upgrade 126/0、mobile 688/0、drag 5/0、geom 5/5。 线上自检 19/19;线上真实账号验收 7/0(含"主表单无隐藏必填""线上 Cropper 接管+取消清空")。
238 lines
12 KiB
PHP
238 lines
12 KiB
PHP
<?php
|
||
/**
|
||
* 首页 —— 一块 dashboard(用户 2026-10-01 第 13 条)。
|
||
*
|
||
* 用户 2026-10-03 第 3 条把它重排成:
|
||
* · hero:标题 + 个人 slogan + 两个图标按钮(我的资料 / 我的家谱)
|
||
* · 统计信息:随机问候语 + 今日天气 + 近七天日程数 / 待办数
|
||
* · 未来七天的日程(自定义 + 观影 + 旅行 + 有截止时间的任务,一次汇总)
|
||
* · 手头在做(进行中 + 已逾期的任务)
|
||
* · 各模块的统计与模块内信息(**可按人在个人设置里开关与排序**)
|
||
* · 往年今日
|
||
* ⚠️ 「接下来的日子(两个月内的生日)」已去掉:生日/纪念日本来就是日程,
|
||
* 已经在「未来七天」里,两块并排是重复。
|
||
*
|
||
* ⚠️ **家人卡片已经不在首页了**(用户明确要求):看人去「名册」、看关系去「家谱」,
|
||
* 首页留给"今天该关心什么"。统计数字仍在,因为那是唯一的全局概览。
|
||
*
|
||
* ⚠️ 标题下的那句个人口号已按用户要求撤掉(v8):hero 区只留标题与三个统计。
|
||
*/
|
||
// 生日事件上用简称,卡片才不会一行塞不下;长名字在详情页里出
|
||
$today = date('Y-m-d');
|
||
// 首页要显示哪些模块、什么顺序 —— 用户在「个人设置 → 首页上的模块」里定(每人一份)
|
||
$homeMods = array_values(array_filter(
|
||
(array)($homeModules ?? []),
|
||
static fn($k) => \App\Module::exists((string)$k)
|
||
));
|
||
?>
|
||
<?php /* 用户 2026-10-03 第 3 条:
|
||
① 标题下显示**个人 slogan**(原来撤掉了,现在要回来);
|
||
② 右侧那三块统计(与我有关 / 名册总数 / 亲属连线)**去掉**;
|
||
③ 「我的资料 / 我的家谱」保留,但从文字按钮换成**图标按钮**;
|
||
④ 「名册」按钮去掉 —— 它与顶部导航条里的「名册」重复。
|
||
⚠️ 图标用行内 SVG(不引外部字体/图片),与观影设置下拉同一套做法。 */ ?>
|
||
<section class="hero">
|
||
<img class="hero-logo" src="<?= e(asset('/assets/icons/icon-192.png')) ?>" alt="">
|
||
<div class="hero-main">
|
||
<h1><?= e(\App\Auth::homeTitle()) ?></h1>
|
||
<?php $heroSlogan = trim((string)($mySlogan ?? '')) !== ''
|
||
? (string)$mySlogan
|
||
: trim((string)($family['motto'] ?? '')); ?>
|
||
<?php if ($heroSlogan !== ''): ?>
|
||
<p class="hero-slogan"><?= e($heroSlogan) ?></p>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php /* ⚠️ 这两个链接必须带上真实的 person id:曾经 layout.php 里写
|
||
`$me = Auth::check()` 把模板里的 $me 覆盖成布尔值,链接就变成 id=0
|
||
("补充亲属关系"点进去是空白页)。所以这里显式用 $meId。 */ ?>
|
||
<div class="hero-actions">
|
||
<a class="icon-btn" href="<?= e(url('people/show', ['id' => (int)$meId])) ?>"
|
||
title="我的资料" aria-label="我的资料">
|
||
<svg viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" fill="none"
|
||
stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
|
||
<circle cx="10" cy="7" r="3.4"/><path d="M3.6 17c0-3.3 2.9-5.4 6.4-5.4s6.4 2.1 6.4 5.4"/>
|
||
</svg>
|
||
</a>
|
||
<a class="icon-btn" href="<?= e(url('kin')) ?>"
|
||
title="我的家谱" aria-label="我的家谱">
|
||
<svg viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" fill="none"
|
||
stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
|
||
<rect x="7.4" y="2.2" width="5.2" height="4.2" rx="1"/>
|
||
<rect x="2.2" y="13.6" width="5.2" height="4.2" rx="1"/>
|
||
<rect x="12.6" y="13.6" width="5.2" height="4.2" rx="1"/>
|
||
<path d="M10 6.4v3.4M4.8 13.6v-1.9h10.4v1.9M4.8 11.7h10.4"/>
|
||
</svg>
|
||
</a>
|
||
</div>
|
||
</section>
|
||
|
||
<?php /* 用户 2026-10-03 第 3 条:「接下来的日子(两个月内)」整块**去掉** ——
|
||
它列的是生日,而生日/纪念日本来就是日程,已经在下面的「未来七天」里出现过,
|
||
两块并排是重复信息。生日的"提前提醒"由日历与纪念日模块负责。 */
|
||
?>
|
||
|
||
<?php /* ==================== 统计信息(用户第 3 条) ====================
|
||
一句话问候 + 今天的天气 + 几个数字。放在最上面,因为它回答的是
|
||
"今天是个什么日子、我该关心什么"——比下面任何一个列表都更该先看到。 */ ?>
|
||
<section class="section">
|
||
<div class="card card-pad home-brief">
|
||
<div class="home-brief-hello">
|
||
<b><?= e((string)($greeting ?? '')) ?></b>
|
||
<span class="muted small"><?= e(date('n 月 j 日')) ?> <?= e((string)($weekday ?? '')) ?></span>
|
||
</div>
|
||
<?php if (!empty($weather)): ?>
|
||
<div class="home-brief-weather">
|
||
<span class="w-icon" aria-hidden="true"><?= e((string)($weather['icon'] ?? '')) ?></span>
|
||
<span class="w-temp"><?= e((string)($weather['temp'] ?? '')) ?></span>
|
||
<span class="w-desc"><?= e((string)($weather['text'] ?? '')) ?></span>
|
||
<?php if (($weather['place'] ?? '') !== ''): ?>
|
||
<span class="muted small"><?= e((string)$weather['place']) ?></span>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
<div class="home-brief-stats">
|
||
<span class="hbs"><b><?= (int)($stat7['events'] ?? 0) ?></b> 条日程(近七天)</span>
|
||
<span class="hbs"><b><?= (int)($stat7['todos'] ?? 0) ?></b> 件待办</span>
|
||
<span class="hbs"><b><?= (int)($stat7['overdue'] ?? 0) ?></b> 件逾期</span>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<?php /* ==================== 各模块统计(用户第 3 条) ====================
|
||
每个模块给一个"一眼看得懂的小结"。用户在个人设置里能挑显示哪些、以及顺序。 */ ?>
|
||
<?php if ($homeMods && !empty($moduleCards)): ?>
|
||
<section class="section">
|
||
<div class="page-head" style="margin-bottom:12px">
|
||
<h1 style="font-size:15px">家里的近况</h1>
|
||
<div class="actions">
|
||
<a class="btn btn-ghost btn-sm" href="<?= e(url('settings/me')) ?>#home-mods">调整显示</a>
|
||
</div>
|
||
</div>
|
||
<div class="mod-cards">
|
||
<?php foreach ($homeMods as $mk): ?>
|
||
<?php $mc = $moduleCards[$mk] ?? null; if (!$mc) { continue; } ?>
|
||
<a class="mod-card" href="<?= e((string)$mc['href']) ?>"
|
||
style="--mc: <?= e((string)($mc['color'] ?? '#888')) ?>">
|
||
<div class="mod-card-head">
|
||
<span class="mod-card-icon"><?= $mc['icon'] /* 行内 SVG,自己人写的,不转义 */ ?></span>
|
||
<span class="mod-card-name"><?= e((string)$mc['name']) ?></span>
|
||
</div>
|
||
<?php if (($mc['big'] ?? '') !== ''): ?>
|
||
<div class="mod-card-big"><?= e((string)$mc['big']) ?></div>
|
||
<?php endif; ?>
|
||
<?php if (!empty($mc['lines'])): ?>
|
||
<ul class="mod-card-lines">
|
||
<?php foreach ($mc['lines'] as $ln): ?>
|
||
<li><?= e((string)$ln) ?></li>
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
<?php endif; ?>
|
||
</a>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
</section>
|
||
<?php endif; ?>
|
||
|
||
<?php /* ==================== 日程(未来七天) ==================== */ ?>
|
||
<section class="section">
|
||
<div class="page-head" style="margin-bottom:12px">
|
||
<h1 style="font-size:15px">未来七天 <span class="sub">日程 · 观影 · 旅行 · 到期任务</span></h1>
|
||
<div class="actions">
|
||
<a class="btn btn-ghost btn-sm" href="<?= e(url('calendar')) ?>">看整月</a>
|
||
</div>
|
||
</div>
|
||
<?php if (!$soon): ?>
|
||
<div class="card card-pad empty"><b>这七天还没有安排</b>有事先记一笔,日后再翻才有得看。</div>
|
||
<?php else: ?>
|
||
<div class="card card-pad">
|
||
<ul class="dash-list">
|
||
<?php foreach ($soon as $ev): ?>
|
||
<li class="dash-row">
|
||
<span class="dash-dot" style="background: <?= e((string)$ev['color']) ?>;"></span>
|
||
<span class="dash-when">
|
||
<?= e((string)$ev['date'] === $today ? '今天' : substr((string)$ev['date'], 5)) ?>
|
||
<?php if (($ev['time'] ?? '') !== ''): ?><b><?= e((string)$ev['time']) ?></b><?php endif; ?>
|
||
</span>
|
||
<a class="dash-what" href="<?= e((string)$ev['href']) ?>"><?= e((string)$ev['title']) ?></a>
|
||
<?php /* 用户 2026-10-04 第 11 批 #1:「右侧的日历本,现在看不清,
|
||
应该用一个色块,颜色就用日历的颜色,文字是日历本的文字,用白色。」
|
||
原来是 .dash-tag(--faint 灰色 11px 小字),在浅色纸上几乎看不见 ——
|
||
现在做成实心色块:底色 = 这本日历的颜色,字 = 白,一眼能对上左侧那个小圆点。 */ ?>
|
||
<span class="dash-cal"
|
||
style="background: <?= e((string)$ev['color']) ?>;"><?= e((string)$ev['calname']) ?></span>
|
||
</li>
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
</div>
|
||
<?php endif; ?>
|
||
</section>
|
||
|
||
<?php /* ==================== 进行中的任务 ==================== */ ?>
|
||
<section class="section">
|
||
<div class="page-head" style="margin-bottom:12px">
|
||
<h1 style="font-size:15px">手头在做 <span class="sub">进行中 · 已逾期</span></h1>
|
||
<div class="actions">
|
||
<a class="btn btn-ghost btn-sm" href="<?= e(url('tasks')) ?>">任务看板</a>
|
||
</div>
|
||
</div>
|
||
<?php if (!$tasks): ?>
|
||
<div class="card card-pad empty"><b>没有进行中的任务</b>也没有逾期的事,挺好。</div>
|
||
<?php else: ?>
|
||
<div class="card card-pad">
|
||
<ul class="dash-list">
|
||
<?php foreach ($tasks as $t): ?>
|
||
<?php $late = \App\Task::isOverdue($t['due_at'] ?? null); ?>
|
||
<li class="dash-row">
|
||
<span class="dash-dot" style="background: <?= e($late ? 'var(--red)' : 'var(--brand)') ?>;"></span>
|
||
<span class="dash-when">
|
||
<?php if (($t['due_at'] ?? '') !== ''): ?>
|
||
<?= e(\App\Task::dueWord($t['due_at'] ?? null)) ?>
|
||
<?php else: ?>
|
||
进行中
|
||
<?php endif; ?>
|
||
</span>
|
||
<a class="dash-what" href="<?= e(url('tasks/show', ['id' => (int)$t['id']])) ?>">
|
||
<?= e((string)$t['title']) ?>
|
||
</a>
|
||
<?php if ((int)($t['child_total'] ?? 0) > 0): ?>
|
||
<span class="dash-tag"><?= (int)$t['child_done'] ?>/<?= (int)$t['child_total'] ?></span>
|
||
<?php endif; ?>
|
||
</li>
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
</div>
|
||
<?php endif; ?>
|
||
</section>
|
||
|
||
<?php /* ==================== 往年今日 ==================== */ ?>
|
||
<section class="section">
|
||
<div class="page-head" style="margin-bottom:12px">
|
||
<?php /* v24 第 19 条:只认「往年的今天」,不再退回同月 —— 见 home_memories() 的说明。 */ ?>
|
||
<h1 style="font-size:15px">
|
||
往年的今天
|
||
<span class="sub"><?= e(date('n 月 j 日')) ?></span>
|
||
</h1>
|
||
</div>
|
||
<?php if (empty($memories['rows'])): ?>
|
||
<div class="card card-pad empty">
|
||
<b>往年的这一天还没有记录</b>
|
||
日子还长,等有了第一次,明年这时候就会自己冒出来。
|
||
</div>
|
||
<?php else: ?>
|
||
<div class="card card-pad">
|
||
<ul class="dash-list">
|
||
<?php foreach ($memories['rows'] as $mm): ?>
|
||
<li class="dash-row">
|
||
<span class="dash-dot" style="background: <?= $mm['kind'] === 'trip' ? '#3F7D5A' : '#7A4E8C' ?>;"></span>
|
||
<span class="dash-when"><?= (int)$mm['years_ago'] ?> 年前</span>
|
||
<a class="dash-what" href="<?= e((string)$mm['href']) ?>">
|
||
<?= $mm['kind'] === 'trip' ? '🧳 ' : '🎬 ' ?><?= e((string)$mm['title']) ?>
|
||
</a>
|
||
<span class="dash-tag"><?= e(substr((string)$mm['starts_at'], 0, 10)) ?></span>
|
||
</li>
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
</div>
|
||
<?php endif; ?>
|
||
</section>
|