修复学习流程路由切换与计时展示稳定性
This commit is contained in:
@@ -18,6 +18,14 @@ export function useTimer(audioUrl: string = '/resource/notification.mp3') {
|
||||
timerRunning.value = false;
|
||||
};
|
||||
|
||||
const syncDisplay = (durationMs: number) => {
|
||||
const safeDuration = Math.max(durationMs, 0);
|
||||
remainingTime.value = safeDuration;
|
||||
timerMinutes.value = Math.floor(safeDuration / 1000 / 60);
|
||||
timerSeconds.value = Math.floor((safeDuration / 1000) % 60);
|
||||
timerIsOver.value = safeDuration === 0;
|
||||
};
|
||||
|
||||
const handleCountdownComplete = () => {
|
||||
audio.loop = true;
|
||||
audio.play();
|
||||
@@ -91,6 +99,7 @@ export function useTimer(audioUrl: string = '/resource/notification.mp3') {
|
||||
timerRunning,
|
||||
timerIsOver,
|
||||
runCountdown,
|
||||
syncDisplay,
|
||||
clear,
|
||||
checkAudioPermission,
|
||||
requestAudioPermission,
|
||||
|
||||
Reference in New Issue
Block a user