新增“用户管理”

This commit is contained in:
2025-11-15 21:24:57 +08:00
parent a896613726
commit 14788fd59d
7 changed files with 64 additions and 149 deletions

View File

@@ -407,8 +407,8 @@
users.forEach(user => {
const row = document.createElement('tr');
// 根据权限值显示权限名称
const permissionText = user.permission === 0 ? '管理员' : '普通用户';
// 根据权限值显示权限名称
const permissionText = Number(user.permission) === 0 ? '管理员' : '普通用户';
row.innerHTML = `
<td>${user.user_id}</td>
@@ -496,9 +496,9 @@
let response;
if (userId) {
// 更新用户
response = await fetch(`/elastic/users/${userId}/update/`, {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrftoken
@@ -506,9 +506,9 @@
body: JSON.stringify(data)
});
} else {
// 添加用户
response = await fetch('/elastic/users/add/', {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrftoken
@@ -540,6 +540,7 @@
const csrftoken = getCookie('csrftoken');
const response = await fetch(`/elastic/users/${userId}/delete/`, {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrftoken