From 065c9884ad58c19e36cb1fa3ec7f7c269ed206e6 Mon Sep 17 00:00:00 2001 From: Leo <98382335+gaoziman@users.noreply.github.com> Date: Sun, 6 Jul 2025 22:56:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=85=8D=E7=BD=AESa-Token=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E5=99=A8=E6=8E=92=E9=99=A4=E9=9D=99=E6=80=81=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=92=8CAPI=E6=96=87=E6=A1=A3=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加静态资源路径排除配置(/picture/**、/static/**等) - 添加API文档路径排除配置(/swagger-ui/**、/v3/api-docs/**等) - 优化拦截器配置以提高性能和用户体验 --- .../thin/satoken/config/SaTokenConfigure.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/coder-common-thin-plugins/coder-common-thin-sa-token/src/main/java/org/leocoder/thin/satoken/config/SaTokenConfigure.java b/coder-common-thin-plugins/coder-common-thin-sa-token/src/main/java/org/leocoder/thin/satoken/config/SaTokenConfigure.java index ccc073f..324f504 100755 --- a/coder-common-thin-plugins/coder-common-thin-sa-token/src/main/java/org/leocoder/thin/satoken/config/SaTokenConfigure.java +++ b/coder-common-thin-plugins/coder-common-thin-sa-token/src/main/java/org/leocoder/thin/satoken/config/SaTokenConfigure.java @@ -17,7 +17,23 @@ public class SaTokenConfigure implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { // 注册 Sa-Token 拦截器,打开注解式鉴权功能 - registry.addInterceptor(new SaInterceptor()).addPathPatterns("/**"); + registry.addInterceptor(new SaInterceptor()) + .addPathPatterns("/**") + .excludePathPatterns( + // 排除静态资源 + "/picture/**", + // 排除其他静态资源 + "/favicon.ico", + "/static/**", + "/css/**", + "/js/**", + "/img/**", + // 排除API文档 + "/swagger-ui/**", + "/v3/api-docs/**", + "/swagger-ui.html", + "/webjars/**" + ); } }