v4.2 科目管理优化与多项修复清理

1. 科目管理:代码长度放宽至50(含数据库升级v4.2)、编辑可清空代码、重命名查重、新增 ↑↓ 快捷排序(批量重排接口)、空代码不再显示占位
2. 修复单人加减分提交空名单:showSinglePointsModal 三处重复定义收口到 points-mgmt 并共享选中状态
3. SMTP:SMTP_FROM 默认取 SMTP_USER、SMTP_ENABLED 兼容 1/yes/on、启动日志打印邮件状态、新增邮件测试接口与按钮(返回真实 SMTP 错误)
4. 密码:加密改为 bcrypt 库直连(修复 passlib 兼容问题)、重置密码不再依赖影响行数、前端统一展示422校验错误
5. 冗余清理:删除未用导入/Schema/函数、死文件 admin.js 与 sanitize.py、重复 escapeHtml、重复CSS、重复脚本加载
6. 修复11个文件被写入的 UTF-8 BOM
7. 文档与版本同步至4.2
This commit is contained in:
canglan committed 2026-09-20 20:35:13 +08:00
1 parent 990f44bf22
commit 1068bc6def
58 files changed
+366 -533

No files matched your search

+20 -2
View File
@@ -1,4 +1,4 @@
/**
/**
* 班级操行分管理系统 - 管理员管理页JS
*
* 开发者: Canglan
@@ -37,6 +37,7 @@ const PERMISSION_SECTIONS = [
let currentEditUserId = null;
let currentResetUserId = null;
let groupsCache = [];
const currentUserId = (window.PAGE_CONFIG && window.PAGE_CONFIG.userId) ? parseInt(window.PAGE_CONFIG.userId) : null;
function groupCapsText(group) {
const add = group.can_add_points
@@ -150,7 +151,12 @@ function showEditAdminModal(userId, username, realName, groupId, email) {
document.getElementById('editAdminUserId').value = userId;
document.getElementById('editAdminUsername').value = username;
document.getElementById('editAdminRealName').value = realName;
document.getElementById('editAdminGroupId').value = groupId || '';
const groupSelect = document.getElementById('editAdminGroupId');
groupSelect.value = groupId || '';
const isSelf = currentUserId !== null && parseInt(userId) === currentUserId;
groupSelect.disabled = isSelf;
const hint = document.getElementById('editAdminGroupHint');
if (hint) hint.style.display = isSelf ? 'block' : 'none';
document.getElementById('editAdminEmail').value = email || '';
document.getElementById('editAdminModal').style.display = 'flex';
}
@@ -360,6 +366,17 @@ async function deleteGroup(groupId, groupName) {
}
}
async function testSmtpEmail() {
const email = prompt('请输入接收测试邮件的邮箱地址:');
if (!email) return;
const res = await apiPost('/api/admin/email/test', { email: email.trim() });
if (res && res.success) {
showToast(res.message || '测试邮件已发送');
} else {
alert('邮件发送失败:\n' + ((res && res.message) || '未知错误'));
}
}
loadGroups();
loadAdmins();
@@ -377,5 +394,6 @@ window.submitGroupForm = submitGroupForm;
window.deleteGroup = deleteGroup;
window.onGroupCapChange = onGroupCapChange;
window.selectAllPermissions = selectAllPermissions;
window.testSmtpEmail = testSmtpEmail;
})();