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

Function TaskList

tech-study.js:5120–5175  ·  view source on GitHub ↗

* @description 任务

()

Source from the content-addressed store, hash-verified

5118 * @description 任务
5119 */
5120function TaskList() {
5121 // 处理任务设置变化
5122 const handleTaskChange = (e, type, title) => {
5123 // 开关
5124 const { checked } = e.target;
5125 if (taskConfig[type].active !== checked) {
5126 taskConfig[type].active = checked;
5127 // 设置
5128 GM_setValue('taskConfig', JSON.stringify(taskConfig));
5129 // 创建提示
5130 createTip(`${title} ${checked ? '打开' : '关闭'}!`);
5131 }
5132 };
5133 // 登录加载
5134 watch(login, async () => {
5135 if (login.value) {
5136 // 加载任务列表
5137 await refreshTaskList();
5138 // 未完成任务
5139 if (taskConfig.some((task) => task.active && !task.status)) {
5140 // 全局暂停
5141 GM_setValue('pauseStudy', false);
5142 // 加载完毕
5143 taskStatus.value = TaskStatusType.LOADED;
5144 return;
5145 }
5146 // 任务完毕
5147 taskStatus.value = TaskStatusType.FINISH;
5148 }
5149 }, true);
5150 return createElementNode('div', undefined, {
5151 class: 'egg_task_list',
5152 }, taskConfig.map((label) => label.immutable
5153 ? TaskItem({
5154 title: label.title,
5155 tip: label.tip,
5156 checked: watchEffectRef(() => label.active),
5157 currentScore: watchEffectRef(() => label.currentScore),
5158 dayMaxScore: watchEffectRef(() => label.dayMaxScore),
5159 onchange: debounce((e) => {
5160 handleTaskChange(e, label.type, label.title);
5161 }, 300),
5162 immutable: label.immutable,
5163 })
5164 : TaskItem({
5165 title: label.title,
5166 tip: label.tip,
5167 checked: watchEffectRef(() => label.active),
5168 currentScore: watchEffectRef(() => label.currentScore),
5169 dayMaxScore: watchEffectRef(() => label.dayMaxScore),
5170 onchange: debounce((e) => {
5171 handleTaskChange(e, label.type, label.title);
5172 }, 300),
5173 immutable: label.immutable,
5174 })));
5175}
5176/**
5177 * @description 任务按钮

Callers 1

PanelFunction · 0.70

Calls 7

watchFunction · 0.70
refreshTaskListFunction · 0.70
createElementNodeFunction · 0.70
TaskItemFunction · 0.70
watchEffectRefFunction · 0.70
debounceFunction · 0.70
handleTaskChangeFunction · 0.70

Tested by

no test coverage detected