Skip to content

Commit

Permalink
fix(script): 智慧树考试强制添加保存弹窗,并从头开始每题保存,防止用户切换题目导致保存失败
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed May 8, 2023
1 parent 4aa68f1 commit f6c0e22
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/scripts/src/projects/zhs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,21 +1010,22 @@ function gxkWorkOrExam(
await $.sleep(stopSecondWhenFinish * 1000);

// 保存题目
const text = el('span', '正在保存题目中,请勿操作...');
const modal = $modal('alert', { content: text });

for (let index = 0; index < worker.totalQuestionCount; index++) {
const modal = $modal('alert', { content: '正在保存题目中,请勿操作...', confirmButton: null });
await waitForCaptcha();
await $.sleep(2000);
// 跳转到该题目,防止用户在保存时切换题目
document.querySelectorAll<HTMLElement>('.answerCard_list ul li').item(index)?.click();
await $.sleep(200);
// 下一页
const next = $el('div.examPaper_box > div.switch-btn-box > button:nth-child(2)');
if (next) {
next.click();
} else {
$console.error('未找到下一页按钮。');
}
modal?.remove();
}
text.innerText = '所有题目保存成功。';
setTimeout(() => modal?.remove(), 1000);

if (type === 'exam') {
$message('info', { content: '考试完成,为了安全考虑,请自行检查后自行点击提交!', duration: 0 });
Expand Down

0 comments on commit f6c0e22

Please sign in to comment.