diff --git a/src/utils/dialog.util.ts b/src/utils/dialog.util.ts index f85db1d..a4bf2c8 100644 --- a/src/utils/dialog.util.ts +++ b/src/utils/dialog.util.ts @@ -9,6 +9,15 @@ export function addDialogButtons(dialog: HTMLElement) { restoreWatchedLessons(); }}, { className: "start-watching", text: "开始观看", onClick: () => { + if (localStorage.getItem("isStartedLesson")) { + alert("你已经开始了刷课会话,请先结束刷课会话"); + return; + } + if (localStorage.getItem("currentLesson")) { + localStorage.setItem("isStartedLesson", "true"); + location.reload(); + return; + } const selectedLessons = getSelectedLessons(); autoWatchVideos(selectedLessons); }}, @@ -16,6 +25,9 @@ export function addDialogButtons(dialog: HTMLElement) { localStorage.removeItem("watchedLessons"); localStorage.removeItem("currentLesson"); localStorage.removeItem("isStartedLesson"); + }}, + { className: "toggle-watching", text: "暂停刷课", onClick: () => { + localStorage.removeItem("isStartedLesson"); }} ];