v0.8.7测试
This commit is contained in:
@@ -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')">×</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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user