From 6ebde793bdcc2862e74f57630851b26bce637919 Mon Sep 17 00:00:00 2001 From: Karson Date: Fri, 16 Jun 2023 14:38:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86JS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/backend/addon.js | 81 +++++++++++++++++-------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/public/assets/js/backend/addon.js b/public/assets/js/backend/addon.js index c3d56735..6b139114 100644 --- a/public/assets/js/backend/addon.js +++ b/public/assets/js/backend/addon.js @@ -92,7 +92,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie'] uid: userinfo ? userinfo.id : '', token: userinfo ? userinfo.token : '', domain: Config.domain, - version: Config.faversion + version: Config.faversion, + sid: Controller.api.sid() }); return params; }, @@ -297,7 +298,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie'] url: Config.api_url + '/user/logintpl', type: 'post', data: { - version: Config.faversion + version: Config.faversion, + sid: Controller.api.sid() } }, function (tpldata, ret) { Layer.open({ @@ -310,6 +312,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie'] yes: function (index, layero) { var data = $("form", layero).serializeArray(); data.push({name: "faversion", value: Config.faversion}); + data.push({name: "sid", value: Controller.api.sid()}); Fast.api.ajax({ url: Config.api_url + '/user/login', type: 'post', @@ -342,45 +345,43 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie'] url: Config.api_url + '/user/userinfotpl', type: 'post', data: { - version: Config.faversion + uid: userinfo.id, + token: userinfo.token, + version: Config.faversion, + sid: Controller.api.sid() } }, function (tpldata, ret) { - Fast.api.ajax({ - url: Config.api_url + '/user/index', - data: { - uid: userinfo.id, - token: userinfo.token, - version: Config.faversion, + Layer.open({ + content: Template.render(tpldata, userinfo), + area: area, + title: __('Userinfo'), + resize: false, + btn: [__('Logout'), __('Close')], + yes: function () { + Fast.api.ajax({ + url: Config.api_url + '/user/logout', + data: { + uid: userinfo.id, + token: userinfo.token, + version: Config.faversion, + sid: Controller.api.sid() + } + }, function (data, ret) { + Controller.api.userinfo.set(null); + Layer.closeAll(); + Layer.alert(ret.msg, {title: __('Warning'), icon: 0}); + }, function (data, ret) { + Controller.api.userinfo.set(null); + Layer.closeAll(); + Layer.alert(ret.msg, {title: __('Warning'), icon: 0}); + }); } - }, function (data) { - Layer.open({ - content: Template.render(tpldata, userinfo), - area: area, - title: __('Userinfo'), - resize: false, - btn: [__('Logout'), __('Close')], - yes: function () { - Fast.api.ajax({ - url: Config.api_url + '/user/logout', - data: {uid: userinfo.id, token: userinfo.token, version: Config.faversion} - }, function (data, ret) { - Controller.api.userinfo.set(null); - Layer.closeAll(); - Layer.alert(ret.msg, {title: __('Warning'), icon: 0}); - }, function (data, ret) { - Controller.api.userinfo.set(null); - Layer.closeAll(); - Layer.alert(ret.msg, {title: __('Warning'), icon: 0}); - }); - } - }); - return false; - }, function (data) { - Controller.api.userinfo.set(null); - $(that).trigger('click'); - return false; }); return false; + }, function (data) { + Controller.api.userinfo.set(null); + $(that).trigger('click'); + return false; }); } }); @@ -774,6 +775,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie'] } } }, + sid: function () { + var sid = $.cookie('fastadmin_sid'); + if (!sid) { + sid = Math.random().toString(20).substr(2, 12); + $.cookie('fastadmin_sid', sid); + } + return sid; + }, refresh: function (table, name) { //刷新左侧边栏 Fast.api.refreshmenu();