fix(admin): 后台入口 /admin /login 用 sendRedirect 产生真实 302
@RestController 下返回 redirect: 字符串只会原样写进 200 响应体, 浏览器不会跳转。页面入口方法改为 HttpServletResponse.sendRedirect 302 到 /admin-vue/,旧 /admin.html、/login.html 一并兜底。
This commit is contained in:
+10
-8
@@ -9,10 +9,12 @@ import com.nanri.aiimage.modules.permission.service.support.AdminMenuTreeBuilder
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -37,26 +39,26 @@ public class AdminConsoleController {
|
||||
|
||||
@GetMapping("/")
|
||||
@Operation(summary = "根路径跳管理后台", hidden = true)
|
||||
public String root() {
|
||||
return "redirect:/admin-vue/";
|
||||
public void root(HttpServletResponse response) throws IOException {
|
||||
response.sendRedirect("/admin-vue/");
|
||||
}
|
||||
|
||||
@GetMapping({"/admin", "/admin.html"})
|
||||
@Operation(summary = "管理后台入口(含旧 /admin.html 兜底)", hidden = true)
|
||||
public String adminPage() {
|
||||
return "redirect:/admin-vue/";
|
||||
public void adminPage(HttpServletResponse response) throws IOException {
|
||||
response.sendRedirect("/admin-vue/");
|
||||
}
|
||||
|
||||
@GetMapping({"/login", "/login.html"})
|
||||
@Operation(summary = "登录页入口(含旧 /login.html 兜底)", hidden = true)
|
||||
public String loginPage() {
|
||||
return "redirect:/admin-vue/login";
|
||||
public void loginPage(HttpServletResponse response) throws IOException {
|
||||
response.sendRedirect("/admin-vue/login");
|
||||
}
|
||||
|
||||
@GetMapping("/logout")
|
||||
@Operation(summary = "登出 GET 兜底(POST 走 auth 模块)", hidden = true)
|
||||
public String logoutPage() {
|
||||
return "redirect:/admin-vue/login";
|
||||
public void logoutPage(HttpServletResponse response) throws IOException {
|
||||
response.sendRedirect("/admin-vue/login");
|
||||
}
|
||||
|
||||
@GetMapping("/api/admin/current-user")
|
||||
|
||||
Reference in New Issue
Block a user