页面 JS/CSS 引用统一改为 asset_url()(附加 ?v=filemtime): 部署更新文件后浏览器自动拉取新版本,避免出现"新按钮点击无反应"等旧缓存现象。
94 lines
3.6 KiB
PHP
94 lines
3.6 KiB
PHP
<?php
|
|
/**
|
|
* 班级操行分管理系统 - 忘记密码
|
|
*
|
|
* 开发者: Canglan
|
|
* 联系方式: admin@sea-studio.top
|
|
* 版权归属: Sea Network Technology Studio
|
|
* 许可证: MIT License
|
|
*
|
|
* 版权所有 © Sea Network Technology Studio
|
|
*/
|
|
|
|
require_once __DIR__ . '/config.php';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
|
<title><?php echo SITE_NAME; ?> - 忘记密码</title>
|
|
<link rel="stylesheet" href="<?php echo asset_url('/assets/css/style.css'); ?>">
|
|
</head>
|
|
<body>
|
|
<div class="login-container">
|
|
<div class="login-header">
|
|
<h1><?php echo SITE_NAME; ?></h1>
|
|
<p>管理员找回密码</p>
|
|
</div>
|
|
|
|
<form id="forgotForm" class="login-form">
|
|
<div class="form-group">
|
|
<label>管理员账号</label>
|
|
<input type="text" id="username" name="username" required autocomplete="off" placeholder="请输入管理员用户名">
|
|
<small>重置链接将发送到该账号绑定的邮箱</small>
|
|
</div>
|
|
<button type="submit" class="btn-login" id="submitBtn">发送重置链接</button>
|
|
<div id="tipMsg" class="error-msg" style="display: none;"></div>
|
|
<p style="text-align:center; margin-top:14px;">
|
|
<a href="/index.php" class="link" style="font-size:14px;">返回登录</a>
|
|
</p>
|
|
</form>
|
|
|
|
<div class="login-footer">
|
|
<p>© <?php echo date('Y'); ?> Sea Network Technology Studio</p>
|
|
<?php if (defined('ICP_ENABLED') && ICP_ENABLED && defined('ICP_NUMBER') && ICP_NUMBER): ?>
|
|
<p><a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer"><?php echo htmlspecialchars(ICP_NUMBER); ?></a></p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
window.API_BASE_URL = '<?php echo API_BASE_URL; ?>';
|
|
|
|
function showTip(msg, isError) {
|
|
const tip = document.getElementById('tipMsg');
|
|
tip.textContent = msg;
|
|
tip.className = isError ? 'error-msg' : 'success-msg';
|
|
tip.style.display = 'block';
|
|
}
|
|
|
|
document.getElementById('forgotForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const username = document.getElementById('username').value.trim();
|
|
if (!username) {
|
|
showTip('请输入管理员账号', true);
|
|
return;
|
|
}
|
|
const btn = document.getElementById('submitBtn');
|
|
btn.disabled = true;
|
|
btn.textContent = '发送中...';
|
|
try {
|
|
const response = await fetch(`${window.API_BASE_URL}/api/auth/forgot-password`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ username })
|
|
});
|
|
const data = await response.json();
|
|
if (data.success) {
|
|
showTip(data.message || '重置链接已发送,请查收邮箱', false);
|
|
} else {
|
|
showTip(data.message || '发送失败', true);
|
|
}
|
|
} catch (error) {
|
|
console.error('找回密码请求失败:', error);
|
|
showTip('网络错误,请稍后重试', true);
|
|
} finally {
|
|
btn.disabled = false;
|
|
btn.textContent = '发送重置链接';
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|