feat: 首页顶部改为本年、本月、今日和累计学时,以及累计学分和可用积分

This commit is contained in:
2026-10-27 05:30:01 +08:00
parent 060dc60c68
commit 84772c9f7a
4 changed files with 34 additions and 22 deletions
+17 -7
View File
@@ -21,11 +21,12 @@ interface HomeProfile {
avatar: string;
department: string;
level: string;
year_score: string;
month_score: string;
year_hours: string;
month_hours: string;
today_hours: string | number | null;
total_hours: string;
total_score: string;
points: string | number | null;
exams: ExamItem[];
trainings: TrainingItem[];
}
@@ -37,15 +38,24 @@ const loading = ref(false);
let timer = 0;
let requestId = 0;
function amount(value: string | number | null | undefined) {
if (value === null || value === undefined || value === "") return "—";
const numeric = Number(value);
if (!Number.isFinite(numeric)) return String(value);
if (Number.isInteger(numeric)) return String(numeric);
return String(value);
}
const facts = computed(() => {
const current = profile.value;
if (!current) return [];
return [
{ label: "本年学分", value: current.year_score },
{ label: "本月学分", value: current.month_score },
{ label: "本月学时", value: current.month_hours },
{ label: "累计学时", value: current.total_hours },
{ label: "累计学分", value: current.total_score },
{ label: "本年学时", value: amount(current.year_hours) },
{ label: "本月学时", value: amount(current.month_hours) },
{ label: "今日学时", value: amount(current.today_hours) },
{ label: "累计学时", value: amount(current.total_hours) },
{ label: "累计学分", value: amount(current.total_score) },
{ label: "可用积分", value: amount(current.points) },
];
});