feat: 考完后1分钟后刷新科目

fix: 合并工具栏
This commit is contained in:
MKStoler 2024-10-09 09:55:03 +08:00
parent 662884f671
commit c7f62b8a84
5 changed files with 33 additions and 32 deletions

View File

@ -25,5 +25,6 @@
"command": "extension.execute", "command": "extension.execute",
"priority": 4 "priority": 4
} }
] ],
"Codegeex.RepoIndex": true
} }

View File

@ -86,8 +86,8 @@
### 开发进度 ### 开发进度
- 在`main`分支上保留原作者`0.1.0`版本 - 在`main`分支上保留原作者`0.1.0`版本
- 正在`dev`分支上开发`1.1-Malkuth`版本 - 正在`dev`分支上开发`1.1-Malkuth`版本
### Project Setup ### Project Setup

View File

@ -1,7 +1,7 @@
{ {
"name": "examshowboard", "name": "examshowboard",
"version": "1.0.0.1", "version": "1.1.0",
"description": "考试展板", "description": "电子考试展板",
"main": "./out/main/index.js", "main": "./out/main/index.js",
"author": "Hello8693 <hello8693@hello8693.xyz>", "author": "Hello8693 <hello8693@hello8693.xyz>",
"homepage": "https://dsz.hello8693.xyz/", "homepage": "https://dsz.hello8693.xyz/",

View File

@ -1,46 +1,22 @@
<template> <template>
<v-system-bar class="position-fixed">
<v-icon icon="mdi-window-close" @click="ipcHandleExit"></v-icon>
<span class="ms-2">{{ currentTime }}</span>
</v-system-bar>
<v-app-bar :elevation="2" class="position-fixed"> <v-app-bar :elevation="2" class="position-fixed">
<v-app-bar-title>{{ profileStore.appHeader }}</v-app-bar-title> <v-app-bar-title>{{ profileStore.appHeader }}</v-app-bar-title>
<template #append> <template #append>
<div class="ga-4"> <div class="ga-4">
<v-btn @click="router.push('/mainWindow')">回到主页</v-btn> <v-btn @click="router.push('/mainWindow')">回到主页</v-btn>
<v-icon icon="mdi-window-close" @click="ipcHandleExit"></v-icon>
</div> </div>
</template> </template>
</v-app-bar> </v-app-bar>
</template> </template>
<script setup> <script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useProfileStore } from '../stores/app'; import { useProfileStore } from '../stores/app';
const profileStore = useProfileStore(); const profileStore = useProfileStore();
const router = useRouter(); const router = useRouter();
const currentTime = ref(
new Date().toLocaleTimeString('en-US', {
hour: 'numeric',
minute: 'numeric',
hour12: false
})
);
const updateTime = () => {
currentTime.value = new Date().toLocaleTimeString('en-US', {
hour: 'numeric',
minute: 'numeric',
hour12: false
});
};
onMounted(() => {
const interval = setInterval(updateTime, 1000);
onUnmounted(() => clearInterval(interval));
});
const ipcHandleExit = () => window.electron.ipcRenderer.send('prog:exit'); const ipcHandleExit = () => window.electron.ipcRenderer.send('prog:exit');
</script> </script>

View File

@ -27,16 +27,40 @@ import { getCurrentTimeSlot, getNextExamTimeSlot } from '@renderer/utils/subject
const globalStore = useProfileStore(); const globalStore = useProfileStore();
const currentExam = ref(null); const currentExam = ref(null);
let timeout = null;
const updateCurrentExam = () => { const updateCurrentExam = () => {
const current = getCurrentTimeSlot(globalStore.examInfos); const current = getCurrentTimeSlot(globalStore.examInfos);
currentExam.value = current ? current : getNextExamTimeSlot(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(() => { onMounted(() => {
updateCurrentExam(); updateCurrentExam();
const interval = setInterval(updateCurrentExam, 20000); // 20 scheduleNextUpdate();
onUnmounted(() => clearInterval(interval)); });
onUnmounted(() => {
if (timeout) {
clearTimeout(timeout);
}
}); });
</script> </script>