save
This commit is contained in:
parent
af6197dfd1
commit
f6c80eb1ee
@ -124,6 +124,46 @@ class Util
|
|||||||
return $var;
|
return $var;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类转换为url path
|
||||||
|
* @param $controller_class
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
|
static function controllerToUrlPath($controller_class)
|
||||||
|
{
|
||||||
|
$key = strtolower($controller_class);
|
||||||
|
$action = '';
|
||||||
|
if (strpos($key, '@')) {
|
||||||
|
[$key, $action] = explode( '@', $key, 2);
|
||||||
|
}
|
||||||
|
$prefix = 'plugin';
|
||||||
|
$paths = explode('\\', $key);
|
||||||
|
if (count($paths) < 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$base = '';
|
||||||
|
if (strpos($key, "$prefix\\") === 0) {
|
||||||
|
if (count($paths) < 4) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
array_shift($paths);
|
||||||
|
$plugin = array_shift($paths);
|
||||||
|
$base = "/app/$plugin/";
|
||||||
|
}
|
||||||
|
array_shift($paths);
|
||||||
|
foreach ($paths as $index => $path) {
|
||||||
|
if ($path === 'controller') {
|
||||||
|
unset($paths[$index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$suffix = 'controller';
|
||||||
|
$code = $base . implode('/', $paths);
|
||||||
|
if (substr($code, -strlen($suffix)) === $suffix) {
|
||||||
|
$code = substr($code, 0, -strlen($suffix));
|
||||||
|
}
|
||||||
|
return $action ? "$code/$action" : $code;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为驼峰
|
* 转换为驼峰
|
||||||
* @param string $value
|
* @param string $value
|
||||||
|
@ -114,54 +114,15 @@ class AdminRuleController extends Crud
|
|||||||
$keys = AdminRule::whereIn('id', $rules)->pluck('key');
|
$keys = AdminRule::whereIn('id', $rules)->pluck('key');
|
||||||
$permissions = [];
|
$permissions = [];
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
$key = strtolower($key);
|
if (!$key = Util::controllerToUrlPath($key)) {
|
||||||
$action = '';
|
|
||||||
if (strpos($key, '@')) {
|
|
||||||
[$key, $action] = explode( '@', $key, 2);
|
|
||||||
}
|
|
||||||
$prefix = 'plugin';
|
|
||||||
$paths = explode('\\', $key);
|
|
||||||
if (count($paths) < 2) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$base = '';
|
$code = str_replace('/', '.', trim($key, '/'));
|
||||||
if (strpos($key, "$prefix\\") === 0) {
|
$permissions[] = $code;
|
||||||
if (count($paths) < 4) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
array_shift($paths);
|
|
||||||
$plugin = array_shift($paths);
|
|
||||||
$base = "app.$plugin.";
|
|
||||||
}
|
|
||||||
if ($code = $this->formatPermissionCode($paths, $action, $base)) {
|
|
||||||
$permissions[] = $code;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $this->json(0, 'ok', $permissions);
|
return $this->json(0, 'ok', $permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $paths
|
|
||||||
* @param $action
|
|
||||||
* @param string $base
|
|
||||||
* @return false|string
|
|
||||||
*/
|
|
||||||
protected function formatPermissionCode($paths, $action, string $base = '')
|
|
||||||
{
|
|
||||||
array_shift($paths);
|
|
||||||
foreach ($paths as $index => $path) {
|
|
||||||
if ($path === 'controller') {
|
|
||||||
unset($paths[$index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$suffix = 'controller';
|
|
||||||
$code = $base . implode('.', $paths);
|
|
||||||
if (substr($code, -strlen($suffix)) === $suffix) {
|
|
||||||
$code = substr($code, 0, -strlen($suffix));
|
|
||||||
}
|
|
||||||
return $action ? "$code.$action" : $code;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据类同步规则到数据库
|
* 根据类同步规则到数据库
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -699,9 +699,11 @@ EOF;
|
|||||||
* @param $controller_class_with_namespace
|
* @param $controller_class_with_namespace
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function createTemplate($template_file_path, $table, $template_path, $url_path_base, $primary_key)
|
protected function createTemplate($template_file_path, $table, $template_path, $url_path_base, $primary_key, $controller_class_with_namespace)
|
||||||
{
|
{
|
||||||
$this->mkdir($template_file_path . '/index.html');
|
$this->mkdir($template_file_path . '/index.html');
|
||||||
|
$code_base = Util::controllerToUrlPath($controller_class_with_namespace);
|
||||||
|
$code_base = str_replace('/', '.', trim($code_base, '/'));
|
||||||
$form = LayuiForm::buildForm($table, 'search');
|
$form = LayuiForm::buildForm($table, 'search');
|
||||||
$html = $form->html(3);
|
$html = $form->html(3);
|
||||||
$html = $html ? <<<EOF
|
$html = $html ? <<<EOF
|
||||||
@ -754,18 +756,18 @@ EOF
|
|||||||
|
|
||||||
<!-- 表格顶部工具栏 -->
|
<!-- 表格顶部工具栏 -->
|
||||||
<script type="text/html" id="table-toolbar">
|
<script type="text/html" id="table-toolbar">
|
||||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="insert">
|
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="$code_base.insert">
|
||||||
<i class="layui-icon layui-icon-add-1"></i>新增
|
<i class="layui-icon layui-icon-add-1"></i>新增
|
||||||
</button>
|
</button>
|
||||||
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove" permission="delete">
|
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove" permission="$code_base.delete">
|
||||||
<i class="layui-icon layui-icon-delete"></i>删除
|
<i class="layui-icon layui-icon-delete"></i>删除
|
||||||
</button>
|
</button>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- 表格行工具栏 -->
|
<!-- 表格行工具栏 -->
|
||||||
<script type="text/html" id="table-bar">
|
<script type="text/html" id="table-bar">
|
||||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit" permission="update">编辑</button>
|
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit" permission="$code_base.update">编辑</button>
|
||||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="delete">删除</button>
|
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="$code_base.delete">删除</button>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="/app/admin/component/layui/layui.js"></script>
|
<script src="/app/admin/component/layui/layui.js"></script>
|
||||||
|
@ -217,7 +217,6 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// 获取选择组件配置项
|
// 获取选择组件配置项
|
||||||
function getControlProps(control_args)
|
function getControlProps(control_args)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user