fix: 任务停止后仍用新的本月学时更新首页和进度条
This commit is contained in:
@@ -650,9 +650,16 @@ function applyStudyControl(payload: Record<string, unknown>) {
|
||||
} else if (!studying) {
|
||||
hoursRefreshIn.value = 0;
|
||||
}
|
||||
if (studying && typeof payload.month_hours === "string" && payload.month_hours) {
|
||||
progressHours.value = payload.month_hours;
|
||||
if (summary.value) summary.value = { ...summary.value, month_hours: payload.month_hours };
|
||||
const incomingHours = typeof payload.month_hours === "string" ? payload.month_hours.trim() : "";
|
||||
if (incomingHours) {
|
||||
const shown = progressHours.value || summary.value?.month_hours || "";
|
||||
const incomingMinutes = Number(incomingHours.match(/(\d+)/)?.[1] ?? 0);
|
||||
const shownMinutes = Number(String(shown).match(/(\d+)/)?.[1] ?? 0);
|
||||
// 达标后任务已停,这一帧仍要补上本月学时和进度条。空闲帧不把刚刷新到的更大数字改小。
|
||||
if (studying || incomingMinutes > shownMinutes) {
|
||||
progressHours.value = incomingHours;
|
||||
if (summary.value) summary.value = { ...summary.value, month_hours: incomingHours };
|
||||
}
|
||||
}
|
||||
if (typeof payload.monthly_target === "number" && Number.isFinite(payload.monthly_target)) {
|
||||
progressTarget.value = Math.trunc(payload.monthly_target);
|
||||
|
||||
Reference in New Issue
Block a user