Skip to content

Commit

Permalink
refactor: move pages
Browse files Browse the repository at this point in the history
  • Loading branch information
cubewhy committed Oct 13, 2024
1 parent 17949f1 commit 3c450e9
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/fuck/manthe/nmsl/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ public class SecurityConfig {
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(conf -> conf
.requestMatchers("/user/**").authenticated()
.requestMatchers("/user/redeem").permitAll()
.requestMatchers("/user/**").authenticated()
.requestMatchers("/dashboard").authenticated()
.requestMatchers("/admin/**").hasAuthority("ADMIN")
.requestMatchers("/webui**", "/webui/**").authenticated()
.requestMatchers("/api/v2/**").authenticated()
.anyRequest().permitAll()
)
.formLogin((form) -> form
.loginPage("/login")
.loginPage("/user/login")
.permitAll()
)
.formLogin(AbstractAuthenticationFilterConfigurer::permitAll)
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/fuck/manthe/nmsl/controller/WebController.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ public String queue() {
return "queue";
}

@Deprecated
@GetMapping("redeem")
public String register() {
return "redirect:/user/redeem";
}

@GetMapping("user/redeem")
public String redeem() {
return "redeem";
}

@GetMapping("login")
@GetMapping("user/login")
public String login() {
return "login";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
if (maintenanceService.isMaintaining()) {
String path = request.getRequestURI();

if (path.equals("/") || path.equals("/redeem")) {
if (path.equals("/") || path.equals("/user/redeem")) {
response.sendRedirect("/maintain?redirect=" + request.getRequestURI());
return;
}
Expand Down
14 changes: 13 additions & 1 deletion src/main/resources/templates/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@
// }

// 页面加载完成后加载首页内容
document.addEventListener('DOMContentLoaded', () => loadContent('home'));
// document.addEventListener('DOMContentLoaded', () => loadContent('home'));
window.onload = function () {
const hash = window.location.hash; // 获取哈希值,例如 #page1
if (hash) {
const page = hash.substring(1); // 去掉前面的 #
loadContent(page); // 调用 loadContent 函数
} else {
loadContent('home');
}
};
</script>

<script>
Expand Down Expand Up @@ -119,6 +128,9 @@
let regDetectJs = /<script(.|\n)*?>(.|\n|\r\n)*?<\/script>/ig;
// 修改 loadContent 函数以包含管理员密码
function loadContent(url) {
if (window.location.hash !== url) {
window.location.hash = url;
}
fetch(`dashboard/${url}`, {
headers: {
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ <h2>平台介绍</h2>
<img alt="Static Badge"
src="https://img.shields.io/badge/channel-Telegram?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI%2BPHBhdGggZD0iTTEyIDI0YzYuNjI3IDAgMTItNS4zNzMgMTItMTJTMTguNjI3IDAgMTIgMCAwIDUuMzczIDAgMTJzNS4zNzMgMTIgMTIgMTJaIiBmaWxsPSJ1cmwoI2EpIi8%2BPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQyNSAxMS44NzFhNzk2LjQxNCA3OTYuNDE0IDAgMCAxIDYuOTk0LTMuMDE4YzMuMzI4LTEuMzg4IDQuMDI3LTEuNjI4IDQuNDc3LTEuNjM4LjEgMCAuMzIuMDIuNDcuMTQuMTIuMS4xNS4yMy4xNy4zMy4wMi4xLjA0LjMxLjAyLjQ3LS4xOCAxLjg5OC0uOTYgNi41MDQtMS4zNiA4LjYyMi0uMTcuOS0uNSAxLjE5OS0uODE5IDEuMjI5LS43LjA2LTEuMjI5LS40Ni0xLjg5OC0uOS0xLjA2LS42ODktMS42NDktMS4xMTktMi42NzgtMS43OTgtMS4xOS0uNzgtLjQyLTEuMjA5LjI2LTEuOTA4LjE4LS4xOCAzLjI0Ny0yLjk3OCAzLjMwNy0zLjIyOC4wMS0uMDMuMDEtLjE1LS4wNi0uMjEtLjA3LS4wNi0uMTctLjA0LS4yNS0uMDItLjExLjAyLTEuNzg4IDEuMTQtNS4wNTYgMy4zNDgtLjQ4LjMzLS45MDkuNDktMS4yOTkuNDgtLjQzLS4wMS0xLjI0OC0uMjQtMS44NjgtLjQ0LS43NS0uMjQtMS4zNDktLjM3LTEuMjk5LS43OS4wMy0uMjIuMzMtLjQ0Ljg5LS42NjlaIiBmaWxsPSIjZmZmIi8%2BPGRlZnM%2BPGxpbmVhckdyYWRpZW50IGlkPSJhIiB4MT0iMTEuOTkiIHkxPSIwIiB4Mj0iMTEuOTkiIHkyPSIyMy44MSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIHN0b3AtY29sb3I9IiMyQUFCRUUiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMyMjlFRDkiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48L3N2Zz4K&label=Telegram">
</a>
<a href="https://github.com/CubeWhyMC/DingZhenServlet">
<img alt="Static Badge"
src="https://img.shields.io/github/stars/CubeWhyMC/DingZhenServlet">
</a>
<p class="highlight">这是一个Minecraft Cheat服务, 不要DDoS我们的服务, 谢谢</p>

<p>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div class="mdui-text-color-green" th:if="${param.logout}">
成功登出
</div>
<form class="mdui-p-t-2" method="post" th:action="@{/login}">
<form class="mdui-p-t-2" method="post" th:action="@{/user/login}">
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">用户名</label>
<input class="mdui-textfield-input" name="username" required type="text"/>
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/templates/maintain.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ <h1>维护中</h1>
<img alt="Static Badge"
src="https://img.shields.io/badge/channel-Telegram?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI%2BPHBhdGggZD0iTTEyIDI0YzYuNjI3IDAgMTItNS4zNzMgMTItMTJTMTguNjI3IDAgMTIgMCAwIDUuMzczIDAgMTJzNS4zNzMgMTIgMTIgMTJaIiBmaWxsPSJ1cmwoI2EpIi8%2BPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQyNSAxMS44NzFhNzk2LjQxNCA3OTYuNDE0IDAgMCAxIDYuOTk0LTMuMDE4YzMuMzI4LTEuMzg4IDQuMDI3LTEuNjI4IDQuNDc3LTEuNjM4LjEgMCAuMzIuMDIuNDcuMTQuMTIuMS4xNS4yMy4xNy4zMy4wMi4xLjA0LjMxLjAyLjQ3LS4xOCAxLjg5OC0uOTYgNi41MDQtMS4zNiA4LjYyMi0uMTcuOS0uNSAxLjE5OS0uODE5IDEuMjI5LS43LjA2LTEuMjI5LS40Ni0xLjg5OC0uOS0xLjA2LS42ODktMS42NDktMS4xMTktMi42NzgtMS43OTgtMS4xOS0uNzgtLjQyLTEuMjA5LjI2LTEuOTA4LjE4LS4xOCAzLjI0Ny0yLjk3OCAzLjMwNy0zLjIyOC4wMS0uMDMuMDEtLjE1LS4wNi0uMjEtLjA3LS4wNi0uMTctLjA0LS4yNS0uMDItLjExLjAyLTEuNzg4IDEuMTQtNS4wNTYgMy4zNDgtLjQ4LjMzLS45MDkuNDktMS4yOTkuNDgtLjQzLS4wMS0xLjI0OC0uMjQtMS44NjgtLjQ0LS43NS0uMjQtMS4zNDktLjM3LTEuMjk5LS43OS4wMy0uMjIuMzMtLjQ0Ljg5LS42NjlaIiBmaWxsPSIjZmZmIi8%2BPGRlZnM%2BPGxpbmVhckdyYWRpZW50IGlkPSJhIiB4MT0iMTEuOTkiIHkxPSIwIiB4Mj0iMTEuOTkiIHkyPSIyMy44MSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIHN0b3AtY29sb3I9IiMyQUFCRUUiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMyMjlFRDkiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48L3N2Zz4K&label=Telegram">
</a>
<a href="https://github.com/CubeWhyMC/DingZhenServlet">
<img alt="Static Badge"
src="https://img.shields.io/github/stars/CubeWhyMC/DingZhenServlet">
</a>
<p>我们正在维护我们的服务, 维护完成后会自动发放补偿, 请关注官方信息来了解开放时间.</p>
<p>你是管理员吗? <a href="/admin/dashboard#basic-settings">点击这里</a>去关闭维护模式</p>
</div>
</body>
</html>

0 comments on commit 3c450e9

Please sign in to comment.