MCPcopy
hub / github.com/ocsjs/ocsjs / methods

Function methods

packages/scripts/src/projects/zhs.ts:719–759  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

717 }
718 },
719 methods() {
720 return {
721 /**
722 * 增加学习时间
723 * @param courseName 课程名
724 * @param val 增加的时间
725 */
726 increaseStudyTime: (courseName: string, val: number) => {
727 const records = this.cfg.studyRecord;
728 // 查找是否存在今天的记录
729 const record = records.find(
730 (r) => new Date(r.date).toLocaleDateString() === new Date().toLocaleDateString()
731 );
732 let courses: {
733 name: string;
734 time: number;
735 }[] = [];
736 if (record) {
737 courses = record.courses;
738 } else {
739 records.push({ date: Date.now(), courses: courses });
740 }
741
742 // 查找是否存在课程记录
743 const course = courses.find((c) => c.name === courseName);
744 if (course) {
745 // 存在则累加时间
746 course.time = course.time + val;
747 // 历史遗留问题,之前的倍速没有转换为数字,导致可能显示为字符串
748 if (typeof course.time === 'string') {
749 course.time = parseFloat(course.time);
750 }
751 } else {
752 // 不存在则新建
753 courses.push({ name: courseName, time: 0 });
754 }
755
756 this.cfg.studyRecord = records;
757 }
758 };
759 },
760 onrender({ panel }) {
761 panel.body.replaceChildren(
762 h('hr'),

Callers

nothing calls this directly

Calls 10

switchPlaybackRateMethod · 0.95
switchLineMethod · 0.95
commonWorkFunction · 0.90
waitForElementFunction · 0.90
getWorkInfoFunction · 0.85
gxkWorkAndExamFunction · 0.85
doWorkFunction · 0.85
fusioncourseWorkFunction · 0.85
smartWorkFunction · 0.85
smartExamFunction · 0.85

Tested by

no test coverage detected