71 lines
2.6 KiB
HTML
71 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-cn">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>登录 SPQR.top</title>
|
|
<link href='normalize.css' rel='stylesheet' type='text/css'>
|
|
<link href="https://fonts.laysense.com/css/5000/zh-cn/harmonyossans/harmonyossans.css" rel="preload" as="style" onload="this.rel='stylesheet'">
|
|
<link id="theme_css" rel="stylesheet" href="/sakura.css"></head>
|
|
<body>
|
|
<script>
|
|
//切换深色模式
|
|
if(window.matchMedia('(prefers-color-scheme: dark)').matches){
|
|
document.getElementById('theme_css').href = '/sakura-dark.css';
|
|
}
|
|
|
|
</script>
|
|
<div class="login-container">
|
|
<h2>登录 SPQR.top</h2>
|
|
<form action="/login" method="post">
|
|
<label for="username">用户名:</label>
|
|
<input type="text" id="username" name="username" required>
|
|
|
|
<label for="password">密码:</label>
|
|
<input type="password" id="password" name="password" required>
|
|
|
|
<label for="captcha">验证码:</label>
|
|
<img src="/!/captcha" alt="Captcha Image" id="captcha-image" onclick="change()"><br />
|
|
<input type="text" id="captcha" name="captcha" required>
|
|
<br />
|
|
<button type="submit">登入</button>
|
|
</form>
|
|
<hr />
|
|
<a href="/">[返回首页]</a>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
<script src="/jquery-3.6.3.min.js"></script>
|
|
<script>
|
|
function change() {
|
|
document.getElementById('captcha-image').src = '/!/captcha?' + Math.random();
|
|
}
|
|
$(document).ready(function() {
|
|
$('form').on('submit', function(event) {
|
|
event.preventDefault();
|
|
var formData = {
|
|
username: $('#username').val(),
|
|
password: $('#password').val(),
|
|
captcha: $('#captcha').val()
|
|
};
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/!/loginapi',
|
|
data: JSON.stringify(formData),
|
|
contentType: 'application/json',
|
|
success: function(response) {
|
|
if(response.code == 200) {
|
|
window.location.href = '/my';
|
|
} else {
|
|
alert('登陆失败:'+response.msg);
|
|
change();
|
|
}
|
|
},
|
|
error: function(error) {
|
|
alert('登陆失败:接口错误');
|
|
change();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script> |