Skip to content

Commit

Permalink
添加更多嵌入点
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Jul 15, 2024
1 parent 82e3883 commit 99878df
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 31 deletions.
64 changes: 37 additions & 27 deletions src/Controller/AuthGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,31 @@ public function delete()

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


/**
* 用户组排序
*/
public function listorder()
{
$id = $this->request->param('id/s', 0);
if (empty($id)) {
return $this->error('参数不能为空!');
}

$listorder = $this->request->param('value/d', 100);

$rs = AuthGroupModel::where([
'id' => $id,
])->update([
'listorder' => $listorder,
]);
if ($rs === false) {
return $this->error("排序失败!");
}

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

/**
* 访问授权页面
*/
Expand Down Expand Up @@ -316,39 +340,22 @@ public function access()
->withData($json)
->buildArray(0);

// 权限数据
$json = apply_filters('admin_authgroup_access_rules', $json);

$this->assign('group_id', $groupId);
$this->assign('json', $json);

$authGroup = AuthGroupModel::where([
'id' => $groupId,
])->find();
'id' => $groupId,
])
->find();
$this->assign('auth_group', $authGroup);

return $this->fetch('laket-admin::auth-group.access');
}

/**
* 用户组排序
*/
public function listorder()
{
$id = $this->request->param('id/s', 0);
if (empty($id)) {
return $this->error('参数不能为空!');
}

$listorder = $this->request->param('value/d', 100);

$rs = AuthGroupModel::where([
'id' => $id,
])->update([
'listorder' => $listorder,
]);
if ($rs === false) {
return $this->error("排序失败!");
}
// 数据设置之后
do_action('admin_authgroup_access_after', $rules);

return $this->success("排序成功!");
return $this->fetch('laket-admin::auth-group.access');
}

/**
Expand Down Expand Up @@ -399,6 +406,9 @@ public function accessSave()
}
}

// 保存后
do_action('admin_authgroup_access_save_after', $rules);

return $this->success('授权成功!');
}

Expand Down
5 changes: 4 additions & 1 deletion src/Controller/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function index()
$this->assign('user_info', Admin::getData());

// 左侧菜单
$menus = AuthRuleModel::getMenuList();
$menus = apply_filters('admin_main_menus', AuthRuleModel::getMenuList());
$this->assign("menus", $menus);

// 后台首页
Expand Down Expand Up @@ -62,8 +62,11 @@ public function main()
$adminCount = AdminModel::count();
$this->assign('admin_count', $adminCount);

// 服务器信息
$this->assign('sys_info', $this->getSysInfo());

do_action('admin_index_main_after');

return $this->fetch('laket-admin::index.main');
}

Expand Down
11 changes: 11 additions & 0 deletions src/Controller/Passport.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public function loginCheck()
return $this->error('你已经登录!');
}

do_action('admin_passport_login_before');

$verify = request()->post('verify');

// 验证码
Expand Down Expand Up @@ -124,6 +126,8 @@ public function loginCheck()

$adminInfo = Admin::login($data['name'], $password);
if (empty($adminInfo)) {
do_action('admin_passport_login_password_error');

return $this->error('用户名或者密码错误!');
}

Expand All @@ -135,6 +139,8 @@ public function loginCheck()
// 清除数据
Session::delete($prikeyCacheKey);

do_action('admin_passport_login_after', $adminInfo);

return $this->success('登录成功!', laket_route('admin.index.index'));
}

Expand All @@ -147,10 +153,15 @@ public function logout()
return $this->error("你还没有登录", laket_route("admin.passport.login"));
}

// 登录账号信息
$adminInfo = Admin::getData();

if (Admin::logout()) {
return $this->success('退出成功', laket_route("admin.passport.login"));
}

do_action('admin_passport_logout_after', $adminInfo);

return $this->error("退出失败", laket_route("admin.passport.login"));
}

Expand Down
4 changes: 3 additions & 1 deletion src/Middleware/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public function handle($request, Closure $next)
$pathinfo = $request->pathinfo();
$routeGroup = config('laket.route.group');
if (Str::startsWith($pathinfo, $routeGroup.'/')) {
$this->app->bind(Handle::class, Handler::class);
$handler = apply_filters('admin_middleware_exception_handler', Handler::class);

$this->app->bind(Handle::class, $handler);
}

return $next($request);
Expand Down
6 changes: 6 additions & 0 deletions src/Middleware/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ public function __construct(App $app)
*/
public function handle($request, Closure $next)
{
do_action('admin_middleware_permission_before');

if (! $this->checkPermission($request)) {
do_action('admin_middleware_permission_fail');

return $this->error('未授权访问!');
}

do_action('admin_middleware_permission_after');

return $next($request);
}

Expand Down
4 changes: 2 additions & 2 deletions src/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
use Laket\Admin\Model\Attachment as AttachmentModel;

// 版本号
define("LAKET_VERSION", "1.3.13");
define("LAKET_RELEASE", "1.3.13.20240715");
define("LAKET_VERSION", "1.3.15");
define("LAKET_RELEASE", "1.3.15.20240715");

if (! function_exists('make')) {
/**
Expand Down

0 comments on commit 99878df

Please sign in to comment.