From c7f62b8a84735fe1f080a309037f63c2016cdd52 Mon Sep 17 00:00:00 2001 From: MKStoler Date: Wed, 9 Oct 2024 09:55:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=80=83=E5=AE=8C=E5=90=8E1=E5=88=86?= =?UTF-8?q?=E9=92=9F=E5=90=8E=E5=88=B7=E6=96=B0=E7=A7=91=E7=9B=AE=20fix:?= =?UTF-8?q?=20=E5=90=88=E5=B9=B6=E5=B7=A5=E5=85=B7=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 ++- README.md | 4 ++-- package.json | 4 ++-- src/renderer/src/components/AppTopBar.vue | 26 +-------------------- src/renderer/src/pages/infoPage.vue | 28 +++++++++++++++++++++-- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index fa35abe..b8d881b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,5 +25,6 @@ "command": "extension.execute", "priority": 4 } - ] + ], + "Codegeex.RepoIndex": true } diff --git a/README.md b/README.md index 77e71fb..de133e7 100644 --- a/README.md +++ b/README.md @@ -86,8 +86,8 @@ ### 开发进度 -- 在`main`分支上保留原作者`0.1.0`版本 -- 正在`dev`分支上开发`1.1-Malkuth`版本 +- 在`main`分支上保留原作者`0.1.0`版本; +- 正在`dev`分支上开发`1.1-Malkuth`版本。 ### Project Setup diff --git a/package.json b/package.json index 29522fb..a3b4b08 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "examshowboard", - "version": "1.0.0.1", - "description": "考试展板", + "version": "1.1.0", + "description": "电子考试展示板", "main": "./out/main/index.js", "author": "Hello8693 ", "homepage": "https://dsz.hello8693.xyz/", diff --git a/src/renderer/src/components/AppTopBar.vue b/src/renderer/src/components/AppTopBar.vue index e0a9d1b..71bdcd1 100644 --- a/src/renderer/src/components/AppTopBar.vue +++ b/src/renderer/src/components/AppTopBar.vue @@ -1,46 +1,22 @@ diff --git a/src/renderer/src/pages/infoPage.vue b/src/renderer/src/pages/infoPage.vue index 7ab2592..22637fe 100644 --- a/src/renderer/src/pages/infoPage.vue +++ b/src/renderer/src/pages/infoPage.vue @@ -27,16 +27,40 @@ import { getCurrentTimeSlot, getNextExamTimeSlot } from '@renderer/utils/subject const globalStore = useProfileStore(); const currentExam = ref(null); +let timeout = null; const updateCurrentExam = () => { const current = getCurrentTimeSlot(globalStore.examInfos); currentExam.value = current ? current : getNextExamTimeSlot(globalStore.examInfos); }; +const scheduleNextUpdate = () => { + if (timeout) { + clearTimeout(timeout); + } + + const nextExam = getNextExamTimeSlot(globalStore.examInfos); + if (nextExam) { + const nextEndTime = new Date(nextExam.end).getTime(); + const now = Date.now(); + const delay = nextEndTime - now + 60000; // 下一次考试结束时间 + 1分钟 + + timeout = setTimeout(() => { + updateCurrentExam(); + scheduleNextUpdate(); + }, delay); + } +}; + onMounted(() => { updateCurrentExam(); - const interval = setInterval(updateCurrentExam, 20000); // 每20秒刷新一次 - onUnmounted(() => clearInterval(interval)); + scheduleNextUpdate(); +}); + +onUnmounted(() => { + if (timeout) { + clearTimeout(timeout); + } });