feat: 历史统计时对照显示官方本月学时

This commit is contained in:
Nixevol
2026-11-19 02:54:32 +08:00
parent ba787a513b
commit a0ceb51348
12 changed files with 156 additions and 13 deletions
+13 -1
View File
@@ -3,6 +3,7 @@ import { apiFetch } from "../../shared/http";
import { computed, onMounted, ref } from "vue";
import { NAlert, NButton, NCheckbox, NDropdown, NForm, NFormItem, NIcon, NInputNumber, NModal, NRadioButton, NRadioGroup, NSelect, NTimePicker, NTooltip, useDialog, type DropdownOption } from "naive-ui";
import { EllipsisHorizontalOutline, EllipsisVerticalOutline, PauseOutline, PlayOutline, RefreshOutline, SettingsOutline } from "@vicons/ionicons5";
import HoursCompare from "../../shared/HoursCompare.vue";
import ProxyFields from "../../shared/ProxyFields.vue";
import { ADMIN_DAY_MAX, ADMIN_DAY_MIN, STUDY_DAY_DEFAULT, adminDayOptions, workerOptions } from "../../shared/studyFields";
import { isRecord, textOf } from "../../shared/text";
@@ -16,6 +17,8 @@ interface UserRow {
last_refresh_at: string | null;
credential_valid: boolean | null;
month_hours: string;
official_month_hours: string;
hours_source: "api" | "history";
monthly_target: number;
has_proxy: boolean;
proxy: string;
@@ -174,6 +177,8 @@ function asUser(value: unknown): UserRow | null {
last_refresh_at: typeof value.last_refresh_at === "string" && value.last_refresh_at ? value.last_refresh_at : null,
credential_valid: readValid(value.credential_valid),
month_hours: textOf(value.month_hours),
official_month_hours: textOf(value.official_month_hours),
hours_source: value.hours_source === "history" ? "history" : "api",
monthly_target: typeof value.monthly_target === "number" ? value.monthly_target : 600,
has_proxy: value.has_proxy === true,
proxy: textOf(value.proxy),
@@ -919,7 +924,14 @@ onMounted(() => {
<td class="name">{{ row.user_name || "—" }}</td>
<td class="company">{{ row.company || "—" }}</td>
<td :class="validityClass(validityText(row))">{{ validityText(row) }}</td>
<td class="when">{{ monthHoursText(row) }}</td>
<td class="when">
{{ monthHoursText(row) }}
<HoursCompare
v-if="row.hours_source === 'history' && monthHoursText(row) !== '—'"
:system="row.month_hours"
:official="row.official_month_hours"
/>
</td>
<td :class="taskText(row) === '运行中' ? 'ok' : 'quiet'">{{ taskText(row) }}</td>
<td class="when">{{ formatRefreshTime(row.study_opened_at) || "—" }}</td>
<td class="when">{{ row.proxy || "—" }}</td>
+17 -3
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { apiFetch } from "../../shared/http";
import HoursCompare from "../../shared/HoursCompare.vue";
import { computed, h, onMounted, ref } from "vue";
import { NAlert, NButton, NDataTable, NIcon, NPagination, NTooltip, type DataTableColumns } from "naive-ui";
import { RefreshOutline } from "@vicons/ionicons5";
@@ -16,6 +17,8 @@ interface HistoryHours {
month_hours: string | number | null;
today_hours: string | number | null;
total_hours: string | number | null;
hours_source: "api" | "history";
official_month_hours: string;
}
type SectionState = "loading" | "ready" | "error";
@@ -95,6 +98,10 @@ async function load() {
month_hours: asHour(payload.month_hours),
today_hours: asHour(payload.today_hours),
total_hours: asHour(payload.total_hours),
hours_source: payload.hours_source === "history" ? "history" : "api",
official_month_hours: typeof payload.official_month_hours === "string" || typeof payload.official_month_hours === "number"
? String(payload.official_month_hours)
: "",
};
historyLimited.value = payload.limited === true;
errorText.value = "";
@@ -119,12 +126,12 @@ function refresh() {
});
}
const historyFacts = computed(() => {
const historyFacts = computed<Array<{ label: string; value: string; compare?: boolean }>>(() => {
const current = hours.value;
return [
{ label: "总学时", value: current ? withMinutes(amount(current.total_hours)) : "" },
{ label: "本年学时", value: current ? withMinutes(amount(current.year_hours)) : "" },
{ label: "本月学时", value: current ? withMinutes(amount(current.month_hours)) : "" },
{ label: "本月学时", value: current ? withMinutes(amount(current.month_hours)) : "", compare: current?.hours_source === "history" },
{ label: "本日学时", value: current ? withMinutes(amount(current.today_hours)) : "" },
];
});
@@ -226,7 +233,14 @@ onMounted(refresh);
<dt>{{ item.label }}</dt>
<dd>
<span v-if="state === 'loading'" class="bone bone-value"></span>
<template v-else>{{ state === "ready" ? item.value : "—" }}</template>
<template v-else>
{{ state === "ready" ? item.value : "—" }}
<HoursCompare
v-if="state === 'ready' && item.compare && item.value && item.value !== '—'"
:system="String(hours?.month_hours ?? '')"
:official="hours?.official_month_hours ?? ''"
/>
</template>
</dd>
</div>
</dl>
+23 -3
View File
@@ -3,6 +3,7 @@ import { apiFetch } from "../../shared/http";
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
import { NAlert, NButton, NForm, NFormItem, NIcon, NInputNumber, NModal, NProgress, NRadioButton, NRadioGroup, NSelect, NSwitch, NTimePicker, NTooltip } from "naive-ui";
import { GlobeOutline, PlayOutline, RefreshOutline, StopOutline } from "@vicons/ionicons5";
import HoursCompare from "../../shared/HoursCompare.vue";
import ProxyFields from "../../shared/ProxyFields.vue";
import { STUDY_DAY_DEFAULT, STUDY_DAY_MAX, STUDY_DAY_MIN, dayOptions, workerOptions } from "../../shared/studyFields";
import { failureText } from "../../shared/text";
@@ -19,6 +20,7 @@ interface HomeSummary {
total_score: string;
points: string | number | null;
hours_source: "api" | "history";
official_month_hours: string;
limited?: boolean;
}
@@ -161,11 +163,25 @@ function withMinutes(value: string) {
const historyHoursNote = "由于Euniv学时统计缺陷/统计延后,本系统已开启采用当月学习历史统计本月学时,可能会导致本系统中显示的本月学时与Euniv官方网站不一样。";
const facts = computed(() => {
interface HourFact {
label: string;
value: string;
compare?: boolean;
system?: string;
official?: string;
}
const facts = computed<HourFact[]>(() => {
const current = summary.value;
return [
{ label: "本年学时", value: current ? withMinutes(amount(current.year_hours)) : "" },
{ label: "本月学时", value: current ? withMinutes(amount(current.month_hours)) : "" },
{
label: "本月学时",
value: current ? withMinutes(amount(current.month_hours)) : "",
compare: current?.hours_source === "history",
system: current?.month_hours ?? "",
official: current?.official_month_hours ?? "",
},
{ label: "本日学时", value: current ? withMinutes(amount(current.today_hours)) : "" },
{ label: "总学时", value: current ? withMinutes(amount(current.total_hours)) : "" },
{ label: "累计学分", value: current ? amount(current.total_score) : "" },
@@ -186,6 +202,7 @@ function asSummary(value: unknown): HomeSummary | null {
level: typeof row.level === "string" ? row.level : "",
year_hours: String(text("year_hours") ?? ""),
month_hours: String(text("month_hours") ?? ""),
official_month_hours: String(text("official_month_hours") ?? ""),
today_hours: typeof row.today_hours === "number" || typeof row.today_hours === "string" ? row.today_hours : null,
total_hours: String(text("total_hours") ?? ""),
total_score: String(text("total_score") ?? ""),
@@ -1017,7 +1034,10 @@ onUnmounted(() => {
<dt>{{ item.label }}</dt>
<dd>
<span v-if="summaryState === 'loading'" class="bone bone-value"></span>
<template v-else>{{ item.value || "—" }}</template>
<template v-else>
{{ item.value || "—" }}
<HoursCompare v-if="item.compare && item.value && item.value !== '—'" :system="String(item.system || '')" :official="String(item.official || '')" />
</template>
</dd>
</div>
</dl>
+25
View File
@@ -0,0 +1,25 @@
<script setup lang="ts">
import { NTooltip } from "naive-ui";
defineProps<{
system: string;
official: string;
}>();
function minutes(value: string) {
const text = value.trim();
return text ? `${text} 分钟` : "—";
}
</script>
<template>
<n-tooltip placement="top">
<template #trigger>
<sup class="hours-mark" tabindex="0">对比</sup>
</template>
<div class="hours-compare">
<div>系统统计: {{ minutes(system) }}</div>
<div>官方统计: {{ minutes(official) }}</div>
</div>
</n-tooltip>
</template>
+14
View File
@@ -1019,6 +1019,20 @@ select {
font-variant-numeric: tabular-nums;
}
.hours-mark {
margin-left: 4px;
color: #f5a524;
font-size: 11px;
font-weight: 650;
letter-spacing: 0;
cursor: help;
vertical-align: super;
}
.hours-compare {
line-height: 1.6;
}
.board {
min-width: 0;
min-height: 0;