mirror of https://gitee.com/karson/fastadmin.git
优化后台退出逻辑
parent
a88f91046c
commit
dd1560d9bf
|
|
@ -128,14 +128,12 @@ class Index extends Backend
|
|||
public function logout()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$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;
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ return [
|
|||
'Please try again after 1 day' => '请于1天后再尝试登录',
|
||||
'Login successful' => '登录成功!',
|
||||
'Logout successful' => '退出成功!',
|
||||
'Are you sure you want to sign out?' => '确定要退出后台管理吗?',
|
||||
'Confirm sign out' => '确定退出',
|
||||
'Verification code is incorrect' => '验证码不正确',
|
||||
'Wipe cache completed' => '清除缓存成功',
|
||||
'Wipe cache failed' => '清除缓存失败',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
{include file="common/meta" /}
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
color: #999;
|
||||
background-color: #f1f4fd;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.logout-main {
|
||||
text-align: center;
|
||||
max-width: 500px;
|
||||
margin: 0 auto;
|
||||
margin-top: 150px;
|
||||
background-color: #fff;
|
||||
padding: 50px 30px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, .1);
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logout-main text-center">
|
||||
<div class="image">
|
||||
<img src="__CDN__/assets/img/info.svg" alt="" width="100" />
|
||||
</div>
|
||||
<h3 class="my-4" style="font-size:16px;">{:__('Are you sure you want to sign out?')}</h3 class="my-4" style="font-size:16px;">
|
||||
<form name="form" id="login-form" class="form-vertical" method="POST" action="#">
|
||||
{:token()}
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary btn-lg btn-block">{:__('Confirm sign out')}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{include file="common/script" /}
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -381,6 +381,24 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi
|
|||
}
|
||||
});
|
||||
|
||||
$(document).on("click", "a[href*='index/logout']", function () {
|
||||
var that = this;
|
||||
$.ajax({
|
||||
type: 'GET', dataType: 'html', url: $(that).attr("href"),
|
||||
success: function (data, status, xhr) {
|
||||
Fast.api.ajax({url: $(that).attr("href"), loading:false, data: {__token__: xhr.getResponseHeader('__token__')}}, function (data, ret) {
|
||||
Layer.msg(ret.msg, {icon: 1}, function () {
|
||||
location.reload();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}, error: function (xhr, type) {
|
||||
Layer.msg(__('Network error'), {icon: 2});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$(window).resize();
|
||||
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue