修改退出登录后的提示行为
在FastAdmin中,默认退出登录后会显示"退出成功"的提示信息并跳转页面。要实现不显示提示信息直接跳转,可以通过以下方式修改:
方法一:修改控制器逻辑
找到application/admin/controller/Login.php
文件中的logout
方法,将原有代码替换为:
/*** 退出登录*/public function logout(){if ($this->request->isPost()) {$this->auth->logout(); Hook::listen("admin_logout_after", $this->request);$this->success(__('Logout successful'), 'index/login');}$html = "<form id='logout_submit' name='logout_submit' action='' method='post'>" . token() . "<input type='submit' value='ok' style='display:none;'></form>";$html .= "<script>document.forms['logout_submit'].submit();</script>";return $html;}
将$this->success(__('Logout successful'), 'index/login');修改为$this->redirect('index/login'); 这样就不会有跳转提示了
/*** 退出登录*/public function logout(){if ($this->request->isPost()) {$this->auth->logout(); Hook::listen("admin_logout_after", $this->request);$this->redirect('index/login');}$html = "<form id='logout_submit' name='logout_submit' action='' method='post'>" . token() . "<input type='submit' value='ok' style='display:none;'></form>";$html .= "<script>document.forms['logout_submit'].submit();</script>";return $html;}