diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index b68ecae7..8188197b 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -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 = "
" . token() . "
"; - $html .= ""; - - return $html; + return $this->view->fetch(); } } diff --git a/application/admin/lang/zh-cn/index.php b/application/admin/lang/zh-cn/index.php index dcb72058..8873cb66 100644 --- a/application/admin/lang/zh-cn/index.php +++ b/application/admin/lang/zh-cn/index.php @@ -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' => '清除缓存失败', diff --git a/application/admin/view/index/logout.html b/application/admin/view/index/logout.html new file mode 100644 index 00000000..2f6f908e --- /dev/null +++ b/application/admin/view/index/logout.html @@ -0,0 +1,47 @@ + + + + {include file="common/meta" /} + + + + +
+
+
+ +
+

{:__('Are you sure you want to sign out?')}

+
+ {:token()} +
+ +
+
+
+
+{include file="common/script" /} + + diff --git a/public/assets/js/backend/index.js b/public/assets/js/backend/index.js index 9b17b378..7ddc54de 100755 --- a/public/assets/js/backend/index.js +++ b/public/assets/js/backend/index.js @@ -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(); },