|
|
<!DOCTYPE html> |
|
|
<html> |
|
|
|
|
|
<head> |
|
|
<base href="/"> |
|
|
<meta charset="utf-8"> |
|
|
<meta name="viewport" content="width=device-width, viewport-fit=cover, initial-scale=1, maximum-scale=1.0, user-scalable=no, interactive-widget=resizes-content"> |
|
|
<meta name="apple-mobile-web-app-capable" content="yes"> |
|
|
<meta name="mobile-web-app-capable" content="yes"> |
|
|
<meta name="darkreader-lock"> |
|
|
<meta name="robots" content="noindex, nofollow" /> |
|
|
<style> |
|
|
|
|
|
body { |
|
|
background-color: rgb(36, 36, 37); |
|
|
} |
|
|
|
|
|
|
|
|
body.login #shadow_popup { |
|
|
opacity: 1; |
|
|
display: flex; |
|
|
} |
|
|
|
|
|
body.login { |
|
|
background-color: rgb(36, 36, 37); |
|
|
background-size: cover; |
|
|
background-position: center center; |
|
|
background-repeat: no-repeat; |
|
|
background-attachment: fixed; |
|
|
position: relative; |
|
|
} |
|
|
|
|
|
|
|
|
body.login::before { |
|
|
content: ''; |
|
|
position: fixed; |
|
|
top: 0; |
|
|
left: 0; |
|
|
width: 100%; |
|
|
height: 100%; |
|
|
background-color: rgba(0, 0, 0, 0.5); |
|
|
z-index: 0; |
|
|
pointer-events: none; |
|
|
} |
|
|
|
|
|
|
|
|
body.login #shadow_popup { |
|
|
position: relative; |
|
|
z-index: 1; |
|
|
} |
|
|
|
|
|
body.login .logo { |
|
|
max-width: 30px; |
|
|
} |
|
|
|
|
|
body.login #logoBlock { |
|
|
align-items: center; |
|
|
margin: 0 auto; |
|
|
gap: 10px; |
|
|
} |
|
|
|
|
|
body.login .userSelect { |
|
|
display: flex; |
|
|
flex-direction: column; |
|
|
color: var(--SmartThemeBodyColor); |
|
|
border: 1px solid var(--SmartThemeBorderColor); |
|
|
border-radius: 5px; |
|
|
padding: 3px 5px; |
|
|
width: 30%; |
|
|
cursor: pointer; |
|
|
margin: 5px 0; |
|
|
transition: background-color 0.15s ease-in-out; |
|
|
display: flex; |
|
|
align-items: center; |
|
|
justify-content: center; |
|
|
text-align: center; |
|
|
overflow: hidden; |
|
|
} |
|
|
|
|
|
body.login .userSelect .userName, |
|
|
body.login .userSelect .userHandle { |
|
|
width: 100%; |
|
|
overflow: hidden; |
|
|
text-overflow: ellipsis; |
|
|
white-space: nowrap; |
|
|
} |
|
|
|
|
|
body.login .userSelect:hover { |
|
|
background-color: var(--black30a); |
|
|
} |
|
|
|
|
|
body.login #handleEntryBlock, |
|
|
body.login #passwordEntryBlock, |
|
|
body.login #passwordRecoveryBlock { |
|
|
margin: 2px; |
|
|
} |
|
|
|
|
|
|
|
|
#friend-links-bar { |
|
|
position: fixed; |
|
|
left: 0; |
|
|
right: 0; |
|
|
bottom: 0; |
|
|
background-color: rgba(25, 25, 25, 0.95); |
|
|
box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.5); |
|
|
padding: 8px 0; |
|
|
z-index: 9999; |
|
|
text-align: center; |
|
|
width: 100%; |
|
|
} |
|
|
|
|
|
.friend-links-title { |
|
|
color: #ddd; |
|
|
font-size: 14px; |
|
|
margin-bottom: 5px; |
|
|
font-weight: bold; |
|
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); |
|
|
} |
|
|
|
|
|
.friend-links-container { |
|
|
display: flex; |
|
|
overflow-x: auto; |
|
|
white-space: nowrap; |
|
|
padding: 0 15px; |
|
|
scrollbar-width: none; |
|
|
-ms-overflow-style: none; |
|
|
justify-content: center; |
|
|
} |
|
|
|
|
|
.friend-links-container::-webkit-scrollbar { |
|
|
display: none; |
|
|
} |
|
|
|
|
|
.friend-link { |
|
|
display: inline-block; |
|
|
margin: 0 8px; |
|
|
padding: 5px 15px; |
|
|
background-color: rgba(50, 50, 50, 0.7); |
|
|
color: #fff; |
|
|
text-decoration: none; |
|
|
border-radius: 20px; |
|
|
font-size: 13px; |
|
|
transition: all 0.2s ease; |
|
|
flex-shrink: 0; |
|
|
} |
|
|
|
|
|
.friend-link:hover { |
|
|
background-color: rgba(70, 70, 70, 0.9); |
|
|
transform: translateY(-2px); |
|
|
} |
|
|
|
|
|
.mobile-hint { |
|
|
font-size: 10px; |
|
|
color: rgba(200, 200, 200, 0.5); |
|
|
margin-top: 5px; |
|
|
font-style: italic; |
|
|
} |
|
|
|
|
|
|
|
|
body.login { |
|
|
padding-bottom: 80px; |
|
|
} |
|
|
|
|
|
|
|
|
.announcement-container { |
|
|
width: 100%; |
|
|
overflow: hidden; |
|
|
margin: 8px 0; |
|
|
position: relative; |
|
|
border-radius: 4px; |
|
|
background-color: rgba(50, 50, 50, 0.4); |
|
|
padding: 6px 0; |
|
|
} |
|
|
|
|
|
.announcement-container marquee { |
|
|
color: #ff3333; |
|
|
font-size: 14px; |
|
|
padding: 0 5px; |
|
|
font-weight: bold; |
|
|
text-transform: uppercase; |
|
|
letter-spacing: 0.5px; |
|
|
text-shadow: 0 0 2px rgba(255, 0, 0, 0.3); |
|
|
} |
|
|
|
|
|
@keyframes scroll-announcement { |
|
|
0% { transform: translateX(100%); } |
|
|
100% { transform: translateX(-100%); } |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@media (max-width: 768px) { |
|
|
.friend-links-container { |
|
|
justify-content: flex-start; |
|
|
padding: 0 10px; |
|
|
} |
|
|
|
|
|
.friend-link { |
|
|
margin: 0 5px; |
|
|
padding: 4px 10px; |
|
|
font-size: 12px; |
|
|
} |
|
|
|
|
|
.friend-links-title { |
|
|
font-size: 12px; |
|
|
margin-bottom: 3px; |
|
|
} |
|
|
|
|
|
#friend-links-bar { |
|
|
padding: 5px 0; |
|
|
} |
|
|
|
|
|
body.login { |
|
|
padding-bottom: 70px; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@media (max-width: 480px) { |
|
|
.friend-link { |
|
|
margin: 0 3px; |
|
|
padding: 3px 8px; |
|
|
font-size: 11px; |
|
|
} |
|
|
|
|
|
.mobile-hint { |
|
|
font-size: 9px; |
|
|
} |
|
|
} |
|
|
</style> |
|
|
<link rel="preload" as="style" href="style.css"> |
|
|
<link rel="apple-touch-icon" sizes="57x57" href="img/apple-icon-57x57.png" /> |
|
|
<link rel="apple-touch-icon" sizes="72x72" href="img/apple-icon-72x72.png" /> |
|
|
<link rel="apple-touch-icon" sizes="114x114" href="img/apple-icon-114x114.png" /> |
|
|
<link rel="apple-touch-icon" sizes="144x144" href="img/apple-icon-144x144.png" /> |
|
|
<link rel="icon" href="favicon.ico" type="image/x-icon"> |
|
|
<link rel="stylesheet" type="text/css" href="style.css"> |
|
|
<link rel="stylesheet" type="text/css" href="css/st-tailwind.css"> |
|
|
|
|
|
<link rel="manifest" crossorigin="use-credentials" href="manifest.json"> |
|
|
<link href="webfonts/NotoSans/stylesheet.css" rel="stylesheet"> |
|
|
<link href="webfonts/NotoSansMono/stylesheet.css" rel="stylesheet"> |
|
|
|
|
|
<link href="css/fontawesome.min.css" rel="stylesheet"> |
|
|
<link href="css/solid.min.css" rel="stylesheet"> |
|
|
<link href="css/user.css" rel="stylesheet"> |
|
|
<title>[柒蓝-公益]云酒馆9号</title> |
|
|
</head> |
|
|
|
|
|
<body class="login"> |
|
|
<div id="shadow_popup" style="opacity: 0;"> |
|
|
<div id="dialogue_popup"> |
|
|
<div id="dialogue_popup_holder"> |
|
|
<div id="dialogue_popup_text"> |
|
|
<div id="userSelectBlock" class="flex-container flexFlowColumn alignItemsCenter"> |
|
|
<h2 id="logoBlock" class="flex-container"> |
|
|
<img src="img/logo.png" alt="SillyTavern" class="logo"> |
|
|
<span>[柒蓝-公益]云酒馆9号</span> |
|
|
</h2> |
|
|
<div class="announcement-container"> |
|
|
<marquee id="announcementText" scrollamount="4" behavior="scroll" direction="left" onmouseover="this.stop();" onmouseout="this.start();"> |
|
|
本云酒馆由谷歌colab机子搭建时间到期会换机子接力运行| 请注意接力-时间段 | 防止过载最多支持200个用户注册 | 且用且珍惜吧 |
|
|
</marquee> |
|
|
</div> |
|
|
<div id="userListBlock" class="wide100p"> |
|
|
<div id="userList" class="flex-container justifySpaceEvenly"></div> |
|
|
<div id="handleEntryBlock" style="display:none;" class="flex-container flexFlowColumn alignItemsCenter"> |
|
|
<input id="userHandle" class="text_pole" type="text" placeholder="QQ" autocomplete="username" > |
|
|
</div> |
|
|
<div id="passwordEntryBlock" style="display:none;" |
|
|
class="flex-container flexFlowColumn alignItemsCenter"> |
|
|
<input id="userPassword" class="text_pole" type="password" placeholder="密码" autocomplete="current-password"> |
|
|
<a id="recoverPassword" href="#" onclick="return false;">忘记密码请联系管理员</a> |
|
|
<div class="flex-container"> |
|
|
<div id="loginButton" class="menu_button" style="white-space: nowrap;">登录</div> |
|
|
</div> |
|
|
</div> |
|
|
<div id="passwordRecoveryBlock" style="display:none;" class="flex-container flexFlowColumn alignItemsCenter"> |
|
|
<div id="recoverMessage"> |
|
|
Recovery code has been posted to the server console. |
|
|
</div> |
|
|
<input id="recoveryCode" class="text_pole" type="text" placeholder="Recovery code"> |
|
|
<input id="newPassword" class="text_pole" type="password" placeholder="New password" autocomplete="new-password"> |
|
|
<div class="flex-container flexGap10"> |
|
|
<div id="sendRecovery" class="menu_button">Send</div> |
|
|
<div id="cancelRecovery" class="menu_button">Cancel</div> |
|
|
</div> |
|
|
</div> |
|
|
<div id="registerBlock" style="display:none;" class="flex-container flexFlowColumn alignItemsCenter"> |
|
|
<input id="registerHandle" class="text_pole" type="text" placeholder="QQ" autocomplete="username"> |
|
|
<input id="registerPassword" class="text_pole" type="password" placeholder="密码" autocomplete="new-password"> |
|
|
<input id="registerConfirm" class="text_pole" type="password" placeholder="确认密码" autocomplete="new-password"> |
|
|
<div class="flex-container"> |
|
|
<div id="registerButton" class="menu_button" style="white-space: nowrap;">注册</div> |
|
|
<div id="backToLogin" class="menu_button" style="white-space: nowrap;">返回登录</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="flex-container justifySpaceEvenly" style="white-space: nowrap;"> |
|
|
<div id="showRegister" class="menu_button">注册账号</div> |
|
|
</div> |
|
|
<div id="serverUptime" style="color: #888; font-size: 13px; margin-top: 10px; text-align: center;"> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div class="neutral_warning" id="errorMessage"> |
|
|
</div> |
|
|
<div id="userCount" class="neutral_warning" style="color: #888; font-size: 12px; margin-top: 5px; text-align: center;"> |
|
|
</div> |
|
|
|
|
|
<div> |
|
|
接力时间[2025-08-09 11:45:54] |
|
|
</div> |
|
|
<div> |
|
|
IP[35.185.53.73] 国家[美国] IPS[XX] |
|
|
</div> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div id="friend-links-bar"> |
|
|
<div class="friend-links-title">所有公益酒馆</div> |
|
|
<div class="friend-links-container"> |
|
|
<a href="http://st.ql66.ggff.net:7070" class="friend-link">1号酒馆</a> |
|
|
<a href="http://st.ql66.ggff.net:7073" class="friend-link">2号酒馆</a> |
|
|
<a href="https://ka.282820.xyz/" class="friend-link">角色卡分享</a> |
|
|
<a href="http://st.ql66.ggff.net:7076" class="friend-link">3号酒馆</a> |
|
|
<a href="http://st.ql66.ggff.net:7078" class="friend-link">4号酒馆</a> |
|
|
<a href="http://st.ql66.ggff.net:7080" class="friend-link">5号酒馆</a> |
|
|
<a href="http://st.ql66.ggff.net:7082" class="friend-link">6号酒馆</a> |
|
|
<a href="http://st.ql66.ggff.net:7084" class="friend-link">7号酒馆</a> |
|
|
|
|
|
|
|
|
</div> |
|
|
<div class="mobile-hint">← 左右滑动查看更多 →</div> |
|
|
</div> |
|
|
|
|
|
<script src="lib/jquery-3.5.1.min.js"></script> |
|
|
|
|
|
<script> |
|
|
|
|
|
|
|
|
|
|
|
let csrfToken = ''; |
|
|
let discreetLogin = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function getCsrfToken() { |
|
|
const response = await fetch('/csrf-token'); |
|
|
const data = await response.json(); |
|
|
return data.token; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function getUserList() { |
|
|
const response = await fetch('/api/users/list', { |
|
|
method: 'POST', |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
'X-CSRF-Token': csrfToken, |
|
|
}, |
|
|
}); |
|
|
|
|
|
if (!response.ok) { |
|
|
const errorData = await response.json(); |
|
|
return displayError(errorData.error || '发生错误'); |
|
|
} |
|
|
|
|
|
if (response.status === 204) { |
|
|
discreetLogin = true; |
|
|
return []; |
|
|
} |
|
|
|
|
|
const userListObj = await response.json(); |
|
|
console.log(userListObj); |
|
|
return userListObj; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function sendRecoveryPart1(handle) { |
|
|
const response = await fetch('/api/users/recover-step1', { |
|
|
method: 'POST', |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
'X-CSRF-Token': csrfToken, |
|
|
}, |
|
|
body: JSON.stringify({ handle }), |
|
|
}); |
|
|
|
|
|
if (!response.ok) { |
|
|
const errorData = await response.json(); |
|
|
return displayError(errorData.error || '发生错误'); |
|
|
} |
|
|
|
|
|
showRecoveryBlock(); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function sendRecoveryPart2(handle, code, newPassword) { |
|
|
const recoveryData = { |
|
|
handle, |
|
|
code, |
|
|
newPassword, |
|
|
}; |
|
|
|
|
|
const response = await fetch('/api/users/recover-step2', { |
|
|
method: 'POST', |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
'X-CSRF-Token': csrfToken, |
|
|
}, |
|
|
body: JSON.stringify(recoveryData), |
|
|
}); |
|
|
|
|
|
if (!response.ok) { |
|
|
const errorData = await response.json(); |
|
|
return displayError(errorData.error || '发生错误'); |
|
|
} |
|
|
|
|
|
console.log(`密码恢复成功: ${handle}!`); |
|
|
await performLogin(handle, newPassword); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function performLogin(handle, password) { |
|
|
const userInfo = { |
|
|
handle: handle, |
|
|
password: password, |
|
|
}; |
|
|
|
|
|
try { |
|
|
const response = await fetch('/api/users/login', { |
|
|
method: 'POST', |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
'X-CSRF-Token': csrfToken, |
|
|
}, |
|
|
body: JSON.stringify(userInfo), |
|
|
}); |
|
|
|
|
|
if (!response.ok) { |
|
|
const errorData = await response.json(); |
|
|
return displayError(errorData.error || '发生错误'); |
|
|
} |
|
|
|
|
|
const data = await response.json(); |
|
|
|
|
|
if (data.handle) { |
|
|
console.log(`登录成功: ${handle}!`); |
|
|
redirectToHome(); |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('登录失败:', error); |
|
|
displayError(String(error)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function performRegister(handle, password, confirmPassword) { |
|
|
|
|
|
if (!handle) { |
|
|
return displayError('QQ号不能为空'); |
|
|
} |
|
|
|
|
|
if (!/^\d{6,13}$/.test(handle)) { |
|
|
return displayError('用户名只能是6-13位的数字'); |
|
|
} |
|
|
|
|
|
if (!password) { |
|
|
return displayError('密码不能为空'); |
|
|
} |
|
|
|
|
|
if (password !== confirmPassword) { |
|
|
return displayError('两次输入的密码不一致'); |
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
const countResponse = await fetch('/api/users-internal/count', { |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
'X-CSRF-Token': csrfToken |
|
|
} |
|
|
}); |
|
|
|
|
|
if (countResponse.ok) { |
|
|
const countData = await countResponse.json(); |
|
|
if (countData.totalCount >= 200) { |
|
|
return displayError('系统已达到最大用户数限制(200),暂停注册'); |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('检查用户数量失败:', error); |
|
|
|
|
|
} |
|
|
|
|
|
const userInfo = { |
|
|
handle: handle, |
|
|
name: handle, |
|
|
password: password |
|
|
}; |
|
|
|
|
|
try { |
|
|
const response = await fetch('/api/users-internal/create', { |
|
|
method: 'POST', |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
'X-CSRF-Token': csrfToken |
|
|
}, |
|
|
body: JSON.stringify(userInfo) |
|
|
}); |
|
|
|
|
|
if (!response.ok) { |
|
|
const errorData = await response.json(); |
|
|
return displayError(errorData.error || '注册失败'); |
|
|
} |
|
|
|
|
|
const data = await response.json(); |
|
|
|
|
|
if (data.handle) { |
|
|
console.log(`注册成功: ${handle}!`); |
|
|
|
|
|
await performLogin(handle, password); |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('注册失败:', error); |
|
|
displayError(String(error)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function onUserSelected(user) { |
|
|
|
|
|
if (!user.password) { |
|
|
return await performLogin(user.handle, ''); |
|
|
} |
|
|
|
|
|
$('#passwordRecoveryBlock').hide(); |
|
|
$('#passwordEntryBlock').show(); |
|
|
$('#loginButton').off('click').on('click', async () => { |
|
|
const password = String($('#userPassword').val()); |
|
|
await performLogin(user.handle, password); |
|
|
}); |
|
|
|
|
|
$('#recoverPassword').off('click').on('click', async () => { |
|
|
await sendRecoveryPart1(user.handle); |
|
|
}); |
|
|
|
|
|
$('#sendRecovery').off('click').on('click', async () => { |
|
|
const code = String($('#recoveryCode').val()); |
|
|
const newPassword = String($('#newPassword').val()); |
|
|
await sendRecoveryPart2(user.handle, code, newPassword); |
|
|
}); |
|
|
|
|
|
displayError(''); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function displayError(message) { |
|
|
$('#errorMessage').text(message); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function redirectToHome() { |
|
|
|
|
|
|
|
|
const urlParams = new URLSearchParams(window.location.search); |
|
|
|
|
|
urlParams.delete('noauto'); |
|
|
|
|
|
window.location.href = '/' + urlParams.toString(); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function showRecoveryBlock() { |
|
|
$('#passwordEntryBlock').hide(); |
|
|
$('#passwordRecoveryBlock').show(); |
|
|
displayError(''); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onCancelRecoveryClick() { |
|
|
$('#passwordRecoveryBlock').hide(); |
|
|
$('#passwordEntryBlock').show(); |
|
|
displayError(''); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function showRegisterForm() { |
|
|
|
|
|
try { |
|
|
const countResponse = await fetch('/api/users-internal/count', { |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
'X-CSRF-Token': csrfToken |
|
|
} |
|
|
}); |
|
|
|
|
|
if (countResponse.ok) { |
|
|
const countData = await countResponse.json(); |
|
|
if (countData.totalCount >= 200) { |
|
|
return displayError('系统已达到最大用户数限制(200),暂停注册'); |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('检查用户数量失败:', error); |
|
|
|
|
|
} |
|
|
|
|
|
$('#registerBlock').show(); |
|
|
$('#userListBlock > div:not(#registerBlock)').hide(); |
|
|
displayError(''); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function backToLoginForm() { |
|
|
$('#registerBlock').hide(); |
|
|
|
|
|
if (discreetLogin) { |
|
|
configureDiscreetLogin(); |
|
|
} else { |
|
|
$('#userList').show(); |
|
|
$('#handleEntryBlock').hide(); |
|
|
$('#passwordEntryBlock').hide(); |
|
|
} |
|
|
|
|
|
displayError(''); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function configureNormalLogin(userList) { |
|
|
console.log('Discreet login is disabled'); |
|
|
$('#handleEntryBlock').hide(); |
|
|
$('#normalLoginPrompt').show(); |
|
|
$('#discreetLoginPrompt').hide(); |
|
|
$('#registerBlock').hide(); |
|
|
console.log(userList); |
|
|
for (const user of userList) { |
|
|
const userBlock = $('<div></div>').addClass('userSelect'); |
|
|
const avatarBlock = $('<div></div>').addClass('avatar'); |
|
|
avatarBlock.append($('<img>').attr('src', user.avatar || 'img/default-avatar.png')); |
|
|
userBlock.append(avatarBlock); |
|
|
userBlock.append($('<span></span>').addClass('userName').text(user.name)); |
|
|
userBlock.append($('<small></small>').addClass('userHandle').text(user.handle)); |
|
|
userBlock.on('click', () => onUserSelected(user)); |
|
|
$('#userList').append(userBlock); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function configureDiscreetLogin() { |
|
|
console.log('Discreet login is enabled'); |
|
|
$('#handleEntryBlock').show(); |
|
|
$('#normalLoginPrompt').hide(); |
|
|
$('#discreetLoginPrompt').show(); |
|
|
$('#userList').hide(); |
|
|
$('#passwordRecoveryBlock').hide(); |
|
|
$('#passwordEntryBlock').show(); |
|
|
$('#registerBlock').hide(); |
|
|
$('#loginButton').off('click').on('click', async () => { |
|
|
const handle = String($('#userHandle').val()); |
|
|
const password = String($('#userPassword').val()); |
|
|
await performLogin(handle, password); |
|
|
}); |
|
|
|
|
|
$('#recoverPassword').off('click').on('click', async () => { |
|
|
const handle = String($('#userHandle').val()); |
|
|
await sendRecoveryPart1(handle); |
|
|
}); |
|
|
|
|
|
$('#sendRecovery').off('click').on('click', async () => { |
|
|
const handle = String($('#userHandle').val()); |
|
|
const code = String($('#recoveryCode').val()); |
|
|
const newPassword = String($('#newPassword').val()); |
|
|
await sendRecoveryPart2(handle, code, newPassword); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function initFriendLinks() { |
|
|
try { |
|
|
const container = document.querySelector('.friend-links-container'); |
|
|
|
|
|
if (!container) { |
|
|
console.log('友联容器未找到'); |
|
|
return; |
|
|
} |
|
|
|
|
|
|
|
|
const isMobile = window.innerWidth <= 768; |
|
|
|
|
|
|
|
|
if (!isMobile && container.scrollWidth > container.clientWidth) { |
|
|
let scrollPos = 0; |
|
|
const maxScroll = container.scrollWidth - container.clientWidth; |
|
|
const scrollInterval = setInterval(() => { |
|
|
scrollPos += 1; |
|
|
container.scrollLeft = scrollPos; |
|
|
|
|
|
if (scrollPos >= maxScroll) { |
|
|
clearInterval(scrollInterval); |
|
|
setTimeout(() => { |
|
|
container.scrollTo({ |
|
|
left: 0, |
|
|
behavior: 'smooth' |
|
|
}); |
|
|
}, 500); |
|
|
} |
|
|
}, 15); |
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
clearInterval(scrollInterval); |
|
|
}, 3000); |
|
|
} |
|
|
|
|
|
console.log('友联滑动功能初始化完成'); |
|
|
} catch (error) { |
|
|
console.error('初始化友联滑动功能时出错:', error); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
(async function () { |
|
|
csrfToken = await getCsrfToken(); |
|
|
const userList = await getUserList(); |
|
|
|
|
|
if (discreetLogin) { |
|
|
configureDiscreetLogin(); |
|
|
} else { |
|
|
configureNormalLogin(userList); |
|
|
} |
|
|
|
|
|
|
|
|
document.getElementById('shadow_popup').style.opacity = ''; |
|
|
|
|
|
|
|
|
$('#cancelRecovery').on('click', onCancelRecoveryClick); |
|
|
$('#showRegister').on('click', async () => { |
|
|
await showRegisterForm(); |
|
|
}); |
|
|
$('#backToLogin').on('click', backToLoginForm); |
|
|
|
|
|
|
|
|
$('#registerButton').on('click', async () => { |
|
|
const handle = String($('#registerHandle').val()); |
|
|
const password = String($('#registerPassword').val()); |
|
|
const confirmPassword = String($('#registerConfirm').val()); |
|
|
await performRegister(handle, password, confirmPassword); |
|
|
}); |
|
|
|
|
|
|
|
|
$(document).on('keydown', (evt) => { |
|
|
if (evt.key === 'Enter' && document.activeElement.tagName === 'INPUT') { |
|
|
if ($('#passwordRecoveryBlock').is(':visible')) { |
|
|
$('#sendRecovery').trigger('click'); |
|
|
} else if ($('#registerBlock').is(':visible')) { |
|
|
$('#registerButton').trigger('click'); |
|
|
} else { |
|
|
$('#loginButton').trigger('click'); |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
const countResponse = await fetch('/api/users-internal/count', { |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
'X-CSRF-Token': csrfToken |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const userCountElement = document.getElementById('userCount'); |
|
|
|
|
|
if (countResponse.ok) { |
|
|
|
|
|
const countData = await countResponse.json(); |
|
|
|
|
|
const totalUsers = countData.totalCount; |
|
|
|
|
|
|
|
|
if (userCountElement) { |
|
|
|
|
|
userCountElement.textContent = `总用户数: ${totalUsers}/200`; |
|
|
|
|
|
|
|
|
if (totalUsers >= 450) { |
|
|
userCountElement.style.color = '#FF3333'; |
|
|
userCountElement.style.fontWeight = 'bold'; |
|
|
|
|
|
|
|
|
if (totalUsers >= 200) { |
|
|
$('#showRegister').hide(); |
|
|
displayError('已达到最大用户数限制(200),暂停注册'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} else { |
|
|
console.error('找不到 userCount 元素'); |
|
|
} |
|
|
} else { |
|
|
console.warn('用户总数API访问受限,显示错误信息'); |
|
|
if (userCountElement) { |
|
|
userCountElement.textContent = '无法获取用户总数'; |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('获取用户数量失败:', error); |
|
|
const userCountElement = document.getElementById('userCount'); |
|
|
if (userCountElement) { |
|
|
userCountElement.textContent = '获取用户数量失败'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
initFriendLinks(); |
|
|
})(); |
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
setTimeout(initFriendLinks, 1000); |
|
|
}); |
|
|
</script> |
|
|
<script> |
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
|
|
|
const bgImages = [ |
|
|
'img/bg/1.jpg', |
|
|
'img/bg/2.jpg', |
|
|
'img/bg/3.jpg', |
|
|
'img/bg/4.jpg', |
|
|
'img/bg/5.jpg', |
|
|
'img/bg/6.jpg', |
|
|
'img/bg/7.jpg', |
|
|
'img/bg/8.jpg', |
|
|
'img/bg/9.jpg', |
|
|
'img/bg/10.jpg', |
|
|
'img/bg/11.jpg', |
|
|
'img/bg/12.jpg', |
|
|
'img/bg/13.jpg', |
|
|
'img/bg/14.jpg', |
|
|
'img/bg/15.jpg', |
|
|
'img/bg/16.jpg', |
|
|
'img/bg/17.jpg', |
|
|
'img/bg/18.jpg' |
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setRandomBackground() { |
|
|
if (bgImages.length === 0) return; |
|
|
|
|
|
|
|
|
const randomIndex = Math.floor(Math.random() * bgImages.length); |
|
|
const selectedImage = bgImages[randomIndex]; |
|
|
|
|
|
|
|
|
const img = new Image(); |
|
|
img.onload = function() { |
|
|
document.body.style.backgroundImage = `url('${selectedImage}')`; |
|
|
console.log(`背景图片已设置: ${selectedImage}`); |
|
|
}; |
|
|
|
|
|
img.onerror = function() { |
|
|
console.warn(`背景图片加载失败: ${selectedImage}`); |
|
|
|
|
|
|
|
|
bgImages.splice(randomIndex, 1); |
|
|
|
|
|
if (bgImages.length > 0) { |
|
|
|
|
|
setRandomBackground(); |
|
|
} else { |
|
|
console.error('所有背景图片加载失败'); |
|
|
document.body.style.backgroundImage = 'none'; |
|
|
} |
|
|
}; |
|
|
|
|
|
img.src = selectedImage; |
|
|
} |
|
|
|
|
|
|
|
|
setRandomBackground(); |
|
|
}); |
|
|
</script> |
|
|
</body> |
|
|
|
|
|
</html> |
|
|
|