44 lines
2.1 KiB
PHP
44 lines
2.1 KiB
PHP
<?php
|
||||
|
|
/**
|
|||
|
|
* 读书模块的「设置」下拉 —— 统计 / 导入笔记。
|
|||
|
|
*
|
|||
|
|
* 与其它模块同一套规矩(用户 2026-10-01 定的四条):
|
|||
|
|
* ① 按钮**没有文字**、只有图标,图标是**三条横线**;
|
|||
|
|
* ② 排在动作区**最右**(靠 .movie-set 的 margin-left:auto);
|
|||
|
|
* ③ 条目文字前都有图标;
|
|||
|
|
* ④ 除设置外其它按钮都有颜色。
|
|||
|
|
*
|
|||
|
|
* 用法(require 前 set 好):
|
|||
|
|
* $bkSetCurrent 当前页 key('list'|'show'|'form'|'read'|'stats'|'import')
|
|||
|
|
*/
|
|||
|
|
$bkSetCurrent = (string)($bkSetCurrent ?? '');
|
|||
|
|
$bkSetOn = static function (string $key) use ($bkSetCurrent): string {
|
|||
|
|
return $bkSetCurrent === $key ? ' class="on"' : '';
|
|||
|
|
};
|
|||
|
|
$bkSetIcon = static function (string $name): string {
|
|||
|
|
$paths = [
|
|||
|
|
// 统计:柱状图
|
|||
|
|
'stats' => '<path d="M3 13V9M6.5 13V5M10 13V7.5M13.5 13V3"/>',
|
|||
|
|
// 导入笔记:一支笔写在纸上
|
|||
|
|
'import' => '<path d="M9.5 2.5l4 4L5 15H2v-3z"/><path d="M8 4l4 4"/>',
|
|||
|
|
];
|
|||
|
|
$d = $paths[$name] ?? '';
|
|||
|
|
if ($d === '') {
|
|||
|
|
return '';
|
|||
|
|
}
|
|||
|
|
return '<svg class="mi" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"'
|
|||
|
|
. ' fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"'
|
|||
|
|
. ' stroke-linejoin="round">' . $d . '</svg>';
|
|||
|
|
};
|
|||
|
|
?>
|
|||
|
|
<details class="movie-set menu">
|
|||
|
|
<summary class="btn btn-icon" title="读书设置" aria-label="读书设置"><svg viewBox="0 0 16 16" width="18" height="18" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/></svg></summary>
|
|||
|
|
<div class="menu-list">
|
|||
|
|
<a href="<?= e(url('books/stats')) ?>"<?= $bkSetOn('stats') ?>><?= $bkSetIcon('stats') ?><span>读书统计</span></a>
|
|||
|
|
<a href="<?= e(url('books/notes_import')) ?>"<?= $bkSetOn('import') ?>><?= $bkSetIcon('import') ?><span>导入读书笔记</span></a>
|
|||
|
|
</div>
|
|||
|
|
</details>
|
|||
|
|
<?php
|
|||
|
|
// ⚠️ 只 unset **本片段自己**定义的变量(前缀 bkSet*),宿主模板的变量一个都不能碰
|
|||
|
|
unset($bkSetCurrent, $bkSetOn, $bkSetIcon);
|