mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-08 01:48:33 +08:00
theme fix
This commit is contained in:
parent
b378920fcb
commit
79b25624fe
@ -9,6 +9,8 @@ import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.maxkey.constants.ConstantsTimeInterval;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
@ -30,6 +32,9 @@ public class ThemeTagDirective implements TemplateDirectiveModel {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
HttpServletResponse response;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public void execute(Environment env,
|
||||
@ -49,6 +54,15 @@ public class ThemeTagDirective implements TemplateDirectiveModel {
|
||||
_logger.trace("read theme form cookie , theme is " + theme);
|
||||
}
|
||||
}
|
||||
|
||||
//每次登陆完成设置一次COOKIE
|
||||
if (request.getAttribute(WebConstants.THEME_COOKIE_NAME) == null
|
||||
&& null != WebContext.getUserInfo()) {
|
||||
request.setAttribute(WebConstants.THEME_COOKIE_NAME, "theme");
|
||||
WebContext.setCookie(response,
|
||||
WebConstants.THEME_COOKIE_NAME, theme, ConstantsTimeInterval.ONE_WEEK);
|
||||
}
|
||||
|
||||
env.getOut().append(theme == null ? "default" : theme);
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.maxkey.constants.ConstantsOperateMessage;
|
||||
import org.maxkey.constants.ConstantsTimeInterval;
|
||||
import org.maxkey.crypto.ReciprocalUtils;
|
||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.maxkey.dao.service.UserInfoService;
|
||||
@ -171,7 +172,7 @@ public class SafeController {
|
||||
userInfo.setEmail(email);
|
||||
|
||||
userInfo.setTheme(theme);
|
||||
WebContext.setCookie(response, WebConstants.THEME_COOKIE_NAME, theme, 0);
|
||||
WebContext.setCookie(response, WebConstants.THEME_COOKIE_NAME, theme, ConstantsTimeInterval.ONE_WEEK);
|
||||
|
||||
userInfoService.changeEmail(userInfo);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user