MCPcopy Create free account
hub / github.com/Xu22Web/tech-study-js / refreshTaskList

Function refreshTaskList

tech-study.js:4493–4537  ·  view source on GitHub ↗

* @description 刷新任务列表

()

Source from the content-addressed store, hash-verified

4491 * @description 刷新任务列表
4492 */
4493async function refreshTaskList() {
4494 // 未登录
4495 if (!login.value) {
4496 throw new Error('用户未登录!');
4497 }
4498 log('加载任务进度...');
4499 // 原始任务进度
4500 const taskProgress = await getTaskList();
4501 if (taskProgress) {
4502 // 登录
4503 taskConfig[TaskType.LOGIN].currentScore = taskProgress[2].currentScore;
4504 taskConfig[TaskType.LOGIN].dayMaxScore = taskProgress[2].dayMaxScore;
4505 taskConfig[TaskType.LOGIN].need =
4506 taskProgress[2].dayMaxScore - taskProgress[2].currentScore;
4507 // 文章选读
4508 taskConfig[TaskType.READ].currentScore = taskProgress[0].currentScore;
4509 taskConfig[TaskType.READ].dayMaxScore = taskProgress[0].dayMaxScore;
4510 taskConfig[TaskType.READ].need =
4511 taskProgress[0].dayMaxScore - taskProgress[0].currentScore;
4512 // 视听学习
4513 taskConfig[TaskType.WATCH].currentScore = taskProgress[1].currentScore;
4514 taskConfig[TaskType.WATCH].dayMaxScore = taskProgress[1].dayMaxScore;
4515 taskConfig[TaskType.WATCH].need =
4516 taskProgress[1].dayMaxScore - taskProgress[1].currentScore;
4517 // 每日答题
4518 taskConfig[TaskType.PRACTICE].currentScore = taskProgress[3].currentScore;
4519 taskConfig[TaskType.PRACTICE].dayMaxScore = taskProgress[3].dayMaxScore;
4520 taskConfig[TaskType.PRACTICE].need = taskProgress[3].dayMaxScore;
4521 // 更新数据
4522 for (const i in taskConfig) {
4523 const { currentScore, dayMaxScore } = taskConfig[i];
4524 // 进度
4525 const rate = Number(((100 * currentScore) / dayMaxScore).toFixed(1));
4526 // 分数
4527 taskConfig[i].score = currentScore;
4528 // 完成状态
4529 taskConfig[i].status = rate === 100;
4530 }
4531 return;
4532 }
4533 // 重试
4534 await sleep(2000);
4535 refreshTaskList();
4536 return;
4537}
4538function Tip({ text, count, show, delayShow, countShow, callback, }) {
4539 return createElementNode('div', undefined, {
4540 class: watchRef([show, delayShow], () => `egg_tip${show.value ? (delayShow.value ? ' active delay' : ' active') : ''}`),

Callers 5

doExamPracticeFunction · 0.70
handleLoginFunction · 0.70
readNewsFunction · 0.70
watchVideoFunction · 0.70
TaskListFunction · 0.70

Calls 3

logFunction · 0.70
getTaskListFunction · 0.70
sleepFunction · 0.70

Tested by

no test coverage detected