Files

63 lines
3.7 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* 旅程模块的「设置」下拉(v24 第 16 批 用户第 8 条;v54 用户第 4 条加一项)。
*
* 用户原话(v24):「右上角的按钮,需要增加一个设置按钮,用来设置车辆管理、出行方式、节点类型。」
*
* 用户原话(v54):「2. 在旅程的「新建旅程」**后面也加一个「设置」按钮**。
* 3. 里面的设置让用户自己配置:**到底默认显示旅程列表,还是用地图显示**。」
*
* 与其它模块同一套规矩(用户 2026-10-01 定的四条):
* ① 按钮**没有文字**、只有图标,图标是**三条横线**;
* ② 排在动作区**最右**(靠 .movie-set 的 margin-left:auto);
* ③ 条目文字前都有图标;
* ④ 除设置外其它按钮都有颜色。
*
* 用法(require 前 set 好):
* $trSetCurrent 当前页 key('vehicles'|'modes'|'types'|'display'|'')
*/
$trSetCurrent = (string)($trSetCurrent ?? '');
$trSetOn = static function (string $key) use ($trSetCurrent): string {
return $trSetCurrent === $key ? ' class="on"' : '';
};
$trSetIcon = static function (string $name): string {
$paths = [
// 车辆:车头 + 两个轮
'car' => '<path d="M2.5 9.5l1.2-3.2A1.4 1.4 0 0 1 5 5.4h6a1.4 1.4 0 0 1 1.3.9l1.2 3.2"/>'
. '<path d="M1.8 9.5h12.4v3.2H1.8z"/><circle cx="4.4" cy="12.9" r="1.1"/>'
. '<circle cx="11.6" cy="12.9" r="1.1"/>',
// 出行方式:一个方向箭头
'modes' => '<path d="M2.5 8h9"/><path d="M8.5 5l3 3-3 3"/>',
// 节点类型:一排小方块
'types' => '<rect x="2" y="2" width="5" height="5" rx="1"/>'
. '<rect x="9" y="2" width="5" height="5" rx="1"/>'
. '<rect x="2" y="9" width="5" height="5" rx="1"/>'
. '<rect x="9" y="9" width="5" height="5" rx="1"/>',
// 🔴 v54:显示方式 —— 列表 + 地图图钉两个小图形
'display' => '<path d="M2.5 4h11M2.5 8h11M2.5 12h6"/>'
. '<path d="M12.6 10.2a2.1 2.1 0 1 0-4.2 0c0 1.5 2.1 3.4 2.1 3.4s2.1-1.9 2.1-3.4z"/>',
];
$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">
<?php /* 🔴 v54(第 4/5 条):显示方式**排在第一条** ——
它是这一页自己最常用的设置("我进来先看列表还是先看地图"),
下面三条(车/方式/类型)是"配一次就不动"的。 */ ?>
<a href="<?= e(url('trips/display')) ?>"<?= $trSetOn('display') ?>><?= $trSetIcon('display') ?><span>显示方式</span></a>
<a href="<?= e(url('trips/vehicles')) ?>"<?= $trSetOn('vehicles') ?>><?= $trSetIcon('car') ?><span>车辆管理</span></a>
<a href="<?= e(url('trips/modes')) ?>"<?= $trSetOn('modes') ?>><?= $trSetIcon('modes') ?><span>出行方式</span></a>
<a href="<?= e(url('trips/types')) ?>"<?= $trSetOn('types') ?>><?= $trSetIcon('types') ?><span>节点类型</span></a>
</div>
</details>
<?php
// ⚠️ 只 unset **本片段自己**定义的变量(前缀 trSet*),宿主模板的变量一个都不能碰
unset($trSetCurrent, $trSetOn, $trSetIcon);