2026-09-30 00:49:53 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
$navItems = [
|
|
|
|
|
|
'home' => ['首页', 'home'],
|
2026-09-30 08:13:07 +08:00
|
|
|
|
'kin' => ['家谱', 'kin'],
|
2026-09-30 00:49:53 +08:00
|
|
|
|
'people' => ['名册', 'people'],
|
|
|
|
|
|
];
|
|
|
|
|
|
if (\App\Auth::isAdmin()) {
|
|
|
|
|
|
$navItems['settings'] = ['设置', 'settings'];
|
|
|
|
|
|
}
|
2026-09-30 08:13:07 +08:00
|
|
|
|
// ⚠️ 变量名不要叫 $me:layout 是在 extract($data) **之后**被 require 的,
|
|
|
|
|
|
// 这里再赋值会把页面传进来的 $me(当前登录者的完整记录)覆盖掉。
|
|
|
|
|
|
// home.php 用 $me 画「补充亲属关系」链接,被覆盖成 true 之后
|
|
|
|
|
|
// 链接就变成 people/show&id=0,还顺带在页首打出一条 Warning。
|
|
|
|
|
|
// 改名前请先确认所有模板都没有依赖这个布尔值。
|
|
|
|
|
|
$isLoggedIn = \App\Auth::check();
|
2026-09-30 00:49:53 +08:00
|
|
|
|
?>
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
<html lang="zh-CN">
|
|
|
|
|
|
<head>
|
|
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
|
|
<title><?= e($pageTitle) ?> · 家书</title>
|
|
|
|
|
|
<link rel="icon" href="/favicon.ico">
|
|
|
|
|
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
|
|
|
|
|
<link rel="manifest" href="/site.webmanifest">
|
|
|
|
|
|
<meta name="theme-color" content="#A84A28">
|
|
|
|
|
|
<link rel="stylesheet" href="<?= e(asset('/assets/css/app.css')) ?>">
|
|
|
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
2026-09-30 08:13:07 +08:00
|
|
|
|
<?php if ($isLoggedIn): ?>
|
2026-09-30 00:49:53 +08:00
|
|
|
|
<header class="topbar">
|
|
|
|
|
|
<div class="topbar-inner">
|
|
|
|
|
|
<a class="brand" href="<?= e(url('home')) ?>">
|
|
|
|
|
|
<img src="<?= e(asset('/assets/icons/icon-96.png')) ?>" alt="">
|
|
|
|
|
|
<span>家书</span>
|
|
|
|
|
|
</a>
|
|
|
|
|
|
<nav class="nav">
|
|
|
|
|
|
<?php foreach ($navItems as $route => list($label, $key)): ?>
|
|
|
|
|
|
<a class="<?= $pageKey === $key ? 'on' : '' ?>" href="<?= e(url($route)) ?>"><?= e($label) ?></a>
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
<div class="topbar-right">
|
2026-09-30 11:06:22 +08:00
|
|
|
|
<?php /* 姓名 + 头像 = 一个下拉菜单,而不是「点名字改资料」+旁边两个裸链接。
|
|
|
|
|
|
裸链接在窄屏只能靠 display:none 藏起来(一藏入口就没了),
|
|
|
|
|
|
收进菜单之后同一个入口在手机上也点得到。
|
|
|
|
|
|
用 <details> 实现:不需要 JS 就能展开/收起,app.js 只额外补
|
|
|
|
|
|
"点外面"和"Esc"两件事。 */ ?>
|
|
|
|
|
|
<details class="menu who-menu">
|
|
|
|
|
|
<summary class="who" title="我的">
|
|
|
|
|
|
<img src="<?= e(avatar_url($_SESSION['avatar'] ?? null)) ?>" alt="">
|
|
|
|
|
|
<span class="who-name"><?= e(\App\Auth::name()) ?></span>
|
|
|
|
|
|
<?php if (\App\Auth::isGuest()): ?><span class="badge">访客</span><?php endif; ?>
|
|
|
|
|
|
<i class="caret" aria-hidden="true"></i>
|
|
|
|
|
|
</summary>
|
|
|
|
|
|
<div class="menu-list">
|
|
|
|
|
|
<a href="<?= e(url('settings/me')) ?>">个人设置</a>
|
|
|
|
|
|
<?php if (\App\Auth::isAdmin()): ?>
|
|
|
|
|
|
<a href="<?= e(url('settings')) ?>">系统设置</a>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
<a href="<?= e(url('auth/password')) ?>">修改密码</a>
|
|
|
|
|
|
<a class="menu-exit" href="<?= e(url('auth/logout', ['_csrf' => csrf_token()])) ?>">退出登录</a>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</details>
|
2026-09-30 00:49:53 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</header>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<main class="<?= in_array($pageKey, ['install', 'login'], true) ? 'container-narrow' : 'container' ?>">
|
|
|
|
|
|
|
|
|
|
|
|
<?php foreach (take_flash() as $f): ?>
|
|
|
|
|
|
<div class="flash">
|
|
|
|
|
|
<div class="flash-item <?= $f['type'] === 'err' ? 'err' : '' ?>"><?= e($f['message']) ?></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<?php require $tplFile; ?>
|
|
|
|
|
|
|
|
|
|
|
|
</main>
|
|
|
|
|
|
|
|
|
|
|
|
<script src="<?= e(asset('/assets/js/app.js')) ?>"></script>
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>
|