优化生成表格工具栏按钮权限判断

pull/406/head
Karson 2022-05-27 15:01:40 +08:00
parent 9400aa6e4e
commit 079f6df9dd
1 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@ use app\common\model\Category;
use fast\Form; use fast\Form;
use fast\Tree; use fast\Tree;
use think\Db; use think\Db;
use think\Loader;
if (!function_exists('build_select')) { if (!function_exists('build_select')) {
@ -102,7 +103,7 @@ if (!function_exists('build_toolbar')) {
function build_toolbar($btns = null, $attr = []) function build_toolbar($btns = null, $attr = [])
{ {
$auth = \app\admin\library\Auth::instance(); $auth = \app\admin\library\Auth::instance();
$controller = str_replace('.', '/', strtolower(think\Request::instance()->controller())); $controller = str_replace('.', '/', Loader::parseName(request()->controller()));
$btns = $btns ? $btns : ['refresh', 'add', 'edit', 'del', 'import']; $btns = $btns ? $btns : ['refresh', 'add', 'edit', 'del', 'import'];
$btns = is_array($btns) ? $btns : explode(',', $btns); $btns = is_array($btns) ? $btns : explode(',', $btns);
$index = array_search('delete', $btns); $index = array_search('delete', $btns);
@ -175,7 +176,7 @@ if (!function_exists('build_heading')) {
$title = $content = ''; $title = $content = '';
if (is_null($path)) { if (is_null($path)) {
$action = request()->action(); $action = request()->action();
$controller = str_replace('.', '/', request()->controller()); $controller = str_replace('.', '/', Loader::parseName(request()->controller()));
$path = strtolower($controller . ($action && $action != 'index' ? '/' . $action : '')); $path = strtolower($controller . ($action && $action != 'index' ? '/' . $action : ''));
} }
// 根据当前的URI自动匹配父节点的标题和备注 // 根据当前的URI自动匹配父节点的标题和备注