diff --git a/mms-admin/src/main/resources/template/html/favicon.ico b/mms-admin/src/main/resources/template/html/favicon.ico
new file mode 100644
index 0000000..3baea80
Binary files /dev/null and b/mms-admin/src/main/resources/template/html/favicon.ico differ
diff --git a/mms-admin/src/main/resources/template/html/holle.html b/mms-admin/src/main/resources/template/html/holle.html
new file mode 100644
index 0000000..04ac247
--- /dev/null
+++ b/mms-admin/src/main/resources/template/html/holle.html
@@ -0,0 +1,10 @@
+
+
+
+
+
Thymeleaf Demo
+
+
+
默认文本(当Thymeleaf未渲染时显示)
+
+
diff --git a/mms-modules/mms-common/src/main/java/com/sxpcwlkj/common/properties/WebThymeleafProperties.java b/mms-modules/mms-common/src/main/java/com/sxpcwlkj/common/properties/WebThymeleafProperties.java
new file mode 100644
index 0000000..1f4b866
--- /dev/null
+++ b/mms-modules/mms-common/src/main/java/com/sxpcwlkj/common/properties/WebThymeleafProperties.java
@@ -0,0 +1,20 @@
+package com.sxpcwlkj.common.properties;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author shanpengnian
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "spring.web")
+public class WebThymeleafProperties {
+
+ private Boolean isOpen;
+ /**
+ * 排除路径
+ */
+ private String[] excludes;
+}
diff --git a/mms-modules/mms-framework/pom.xml b/mms-modules/mms-framework/pom.xml
index 1a009e7..c54f946 100644
--- a/mms-modules/mms-framework/pom.xml
+++ b/mms-modules/mms-framework/pom.xml
@@ -106,6 +106,12 @@
com.sxpcwlkj
mms-common
+
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
diff --git a/mms-modules/mms-framework/src/main/java/com/sxpcwlkj/framework/controller/FrameworkController.java b/mms-modules/mms-framework/src/main/java/com/sxpcwlkj/framework/controller/FrameworkController.java
index 610bfaa..2371b8a 100644
--- a/mms-modules/mms-framework/src/main/java/com/sxpcwlkj/framework/controller/FrameworkController.java
+++ b/mms-modules/mms-framework/src/main/java/com/sxpcwlkj/framework/controller/FrameworkController.java
@@ -1,11 +1,14 @@
package com.sxpcwlkj.framework.controller;
import cn.dev33.satoken.annotation.SaIgnore;
+import cn.hutool.core.lang.Console;
import com.sxpcwlkj.common.annotation.RateLimit;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
@@ -13,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
*
* @author shanpengnian
*/
-@RestController
+@Controller
@RequiredArgsConstructor
public class FrameworkController {
@@ -35,15 +38,23 @@ public class FrameworkController {
*
* @return 系统信息
*/
-// @RateLimit(permitsPerSecond = 1.0) // 每秒允许 1 个请求
-// @SaIgnore
-// @GetMapping("/")
-// public String index() {
-// return "Hello " + name + "! V" + version;
-// }
+ @RateLimit(permitsPerSecond = 1.0) // 每秒允许 1 个请求
+ @SaIgnore
+ @GetMapping("/")
+ @ResponseBody
+ public String index() {
+ return "Hello " + name + "! V" + version;
+ }
+
+ @RateLimit(permitsPerSecond = 1.0) // 每秒允许 1 个请求
+ @SaIgnore
+ @GetMapping("/ai")
+ public String ai() {
+ return "ai/index";
+ }
@PostConstruct
public void init() {
-
+ Console.log("========== Hello" + name + "! V" + version+" ==========");
}
}
diff --git a/mms-modules/mms-framework/src/main/java/com/sxpcwlkj/framework/controller/GlobalModelAttributes.java b/mms-modules/mms-framework/src/main/java/com/sxpcwlkj/framework/controller/GlobalModelAttributes.java
new file mode 100644
index 0000000..3c4a484
--- /dev/null
+++ b/mms-modules/mms-framework/src/main/java/com/sxpcwlkj/framework/controller/GlobalModelAttributes.java
@@ -0,0 +1,30 @@
+package com.sxpcwlkj.framework.controller;
+
+import jakarta.servlet.ServletContext;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ModelAttribute;
+
+@ControllerAdvice
+@RequiredArgsConstructor
+public class GlobalModelAttributes {
+
+
+ private final ServletContext servletContext;
+
+ // 注入上下文路径(如 /myapp)
+ @ModelAttribute("ctx")
+ public String contextPath() {
+ return servletContext.getContextPath();
+ }
+
+ // 可选:注入静态资源 CDN 前缀(需在配置文件中定义)
+ @Value("${spring.thymeleaf.static-resource-url:}")
+ private String staticResourceUrl;
+
+ @ModelAttribute("staticCdn")
+ public String staticCdn() {
+ return staticResourceUrl;
+ }
+}
diff --git a/mms-modules/mms-framework/src/main/java/com/sxpcwlkj/framework/handler/WebMvcConfigurerHandler.java b/mms-modules/mms-framework/src/main/java/com/sxpcwlkj/framework/handler/WebMvcConfigurerHandler.java
index 63c8474..621eeeb 100644
--- a/mms-modules/mms-framework/src/main/java/com/sxpcwlkj/framework/handler/WebMvcConfigurerHandler.java
+++ b/mms-modules/mms-framework/src/main/java/com/sxpcwlkj/framework/handler/WebMvcConfigurerHandler.java
@@ -1,7 +1,10 @@
package com.sxpcwlkj.framework.handler;
+import com.sxpcwlkj.common.properties.WebThymeleafProperties;
import jakarta.validation.constraints.NotNull;
+import lombok.RequiredArgsConstructor;
+import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
@@ -16,12 +19,19 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
* 跨域请求配置
*/
@Configuration
+@RequiredArgsConstructor
public class WebMvcConfigurerHandler implements WebMvcConfigurer {
+
+ private final WebThymeleafProperties webThymeleafProperties;
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 全局访问性能拦截
- registry.addInterceptor(new WebHandlerInterceptorHandler());
+ registry.addInterceptor(new WebHandlerInterceptorHandler())
+ // 拦截所有路径
+ .addPathPatterns("/**")
+ .excludePathPatterns(webThymeleafProperties.getExcludes());
+ ;
}
@Override