fixed some bugs
This commit is contained in:
@@ -12,6 +12,7 @@ function renderState() {
|
||||
el('mainArea').classList.remove('hidden');
|
||||
el('teacherToolbar').classList.remove('hidden');
|
||||
el('teacherChip').textContent = `教师:${state.username}`;
|
||||
el('groupLimit').value = state.snapshot.group_limit;
|
||||
renderClassTabs();
|
||||
renderStatistics();
|
||||
renderGroups();
|
||||
@@ -166,6 +167,41 @@ async function submitLogin(event) {
|
||||
}
|
||||
}
|
||||
|
||||
async function submitTeacherPassword(event) {
|
||||
event.preventDefault();
|
||||
const oldPassword = el('teacherOldPassword').value;
|
||||
const newPassword = el('teacherNewPassword').value;
|
||||
const confirmPassword = el('teacherConfirmPassword').value;
|
||||
const notice = el('teacherPasswordNotice');
|
||||
notice.textContent = '';
|
||||
if (newPassword !== confirmPassword) {
|
||||
notice.textContent = '两次输入的新密码不一致';
|
||||
return;
|
||||
}
|
||||
setButtonsDisabled(el('teacherPasswordForm'), true);
|
||||
const result = await api('teacher/change-password', {
|
||||
method: 'POST', json: { old_password: oldPassword, new_password: newPassword }
|
||||
});
|
||||
setButtonsDisabled(el('teacherPasswordForm'), false);
|
||||
notice.textContent = result.ok ? '' : result.message;
|
||||
toast(result.message, !result.ok);
|
||||
if (result.ok) {
|
||||
el('teacherPasswordForm').reset();
|
||||
}
|
||||
}
|
||||
|
||||
async function submitGroupLimit(event) {
|
||||
event.preventDefault();
|
||||
setButtonsDisabled(el('groupLimitForm'), true);
|
||||
const result = await api('teacher/group-limit', {
|
||||
method: 'POST', json: { limit: Number(el('groupLimit').value) }
|
||||
});
|
||||
setButtonsDisabled(el('groupLimitForm'), false);
|
||||
el('groupLimitNotice').textContent = result.ok ? '' : result.message;
|
||||
toast(result.message, !result.ok);
|
||||
if (result.ok) await loadState();
|
||||
}
|
||||
|
||||
async function switchClass(className) {
|
||||
const result = await api('teacher/class', { method: 'POST', json: { class_name: className } });
|
||||
toast(result.message, !result.ok);
|
||||
@@ -211,6 +247,8 @@ async function logout() {
|
||||
}
|
||||
|
||||
el('loginForm').addEventListener('submit', submitLogin);
|
||||
el('teacherPasswordForm').addEventListener('submit', submitTeacherPassword);
|
||||
el('groupLimitForm').addEventListener('submit', submitGroupLimit);
|
||||
el('logoutButton').addEventListener('click', logout);
|
||||
el('lockButton').addEventListener('click', toggleLock);
|
||||
el('createGroupForm').addEventListener('submit', submitCreateGroup);
|
||||
|
||||
Reference in New Issue
Block a user