优化体验,当关闭多地登录,且被挤下时,给予用户提示,而不是直接跳转登录页
This commit is contained in:
@@ -29,7 +29,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在线用户Controller
|
* 在线用户Controller
|
||||||
@@ -51,6 +53,7 @@ public class OnlineController extends BaseController{
|
|||||||
* @param response
|
* @param response
|
||||||
* @author ThinkGem
|
* @author ThinkGem
|
||||||
*/
|
*/
|
||||||
|
@RequiresPermissions("user")
|
||||||
@RequestMapping(value = "count")
|
@RequestMapping(value = "count")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Integer count(HttpServletRequest request, HttpServletResponse response) {
|
public Integer count(HttpServletRequest request, HttpServletResponse response) {
|
||||||
@@ -158,7 +161,7 @@ public class OnlineController extends BaseController{
|
|||||||
if (pc instanceof PrincipalCollection){
|
if (pc instanceof PrincipalCollection){
|
||||||
Object pp = ((PrincipalCollection)pc).getPrimaryPrincipal();
|
Object pp = ((PrincipalCollection)pc).getPrimaryPrincipal();
|
||||||
if (pp instanceof LoginInfo){
|
if (pp instanceof LoginInfo){
|
||||||
LoginInfo loginInfo = ((LoginInfo)pp);
|
LoginInfo loginInfo = (LoginInfo)pp;
|
||||||
String key = loginInfo.getId()+"_"+loginInfo.getParam("deviceType", "pc");
|
String key = loginInfo.getId()+"_"+loginInfo.getParam("deviceType", "pc");
|
||||||
onlineTickOutMap.put(key, StringUtils.EMPTY);
|
onlineTickOutMap.put(key, StringUtils.EMPTY);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
data-mergeMsgLimit="${@Global.getConfig('sys.msg.mergeMsgLimit', '5')}"
|
data-mergeMsgLimit="${@Global.getConfig('sys.msg.mergeMsgLimit', '5')}"
|
||||||
data-mergeMsgTitle="${text('系统消息')}"
|
data-mergeMsgTitle="${text('系统消息')}"
|
||||||
data-mergeMsgContent="${text('您有 {0\} 条新消息,由于消息太多,这里为您合并,请点击查看按钮看详情。')}"
|
data-mergeMsgContent="${text('您有 {0\} 条新消息,由于消息太多,这里为您合并,请点击查看按钮看详情。')}"
|
||||||
data-loginTimeout="${text('您当前的会话已超时,请重新登录。')}"
|
|
||||||
data-pullMsgPollingInterval="1000*60"
|
data-pullMsgPollingInterval="1000*60"
|
||||||
data-showMsgCloseTimeout="1000*60"></ul>
|
data-showMsgCloseTimeout="1000*60"></ul>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -5,15 +5,32 @@
|
|||||||
</a>
|
</a>
|
||||||
<script>
|
<script>
|
||||||
function refreshOnlineCount(){
|
function refreshOnlineCount(){
|
||||||
$.get('${ctx}/sys/online/count?__notUpdateSession=true&__t='
|
function ajaxCallback(data) {
|
||||||
+ new Date().getTime(), function(data){
|
if (data && data.message){
|
||||||
if (!(data && data.result != 'login')){
|
if (data.result == 'false' || data.result == 'login') {
|
||||||
if (window.rocInt) {
|
if (window.rocInt) clearInterval(window.rocInt);
|
||||||
clearInterval(window.rocInt);
|
if (window.ppmInt) clearInterval(window.ppmInt);
|
||||||
|
}
|
||||||
|
js.confirm(data.message, function(){
|
||||||
|
location.reload(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try{$('#onlineCount').html(Number(data || 0))}catch(e){}
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: ctx+'/sys/online/count?__notUpdateSession=true&__t=' + new Date().getTime(),
|
||||||
|
method: 'GET',
|
||||||
|
success: function(data) {
|
||||||
|
ajaxCallback(data);
|
||||||
|
},
|
||||||
|
error: function(jqXHR) {
|
||||||
|
try {
|
||||||
|
ajaxCallback(JSON.parse(jqXHR.responseText));
|
||||||
|
} catch (e) {
|
||||||
|
ajaxCallback({message: jqXHR.responseText});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try{$('#onlineCount').html(Number(data))}catch(e){}
|
});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
refreshOnlineCount(); // 先执行一次
|
refreshOnlineCount(); // 先执行一次
|
||||||
window.rocInt = setInterval(refreshOnlineCount, 180000); // 3分钟执行一次
|
window.rocInt = setInterval(refreshOnlineCount, 180000); // 3分钟执行一次
|
||||||
|
|||||||
Reference in New Issue
Block a user