Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Jun 9, 2024
1 parent fa15f60 commit e0587d7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 46 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"laket" : {
"title": "系统设置",
"version": "1.2.1",
"version": "1.2.3",
"adaptation": "1.2.*"
},
"extra": {
Expand Down
32 changes: 16 additions & 16 deletions resources/menus/menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

return [
"title" => "系统配置",
"url" => "admin/settings/setting",
"url" => "settings/setting",
"method" => "GET",
"slug" => $this->slug,
"icon" => "icon-zidongxiufu",
Expand All @@ -12,7 +12,7 @@
"children" => [
[
"title" => "系统设置",
"url" => "admin/settings/setting",
"url" => "settings/setting",
"method" => "GET",
"slug" => "admin.settings.setting",
"icon" => "icon-setup",
Expand All @@ -21,15 +21,15 @@
"children" => [
[
"title" => "系统设置",
"url" => "admin/settings/setting",
"url" => "settings/setting",
"method" => "GET",
"slug" => "admin.settings.setting",
"menu_show" => 0,
"listorder" => 5,
],
[
"title" => "系统设置",
"url" => "admin/settings/setting",
"url" => "settings/setting",
"method" => "POST",
"slug" => "admin.settings.setting-post",
"menu_show" => 0,
Expand All @@ -39,7 +39,7 @@
],
[
"title" => "配置管理",
"url" => "admin/settings/index",
"url" => "settings/index",
"method" => "GET",
"slug" => "admin.settings.index",
"icon" => "icon-apartment",
Expand All @@ -48,87 +48,87 @@
"children" => [
[
"title" => "系统设置",
"url" => "admin/settings/index",
"url" => "settings/index",
"method" => "GET",
"slug" => "admin.settings.index",
"menu_show" => 0,
"listorder" => 5,
],
[
"title" => "系统设置",
"url" => "admin/settings/index",
"url" => "settings/index",
"method" => "POST",
"slug" => "admin.settings.index-post",
"menu_show" => 0,
"listorder" => 10,
],
[
"title" => "全部配置",
"url" => "admin/settings/all",
"url" => "settings/all",
"method" => "GET",
"slug" => "admin.settings.all",
"menu_show" => 0,
"listorder" => 15,
],
[
"title" => "全部配置",
"url" => "admin/settings/all",
"url" => "settings/all",
"method" => "POST",
"slug" => "admin.settings.all-post",
"menu_show" => 0,
"listorder" => 20,
],
[
"title" => "新增配置",
"url" => "admin/settings/add",
"url" => "settings/add",
"method" => "GET",
"slug" => "admin.settings.add",
"menu_show" => 0,
"listorder" => 25,
],
[
"title" => "新增配置",
"url" => "admin/settings/add",
"url" => "settings/add",
"method" => "POST",
"slug" => "admin.settings.add-post",
"menu_show" => 0,
"listorder" => 30,
],
[
"title" => "编辑配置",
"url" => "admin/settings/edit",
"url" => "settings/edit",
"method" => "GET",
"slug" => "admin.settings.edit",
"menu_show" => 0,
"listorder" => 35,
],
[
"title" => "编辑配置",
"url" => "admin/settings/edit",
"url" => "settings/edit",
"method" => "POST",
"slug" => "admin.settings.edit-post",
"menu_show" => 0,
"listorder" => 40,
],
[
"title" => "删除配置",
"url" => "admin/settings/del",
"url" => "settings/del",
"method" => "POST",
"slug" => "admin.settings.del-post",
"menu_show" => 0,
"listorder" => 45,
],
[
"title" => "配置排序",
"url" => "admin/settings/listorder",
"url" => "settings/listorder",
"method" => "POST",
"slug" => "admin.settings.listorder-post",
"menu_show" => 0,
"listorder" => 50,
],
[
"title" => "设置状态",
"url" => "admin/settings/setstate",
"url" => "settings/setstate",
"method" => "POST",
"slug" => "admin.settings.setstate-post",
"menu_show" => 0,
Expand Down
5 changes: 3 additions & 2 deletions resources/view/config/all.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@
</div>
</script>
<script type="text/html" id="barTool">
{if laket_check_permission(['admin.settings.edit', 'admin.settings.edit-post'], 'and')}
{if laket_auth(['admin.settings.edit', 'admin.settings.edit-post'], 'and')}
<a href='{:laket_route("admin.settings.edit-post")}?id={{ d.id }}' class="layui-btn layui-btn-xs layui-iframe" title="编辑配置项">编辑</a>
{/if}
{if laket_check_permission('admin.settings.del-post')}

{if laket_auth('admin.settings.del-post')}
<a href='{:laket_route("admin.settings.del-post")}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
{/if}
</script>
Expand Down
14 changes: 4 additions & 10 deletions resources/view/config/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,20 @@
{/block}

{block name="script"}

{php}
$addSug = ['get:admin.settings.add', 'post:admin.settings.add-post'];
$editSug = ['get:admin.settings.edit', 'post:admin.settings.edit-post'];
$delSug = 'post:admin.settings.del-post';
{/php}

<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
{if laket_check_permission($addSug, 'and')}
{if laket_auth(['admin.settings.add', 'admin.settings.add-post'], 'and')}
<a class="layui-btn layui-btn-sm layui-iframe" href="{:laket_route('admin.settings.add')}?group={$group}" title="新增配置项">新增配置项</a>
{/if}
</div>
</script>

<script type="text/html" id="barTool">
{if laket_check_permission($editSug, 'and')}
{if laket_auth(['admin.settings.edit', 'admin.settings.edit-post'], 'and')}
<a href='{:laket_route("admin.settings.edit-post")}?id={{ d.id }}' class="layui-btn layui-btn-xs layui-iframe" title="编辑配置项">编辑</a>
{/if}

{if laket_check_permission($delSug)}
{if laket_auth('admin.settings.del-post')}
<a href='{:laket_route("admin.settings.del-post")}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
{/if}
</script>
Expand Down
34 changes: 17 additions & 17 deletions src/Controller/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ public function add()

$status = ConfigModel::create($data);
if (false === $status) {
$this->error('配置添加失败!');
return $this->error('配置添加失败!');
}

$this->success('配置添加成功!');
return $this->success('配置添加成功!');
} else {
// ['name,title,ifoption,ifstring']
$fieldType = ConfigModel::getFieldType();
Expand Down Expand Up @@ -247,21 +247,21 @@ public function edit()
'id' => $id,
])->find();
if (empty($info)) {
$this->error('信息不存在!');
return $this->error('信息不存在!');
}

$status = ConfigModel::update($data, [
'id' => $id,
]);
if ($status === false) {
$this->error('配置编辑失败!');
return $this->error('配置编辑失败!');
}

$this->success('配置编辑成功!');
return $this->success('配置编辑成功!');
} else {
$id = $this->request->param('id');
if (empty($id) || strlen($id) != 32) {
$this->error('参数错误!');
return $this->error('参数错误!');
}

// ['name,title,ifoption,ifstring']
Expand All @@ -271,7 +271,7 @@ public function edit()
'id' => $id,
])->find();
if (empty($info)) {
$this->error('信息不存在!');
return $this->error('信息不存在!');
}

$this->assign([
Expand All @@ -291,24 +291,24 @@ public function del()
{
$id = $this->request->param('id');
if (empty($id) || strlen($id) != 32) {
$this->error('参数错误!');
return $this->error('参数错误!');
}

$info = ConfigModel::where([
'id' => $id,
])->find();
if (empty($info)) {
$this->error('信息不存在!');
return $this->error('信息不存在!');
}

$re = ConfigModel::where([
'id' => $id,
])->delete();
if ($re === false) {
$this->error('删除失败!');
return $this->error('删除失败!');
}

$this->success('删除成功');
return $this->success('删除成功');
}

/**
Expand All @@ -318,7 +318,7 @@ public function listorder()
{
$id = $this->request->param('id');
if (empty($id) || strlen($id) != 32) {
$this->error('参数不能为空!');
return $this->error('参数不能为空!');
}

$listorder = $this->request->param('value/d', 0);
Expand All @@ -333,10 +333,10 @@ public function listorder()
]);

if ($rs === false) {
$this->error("排序失败!");
return $this->error("排序失败!");
}

$this->success("排序成功!");
return $this->success("排序成功!");
}

/**
Expand All @@ -346,7 +346,7 @@ public function setstate($id, $status)
{
$id = $this->request->param('id');
if (empty($id) || strlen($id) != 32) {
$this->error('参数不能为空!');
return $this->error('参数不能为空!');
}

$status = $this->request->param('status/d');
Expand All @@ -360,10 +360,10 @@ public function setstate($id, $status)
'status' => $status,
]);
if ($rs === false) {
$this->error('操作失败!');
return $this->error('操作失败!');
}

$this->success('操作成功!');
return $this->success('操作成功!');
}

}

0 comments on commit e0587d7

Please sign in to comment.