Skip to content

Commit

Permalink
fix(script): 优化智慧树考试作业提示
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed May 11, 2023
1 parent 07f3cfc commit 3703e97
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions packages/scripts/src/projects/zhs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ export const ZHSProject = Project.create({
configs: {
notes: {
defaultValue: $creator.notes([
'📢 如果未开始答题,请尝试刷新页面。',
'自动答题前请在 “通用-全局设置” 中设置题库配置。',
'可以搭配 “通用-在线搜题” 一起使用。',
'📢 手动进入作业/考试,如果未开始答题,请尝试刷新页面。'
'可以搭配 “通用-在线搜题” 一起使用。'
]).outerHTML
}
},
Expand All @@ -462,13 +462,25 @@ export const ZHSProject = Project.create({
// 等待试卷加载
const isExam = location.href.includes('doexamination');
const isWork = location.href.includes('dohomework');

if (isExam || isWork) {
await waitForQuestionsLoad();
$message('info', { content: `开始${isExam ? '考试' : '作业'}` });
commonWork(this, {
workerProvider: (opts) => gxkWorkAndExam(opts)
});
const res = await Promise.race([
waitForQuestionsLoad(),
(async () => {
console.log('res');
await $.sleep(10 * 1000);
$message('warn', { content: '作业/试卷加载超时,请刷新重试。', duration: 0 });
return false;
})()
]);
if (res === false) {
$message('info', { content: `开始${isExam ? '考试' : '作业'}` });
commonWork(this, {
workerProvider: (opts) => gxkWorkAndExam(opts)
});
}
} else {
$message('info', { content: '📢 请手动进入作业/考试,如果未开始答题,请尝试刷新页面。', duration: 0 });
CommonProject.scripts.render.methods.pin(this);
}
}
Expand Down Expand Up @@ -875,7 +887,7 @@ function gxkWorkAndExam({
worker.emit('done');
})
.catch((err) => {
$message('error', { content: '答题程序发生错误 : ' + err.message });
$message('error', { content: '答题程序发生错误 : ' + err.message, duration: 0 });
});

return worker;
Expand Down

0 comments on commit 3703e97

Please sign in to comment.