feat: 增加用户修改密码与管理员重置密码
This commit is contained in:
+12
-1
@@ -26,7 +26,7 @@
|
||||
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
|
||||
th, td { border: 1px solid var(--border); padding: 0.5rem 0.6rem; text-align: left; }
|
||||
th { background: var(--bg); }
|
||||
.user-actions { display: flex; gap: 0.35rem; }
|
||||
.user-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; max-width: 240px; }
|
||||
.user-actions button {
|
||||
border: 1px solid var(--border); background: none; border-radius: 4px;
|
||||
padding: 0.3rem 0.5rem; cursor: pointer; color: var(--text-muted);
|
||||
@@ -88,6 +88,7 @@
|
||||
'<td>' + esc(u.created_at) + '</td>' +
|
||||
'<td><div class="user-actions">' +
|
||||
'<button data-id="' + u.id + '" data-active="' + (u.is_active ? '0' : '1') + '" class="toggle-user">' + (u.is_active ? '禁用' : '启用') + '</button>' +
|
||||
'<button data-id="' + u.id + '" class="reset-password">重置密码</button>' +
|
||||
'<button data-id="' + u.id + '" class="danger delete-user">删除</button>' +
|
||||
'</div></td>' +
|
||||
'</tr>';
|
||||
@@ -131,6 +132,16 @@
|
||||
adminMsg.textContent = '用户已删除';
|
||||
loadUsers();
|
||||
}).catch(function(err) { adminMsg.textContent = err.message; });
|
||||
} else if (btn.classList.contains('reset-password')) {
|
||||
var newPassword = prompt('请输入该用户的新密码(至少 6 位):');
|
||||
if (newPassword == null) return;
|
||||
if (newPassword.length < 6) {
|
||||
adminMsg.textContent = '密码至少 6 位';
|
||||
return;
|
||||
}
|
||||
apiAdminResetPassword(id, newPassword).then(function() {
|
||||
adminMsg.textContent = '密码已重置';
|
||||
}).catch(function(err) { adminMsg.textContent = err.message; });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user