Skip to content

Commit

Permalink
chore: simplify auto refresh and improve qrcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Xu22Web committed Jan 13, 2023
1 parent 788481a commit a041c29
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 51 deletions.
23 changes: 1 addition & 22 deletions src/controller/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,7 @@ async function refreshScheduleTask() {
refreshLoginQRCode();
}
}, 1000);
return;
}
// 无剩余任务
if (mainStore.scheduleList.length) {
// 最新
const lastest = mainStore.scheduleList[0];
log(`已设置 ${lastest.time} 的定时任务!`);
createTip(`已设置 ${lastest.time} 的定时任务!`);
let time = 0;
mainStore.scheduleTimer = setInterval(() => {
if (!(time++ % interval)) {
log('定时刷新正在运行...');
}
if (isNow(lastest)) {
clearInterval(mainStore.scheduleTimer);
log(`执行 ${lastest.time} 的定时任务!`);
createTip(`执行 ${lastest.time} 的定时任务!`);
// 加载二维码
refreshLoginQRCode();
}
}, 1000);
}
}
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/tech-study.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,7 @@ function renderFrame() {
*/
async function renderQRCode() {
// 加载二维码
if (
!mainStore.settings[SettingType.REMOTE_PUSH] &&
!mainStore.settings[SettingType.SCHEDULE_RUN]
) {
if (!mainStore.login && !mainStore.settings[SettingType.SCHEDULE_RUN]) {
// 等待加载
await $_('.egg_login_img_wrap');
// 刷新二维码
Expand Down
28 changes: 3 additions & 25 deletions tech-study.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name 不学习何以强国
// @namespace http://tampermonkey.net/
// @version v1.5.0
// @version v1.5.2
// @description 有趣的 `学习强国` 油猴插件。读文章,看视频,做习题。问题反馈: https://github.com/Xu22Web/tech-study-js/issues 。
// @author 原作者:techxuexi 荷包蛋。现作者:Xu22Web
// @match https://www.xuexi.cn/*
Expand Down Expand Up @@ -492,7 +492,7 @@ const defaultSettings = [
false,
];
const mainStore = {
version: 'v1.5.0',
version: 'v1.5.2',
tasks: [
{
title: '文章选读',
Expand Down Expand Up @@ -2610,27 +2610,6 @@ async function refreshScheduleTask() {
refreshLoginQRCode();
}
}, 1000);
return;
}
// 无剩余任务
if (mainStore.scheduleList.length) {
// 最新
const lastest = mainStore.scheduleList[0];
log(`已设置 ${lastest.time} 的定时任务!`);
createTip(`已设置 ${lastest.time} 的定时任务!`);
let time = 0;
mainStore.scheduleTimer = setInterval(() => {
if (!(time++ % interval)) {
log('定时刷新正在运行...');
}
if (isNow(lastest)) {
clearInterval(mainStore.scheduleTimer);
log(`执行 ${lastest.time} 的定时任务!`);
createTip(`执行 ${lastest.time} 的定时任务!`);
// 加载二维码
refreshLoginQRCode();
}
}, 1000);
}
}
}
Expand Down Expand Up @@ -4248,8 +4227,7 @@ function renderFrame() {
*/
async function renderQRCode() {
// 加载二维码
if (!mainStore.settings[SettingType.REMOTE_PUSH] &&
!mainStore.settings[SettingType.SCHEDULE_RUN]) {
if (!mainStore.login && !mainStore.settings[SettingType.SCHEDULE_RUN]) {
// 等待加载
await $_('.egg_login_img_wrap');
// 刷新二维码
Expand Down

0 comments on commit a041c29

Please sign in to comment.