v0.8.7测试

This commit is contained in:
2026-04-16 11:54:33 +08:00
parent 3a4e0357a3
commit 21b53375d7
4 changed files with 60 additions and 12 deletions

View File

@@ -121,8 +121,35 @@ include __DIR__ . '/../includes/header.php';
</div>
</div>
<!-- 重置密码模态框 -->
<div id="resetPasswordModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>重置密码</h3>
<button class="modal-close" onclick="closeModal('resetPasswordModal')">&times;</button>
</div>
<form onsubmit="event.preventDefault(); submitResetPassword()">
<input type="hidden" id="resetPasswordUserId">
<div class="form-group">
<label>管理员</label>
<input type="text" id="resetPasswordAdminName" disabled>
</div>
<div class="form-group">
<label>新密码</label>
<input type="text" id="newPassword" required minlength="6" placeholder="请输入新密码至少6位">
<small>密码长度至少6位</small>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">确认重置</button>
<button type="button" class="btn" onclick="closeModal('resetPasswordModal')">取消</button>
</div>
</form>
</div>
</div>
<script>
var currentEditUserId = null;
var currentResetUserId = null;
async function loadAdmins() {
const res = await apiGet('/api/admin/list');
@@ -228,14 +255,30 @@ async function deleteAdmin(userId, realName) {
}
}
async function resetAdminPassword(userId, realName) {
if (!confirm(`确定要重置管理员 "${realName}" 的密码吗?`)) {
function resetAdminPassword(userId, realName) {
currentResetUserId = userId;
document.getElementById('resetPasswordUserId').value = userId;
document.getElementById('resetPasswordAdminName').value = realName;
document.getElementById('newPassword').value = '';
document.getElementById('resetPasswordModal').style.display = 'flex';
}
async function submitResetPassword() {
if (!currentResetUserId) return;
const newPassword = document.getElementById('newPassword').value;
if (!newPassword || newPassword.length < 6) {
showToast('密码长度至少6位', 'warning');
return;
}
const res = await apiPost(`/api/admin/reset-password/${userId}`, {});
const res = await apiPost(`/api/admin/reset-password/${currentResetUserId}`, {
new_password: newPassword
});
if (res && res.success) {
alert(`密码重置成功\n管理员${realName}\n新密码${res.data.password}\n请妥善保管并及时通知该管理员。`);
showToast('密码重置成功');
closeModal('resetPasswordModal');
} else {
showToast(res?.message || '密码重置失败', 'error');
}

View File

@@ -114,8 +114,8 @@ async function exportMoralityRecords() {
return;
}
// 获取所有历史记录(不分页,获取全部)
const historyRes = await apiGet('/api/admin/conduct/history', { page: 1, page_size: 10000 });
// 获取所有历史记录(获取全部API限制最大1000条
const historyRes = await apiGet('/api/admin/conduct/history', { page: 1, page_size: 1000 });
if (!historyRes || !historyRes.success) {
showToast('获取历史记录失败', 'error');
return;