53 lines
2.8 KiB
PHP
53 lines
2.8 KiB
PHP
<?php
|
||||
|
|
/**
|
|||
|
|
* 旅程模块的「设置」下拉(v24 第 16 批 用户第 8 条)。
|
|||
|
|
*
|
|||
|
|
* 用户原话:「右上角的按钮,需要增加一个设置按钮,用来设置车辆管理、出行方式、节点类型。」
|
|||
|
|
*
|
|||
|
|
* 与其它模块同一套规矩(用户 2026-10-01 定的四条):
|
|||
|
|
* ① 按钮**没有文字**、只有图标,图标是**三条横线**;
|
|||
|
|
* ② 排在动作区**最右**(靠 .movie-set 的 margin-left:auto);
|
|||
|
|
* ③ 条目文字前都有图标;
|
|||
|
|
* ④ 除设置外其它按钮都有颜色。
|
|||
|
|
*
|
|||
|
|
* 用法(require 前 set 好):
|
|||
|
|
* $trSetCurrent 当前页 key('vehicles'|'modes'|'types'|'')
|
|||
|
|
*/
|
|||
|
|
$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"/>',
|
|||
|
|
];
|
|||
|
|
$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('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);
|