| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace App\Module\Dev\AdminControllers\Helper;
- use App\Module\Dev\Enums\DEV_LOG_TYPE;
- use App\Module\Dev\Enums\DEV_STATUS;
- use Dcat\Admin\Show;
- /**
- * 详情页辅助特性
- *
- * 提供开发工具模块后台控制器的详情页构建功能的具体实现
- */
- trait ShowHelperTrait
- {
- /**
- * 显示开发工具状态
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldDevStatus(string $field = 'status', string $label = '状态'): Show\Field
- {
- return $this->show->field($field, $label)->as(function ($value) {
- return DEV_STATUS::getAll()[$value] ?? '未知';
- });
- }
- /**
- * 显示开发日志类型
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldDevLogType(string $field = 'type', string $label = '日志类型'): Show\Field
- {
- return $this->show->field($field, $label)->as(function ($value) {
- return DEV_LOG_TYPE::getAll()[$value] ?? '未知';
- });
- }
- /**
- * 显示开发日志内容
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldDevLogContent(string $field = 'content', string $label = '日志内容'): Show\Field
- {
- return $this->show->field($field, $label);
- }
- /**
- * 显示开发日志额外数据
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldDevLogExtraData(string $field = 'extra_data', string $label = '额外数据'): Show\Field
- {
- return $this->show->field($field, $label)->json();
- }
- /**
- * 显示开发配置值
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldDevConfigValue(string $field = 'value', string $label = '配置值'): Show\Field
- {
- return $this->show->field($field, $label);
- }
- /**
- * 显示系统信息
- *
- * @param array $systemInfo 系统信息
- * @return Show\Field
- */
- public function fieldSystemInfo(array $systemInfo): void
- {
- $this->show->divider('系统信息');
- foreach ($systemInfo as $key => $value) {
- $label = ucwords(str_replace('_', ' ', $key));
- $this->show->field($key, $label)->as(function () use ($value) {
- return $value;
- });
- }
- }
- }
|