mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-10-14 22:00:25 +00:00
build 嵌入前端项目处理, 支持webhistory模式
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -14,3 +14,5 @@ target/
|
|||||||
build/
|
build/
|
||||||
logs/
|
logs/
|
||||||
rebel.xml
|
rebel.xml
|
||||||
|
/daxpay-single-server/src/main/resources/static/web/
|
||||||
|
/daxpay-single-server/src/main/resources/static/h5/
|
||||||
|
@@ -0,0 +1,24 @@
|
|||||||
|
package org.dromara.daxpay;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前端转发
|
||||||
|
* @author xxm
|
||||||
|
* @since 2024/10/6
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
public class FrontController {
|
||||||
|
|
||||||
|
@RequestMapping(value = {"/h5", "/h5/"})
|
||||||
|
public ModelAndView h5IndexForward() {
|
||||||
|
return new ModelAndView("/h5/index.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = {"/web", "/web/"})
|
||||||
|
public ModelAndView webIndexForward() {
|
||||||
|
return new ModelAndView("/web/index.html");
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,32 @@
|
|||||||
|
package org.dromara.daxpay;
|
||||||
|
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移动端前端转发
|
||||||
|
* @author xxm
|
||||||
|
* @since 2024/10/6
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class FrontH5Interceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
String requestURI = request.getRequestURI();
|
||||||
|
|
||||||
|
// 检查请求 URI 是否包含 "."(即文件后缀名)
|
||||||
|
if (requestURI.contains(".")) {
|
||||||
|
// 对于静态资源,继续处理
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不包含后缀的路径,转发到 index.html
|
||||||
|
request.getRequestDispatcher("/h5/index.html").forward(request, response);
|
||||||
|
// 阻止继续处理请求
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,23 @@
|
|||||||
|
package org.dromara.daxpay;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前端转发配置
|
||||||
|
* @author xxm
|
||||||
|
* @since 2024/10/6
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class FrontWebConfig implements WebMvcConfigurer {
|
||||||
|
private final FrontH5Interceptor h5Interceptor;
|
||||||
|
private final FrontWebInterceptor webInterceptor;
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(h5Interceptor).addPathPatterns("/h5/**");
|
||||||
|
registry.addInterceptor(webInterceptor).addPathPatterns("/web/**");
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,31 @@
|
|||||||
|
package org.dromara.daxpay;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理端前端转发
|
||||||
|
* @author xxm
|
||||||
|
* @since 2024/10/6
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class FrontWebInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
String requestURI = request.getRequestURI();
|
||||||
|
|
||||||
|
// 检查请求 URI 是否包含 "."(即文件后缀名)
|
||||||
|
if (requestURI.contains(".")) {
|
||||||
|
// 对于静态资源,继续处理
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不包含后缀的路径,转发到 index.html
|
||||||
|
request.getRequestDispatcher("/web/index.html").forward(request, response);
|
||||||
|
// 阻止继续处理请求
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@@ -66,7 +66,7 @@ bootx-platform:
|
|||||||
- '/demo/**'
|
- '/demo/**'
|
||||||
- '/test/**'
|
- '/test/**'
|
||||||
- '/webjars/**'
|
- '/webjars/**'
|
||||||
- '/front/**'
|
- '/web/**'
|
||||||
- '/h5/**'
|
- '/h5/**'
|
||||||
- '/css/**'
|
- '/css/**'
|
||||||
- '/error'
|
- '/error'
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 9.4 KiB |
@@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/unipay/assist/channel/auth")
|
@RequestMapping("/unipay/assist/channel/auth")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ChannelAuthController {
|
public class ChannelUniAuthController {
|
||||||
|
|
||||||
private final ChannelAuthService channelAuthService;
|
private final ChannelAuthService channelAuthService;
|
||||||
|
|
Reference in New Issue
Block a user