diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/controller/ArticleManageController.java b/ruoyi-content/src/main/java/com/ruoyi/content/controller/ArticleManageController.java index 02c3caa41..c3d3ff2dd 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/controller/ArticleManageController.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/controller/ArticleManageController.java @@ -14,7 +14,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -304,7 +303,6 @@ public class ArticleManageController extends BaseController { * 保存(更新)文章静态页面 @Title: updateArticle @Description: TODO() @param @return * 参数 @return Message 返回类型 @throws */ - @CrossOrigin(allowCredentials = "true", allowedHeaders = "*", origins = "*", maxAge = 1800) @RequestMapping("/updateArticle") @ResponseBody public Message updateArticle(HttpServletRequest request, HttpServletResponse response) { diff --git a/ruoyi-content/src/main/resources/templates/content/article/articleManage.html b/ruoyi-content/src/main/resources/templates/content/article/articleManage.html index 90ccbe510..0ae2d97d5 100644 --- a/ruoyi-content/src/main/resources/templates/content/article/articleManage.html +++ b/ruoyi-content/src/main/resources/templates/content/article/articleManage.html @@ -1017,7 +1017,7 @@ cache: false, success: function (data) { if (data.result) { - $.modal.open('文章预览', data.object.editUrl) + $.modal.open('文章预览', data.object.editUrl + '?l=1') } else { $.modal.alertError("预览失败,请稍后重试!"); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java index d6feedb82..061fd4aaa 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java @@ -269,6 +269,7 @@ public class ShiroConfig // Shiro连接约束配置,即过滤链的定义 LinkedHashMap filterChainDefinitionMap = new LinkedHashMap<>(); // 对静态资源设置匿名访问 + filterChainDefinitionMap.put("/article/updateArticle", "anon"); filterChainDefinitionMap.put("/favicon.ico**", "anon"); filterChainDefinitionMap.put("/ruoyi.png**", "anon"); filterChainDefinitionMap.put("/css/**", "anon"); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java index 35076b595..c7801333c 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java @@ -3,6 +3,8 @@ package com.ruoyi.framework.interceptor; import java.lang.reflect.Method; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; @@ -13,40 +15,42 @@ import com.ruoyi.common.utils.ServletUtils; /** * 防止重复提交拦截器 - * + * * @author ruoyi */ @Component -public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter -{ +public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter { @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception - { - if (handler instanceof HandlerMethod) - { + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + response.setHeader("Access-control-Allow-Origin", request.getHeader("Origin")); + response.setHeader("Access-Control-Allow-Credentials", "true"); + response.setHeader("Access-Control-Allow-Headers", request.getHeader("Access-Control-Request-Headers")); + response.addHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT"); + if ("OPTIONS".equals(request.getMethod())) { + response.setStatus(HttpStatus.OK.value()); + return false; + } + + if (handler instanceof HandlerMethod) { HandlerMethod handlerMethod = (HandlerMethod) handler; Method method = handlerMethod.getMethod(); RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class); - if (annotation != null) - { - if (this.isRepeatSubmit(request)) - { + if (annotation != null) { + if (this.isRepeatSubmit(request)) { AjaxResult ajaxResult = AjaxResult.error("不允许重复提交,请稍后再试"); ServletUtils.renderString(response, JSON.marshal(ajaxResult)); return false; } } return true; - } - else - { + } else { return super.preHandle(request, response, handler); } } /** * 验证是否重复提交由子类实现具体的防重复提交的规则 - * + * * @param request * @return * @throws Exception