DcatAdmin行操作按钮样式调整(图标+文字)
PHP

DcatAdmin行操作按钮样式调整(图标+文字)

quhe.net
2023-10-13 / 0 评论 / 76 阅读 / 正在检测是否收录...

效果

lxo62gaw.png

lxo62uwp.png

更改方式

app/Admin/Actions/Grid/ 下新建 TextActions.php 文件,内容如下

<?php

namespace App\Admin\Actions\Grid;

use Dcat\Admin\Grid\Displayers\Actions;

/**
 * 重写行操作按钮样式
 */
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> &emsp;';
    }

    /**
     * @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> &emsp;';
    }

    /**
     * @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> &emsp;';
    }

    /**
     * @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> &emsp;';
    }
}

config/admin.php 中更改配置项 grid.grid_action_class, 如下

// The global Grid action display class.
'grid_action_class'  => App\Admin\Actions\Grid\TextActions::class,
1

评论 (0)

取消