refactor: 界面优化和使用sse替换websocket

This commit is contained in:
Ray.Hao
2026-04-26 14:11:05 +08:00
parent 0288b5a08d
commit c9fbc441bd
31 changed files with 546 additions and 916 deletions

View File

@@ -0,0 +1,39 @@
import { ref, onUnmounted } from "vue";
export function useCountdown(duration = 60) {
const countdown = ref(0);
const isRunning = ref(false);
let timer: ReturnType<typeof setInterval> | null = null;
const start = () => {
if (isRunning.value) return;
countdown.value = duration;
isRunning.value = true;
timer = setInterval(() => {
countdown.value--;
if (countdown.value <= 0) {
stop();
}
}, 1000);
};
const stop = () => {
if (timer) {
clearInterval(timer);
timer = null;
}
countdown.value = 0;
isRunning.value = false;
};
onUnmounted(() => stop());
return {
countdown,
isRunning,
start,
stop,
};
}