1. 独立页(登录/安装/错误)套上 HTML 骨架 —— 修「首页为什么没有样式」: 新增 templates/layout-bare.php,View::render 对独立页也走完整 <head> + CSS。 2. 以个人为中心:Kinship::label() 现算称呼、Auth::homeTitle() 出「X的家书」; 同一批人在不同登录者眼里自动变成公公婆婆 / 岳父岳母(不存一次性称谓)。 3. 附件存储可配置:Storage 门面(local / 阿里云 OSS),库里只存相对键, 云端失败自动回退本地;设置页可选驱动并填 OSS 参数(照 MovieLog 的方案)。 4. 三种角色:admin / member / guest,访客只读、写操作一律 403; accounts.role 枚举扩容,老库靠 Schema::ensure() 自动升级。 5. 家谱:只存相邻两代的边(parent / spouse),其余称呼全部推导 —— 兄弟姐妹不存边(共同父母 + birth_rank 排行推长子/次女、哥哥/妹妹), 认不清的人用虚拟人物 is_placeholder 占位,关系天然双向。 顺带修掉本地 e2e 挖出的 8 个线上级 bug(性别写死、长幼方向反、关系方向静默写反、 birth_rank 不从表单取回、隐式可空参数致响应头失效、无文件字段被误判为上传失败、 layout 变量撞车覆盖 $me、世代 0 显示成「下 0 代」)。 验证:kinship 单测 37/0 · HTTP e2e 81/0 · 老库升级专测 14/0 · 反向验证 11/11(把每个修复改回旧写法,对应断言都会变红)。
129 lines
4.9 KiB
PHP
129 lines
4.9 KiB
PHP
<?php
|
|
/**
|
|
* 首页 —— 以「我」为中心。
|
|
*
|
|
* 同一份数据,爸爸登进来看到的是「我的父亲/我的儿子」,
|
|
* 爱人登进来看到的是同一批人,称呼却变成「公公/婆婆」。
|
|
* 称呼全部由 Kinship 现算,库里不存任何一次性称谓。
|
|
*/
|
|
$kinCount = count($kin);
|
|
$hasRel = $relCount > 0;
|
|
// 有亲属关系 → 只显示家人;还没建 → 退回显示全名册,别让首页空着
|
|
$list = $hasRel ? $kin : [];
|
|
if (!$list) {
|
|
foreach (\App\Person::all((int)\App\Auth::familyId()) as $p) {
|
|
$list[(int)$p['id']] = $p + ['label' => ''];
|
|
}
|
|
}
|
|
?>
|
|
<section class="hero">
|
|
<img class="hero-logo" src="<?= e(asset('/assets/icons/icon-192.png')) ?>" alt="">
|
|
<div>
|
|
<h1><?= e(\App\Auth::homeTitle()) ?></h1>
|
|
<p class="motto">
|
|
<?php if ($me): ?>
|
|
<?= e($family['name']) ?> · 这里的称呼都是按你的视角算的
|
|
<?php else: ?>
|
|
<?= e($family['motto'] ?: '一本用岁月写成的家谱') ?>
|
|
<?php endif; ?>
|
|
</p>
|
|
</div>
|
|
<div class="hero-stats">
|
|
<div class="stat"><b><?= (int)$kinCount ?></b><span>与我有关</span></div>
|
|
<div class="stat"><b><?= (int)$allCount ?></b><span>名册总数</span></div>
|
|
<div class="stat"><b><?= (int)$relCount ?></b><span>亲属连线</span></div>
|
|
</div>
|
|
</section>
|
|
|
|
<?php if ($birthdays): ?>
|
|
<section class="section">
|
|
<h2 class="section-title">接下来的日子 <span class="hint">两个月内</span></h2>
|
|
<div class="bdays">
|
|
<?php foreach ($birthdays as $b): ?>
|
|
<div class="bday">
|
|
<img src="<?= e(avatar_url($b['avatar'])) ?>" alt="">
|
|
<div>
|
|
<b><?= e($b['name']) ?></b>
|
|
<?php if (!empty($b['label']) && $b['label'] !== '我'): ?>
|
|
<span class="badge"><?= e($b['label']) ?></span>
|
|
<?php endif; ?>
|
|
<div class="d">
|
|
<?php if ($b['days_left'] === 0): ?>
|
|
就是今天,生日快乐
|
|
<?php else: ?>
|
|
还有 <?= (int)$b['days_left'] ?> 天过生日
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</section>
|
|
<?php endif; ?>
|
|
|
|
<section class="section">
|
|
<div class="page-head" style="margin-bottom:12px">
|
|
<h1 style="font-size:15px"><?= $hasRel ? '我的家人' : '家庭成员' ?></h1>
|
|
<div class="actions">
|
|
<a class="btn btn-ghost btn-sm" href="<?= e(url('kin')) ?>">我的家谱</a>
|
|
<?php if ($me): ?>
|
|
<a class="btn btn-ghost btn-sm" href="<?= e(url('people/show', ['id' => (int)$me['id']])) ?>">补充亲属关系</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (!$hasRel): ?>
|
|
<div class="empty">
|
|
<b>先把家人连起来</b>
|
|
目前还没有任何亲属关系,所以下面显示的是整个名册。<br>
|
|
到自己的资料页填上「谁是我的父母、配偶、子女」,之后这一页就只显示跟你有关的人,
|
|
每个人的称呼也会按你的视角来算。
|
|
<?php if ($me): ?>
|
|
<div class="btn-row" style="justify-content:center">
|
|
<a class="btn" href="<?= e(url('people/show', ['id' => (int)$me['id']])) ?>">开始连关系</a>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!$list): ?>
|
|
<div class="empty">
|
|
<b>名册还是空的</b>
|
|
先把家里人加进来,之后他们就能出现在每一条记录里。
|
|
<div class="btn-row" style="justify-content:center">
|
|
<a class="btn" href="<?= e(url('people/new')) ?>">添加成员</a>
|
|
</div>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="people-grid">
|
|
<?php foreach ($list as $p): ?>
|
|
<a class="person" href="<?= e(url('people/show', ['id' => (int)$p['id']])) ?>">
|
|
<div class="ph"><img src="<?= e(avatar_url($p['avatar'] ?? '')) ?>" alt=""></div>
|
|
<div class="pb">
|
|
<div class="pname">
|
|
<?= e($p['name']) ?>
|
|
<?php if (!empty($p['is_placeholder'])): ?><span class="badge">待确认</span><?php endif; ?>
|
|
</div>
|
|
<div class="pmeta">
|
|
<?php if (!empty($p['label'])): ?>
|
|
<span class="rel-label"><?= e($p['label']) ?></span>
|
|
<?php endif; ?>
|
|
<?php
|
|
$role = $p['account_role'] ?? '';
|
|
if ($role === 'admin' && ($p['account_status'] ?? '') === 'active') {
|
|
echo '<span class="badge badge-admin">管理员</span>';
|
|
} elseif ($role === 'guest') {
|
|
echo '<span class="badge">访客</span>';
|
|
} elseif (!empty($p['account_id'])) {
|
|
echo '<span class="badge badge-open">已开通</span>';
|
|
}
|
|
$age = age_from($p['birthday'] ?? '');
|
|
if ($age !== null) { echo ' · ' . (int)$age . ' 岁'; }
|
|
?>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</section>
|