Dcat Admin 自定义行默认操作按钮样式,Dcat Admin行操作按钮样式调整(图标+文字)
admin 阅读:39 2024-03-02
Dcat Admin 默认有四个行操作编辑
、快捷编辑
、删除
和详情
,实际默认显示只有三个小图标,没有说明文字。对用户不太友好,我们可以自己定义一个操作按钮显示样式,然后以通过配置参数 admin.grid.grid_action_class
参数进行配置即可。

首先、新建行操作按钮显示样式文件。
在 app/Admin/Actions/Grid/
下新建 TextActions.php
文件,内容如下:
<?php
namespace AppAdminActionsGrid;
use DcatAdminGridDisplayersActions;
/**
* 重写行操作按钮样式
*/
class TextActions extends Actions
{
/**
* @return string
*/
protected function getViewLabel()
{
$label = trans('admin.show');
return '<i class="feather icon-eye text-success"></i> <span class="text-success">' . $label . '</span> ';
}
/**
* @return string
*/
protected function getEditLabel()
{
$label = trans('admin.edit');
return '<i class="feather icon-edit-1 text-custom"></i> <span class="text-custom">' . $label . '</span> ';
}
/**
* @return string
*/
protected function getQuickEditLabel()
{
$label = trans('admin.edit');
$label2 = trans('admin.quick_edit');
return '<i class="feather icon-edit-1 text-custom"></i> <span class="text-custom" title="' . $label2 . '">' . $label . '</span> ';
}
/**
* @return string
*/
protected function getDeleteLabel()
{
$label = trans('admin.delete');
return '<i class="feather icon-alert-triangle text-danger"></i> <span class="text-danger">' . $label . '</span> ';
}
}
其次、配置admin.grid.grid_action_class
参数
在 config/admin.php
中更改配置项 grid.grid_action_class
为新创建的文件。
'grid_action_class' => AppAdminActionsGridTextActions::class,
返回到页面,刷新一下就可以看到新的样式了。
声明
1、部分文章来源于网络,仅作为参考。 2、如果网站中图片和文字侵犯了您的版权,请联系1943759704@qq.com处理!