修改服务注册地址

This commit is contained in:
haozq 2025-08-20 09:34:11 +08:00
parent 1815b37547
commit acd2ed7b7f
4 changed files with 44 additions and 6 deletions

View File

@ -39,7 +39,12 @@ public class JwtUtils
*/ */
public static Claims parseToken(String token) public static Claims parseToken(String token)
{ {
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody(); try{
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
}catch (Exception e){
System.err.println("token不正确--->"+token);
return null;
}
} }
/** /**

View File

@ -63,7 +63,7 @@ public class AuthFilter implements GlobalFilter, Ordered
return chain.filter(exchange); return chain.filter(exchange);
} }
String token = getToken(request); String token = getToken(request);
if (StringUtils.isEmpty(token)) if (StringUtils.isEmpty(token) )
{ {
return unauthorizedResponse(exchange, "令牌不能为空"); return unauthorizedResponse(exchange, "令牌不能为空");
} }

View File

@ -1,5 +1,14 @@
let Authorization = localStorage.getItem("smz-token"); let Authorization = localStorage.getItem("smz-token");
$(document).ajaxSuccess(function (event, xhr, settings, data) {
if(data.code===401){
localStorage.removeItem("smz-token");
top.location.href = ctxPath + '/login.html';
}
return data;
});
$.ajaxSetup({ $.ajaxSetup({
cache : false, cache : false,
headers : { headers : {
@ -18,12 +27,12 @@ $.ajaxSetup({
var response = JSON.parse(msg); var response = JSON.parse(msg);
var code = response.code; var code = response.code;
var message = response.message; var message = response.message;
if (code == 400) { if (code === 400) {
layer.msg(message); layer.msg(message);
} else if (code == 401) { } else if (code === 401) {
localStorage.removeItem("smz-token"); localStorage.removeItem("smz-token");
location.href = '/login.html'; top.location.href = ctxPath + '/login.html';
} else if (code == 403) { } else if (code === 403) {
console.log("未授权:" + message); console.log("未授权:" + message);
layer.msg('未授权'); layer.msg('未授权');
} else if (code == 500) { } else if (code == 500) {

View File

@ -20,6 +20,12 @@ function initMenu() {
location.href = ctxPath + '/login.html'; location.href = ctxPath + '/login.html';
return; return;
} }
if (data.code==401) {
//redis的token未获取到权限
// alert("权限已过期,请重新登录");
location.href = ctxPath + '/login.html';
return;
}
var menu = $("#menu"); var menu = $("#menu");
$.each(data, function (i, item) { $.each(data, function (i, item) {
var a = $("<a href='javascript:;'></a>"); var a = $("<a href='javascript:;'></a>");
@ -48,6 +54,9 @@ function initMenu() {
setChild(li, item.child) setChild(li, item.child)
}); });
},
error : function (e){
location.href = ctxPath + '/login.html';
} }
}); });
} }
@ -93,6 +102,12 @@ function showLoginInfo() {
}, },
async: false, async: false,
success: function (data) { success: function (data) {
if (data.code==401) {
//redis的token未获取到权限
// alert("权限已过期,请重新登录");
location.href = ctxPath + '/login.html';
return;
}
$(".admin-header-user span").text(data.nickname); $(".admin-header-user span").text(data.nickname);
var pro = window.location.protocol; var pro = window.location.protocol;
@ -130,8 +145,17 @@ function logout() {
"Authorization": token "Authorization": token
}, },
success: function (data) { success: function (data) {
if (data.code==401) {
//redis的token未获取到权限
// alert("权限已过期,请重新登录");
location.href = ctxPath + '/login.html';
return;
}
localStorage.removeItem("smz-token"); localStorage.removeItem("smz-token");
location.href = ctxPath + '/login.html'; location.href = ctxPath + '/login.html';
},
error : function (e){
location.href = ctxPath + '/login.html';
} }
}); });
// var userAgent = navigator.userAgent.toLowerCase(); // var userAgent = navigator.userAgent.toLowerCase();