From 2fb40c37aedd6ea365a91db45411be7355257b29 Mon Sep 17 00:00:00 2001 From: Nixevol Date: Mon, 16 Nov 2026 03:18:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=95=B4=E7=90=86=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E3=80=81=E7=99=BB=E5=BD=95=E5=92=8C=E7=AE=A1=E7=90=86=E7=AB=AF?= =?UTF-8?q?=E7=9A=84=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/index.html | 11 + web/src/App.vue | 93 +++-- web/src/features/admin/CoursesView.vue | 51 ++- web/src/features/admin/ProxiesView.vue | 116 +++-- web/src/features/admin/SettingsView.vue | 51 ++- web/src/features/admin/UsersView.vue | 395 +++++++++++++----- web/src/features/auth/LoginView.vue | 254 ++++++++--- web/src/features/exams/ExamsView.vue | 32 +- web/src/features/history/HoursHistoryView.vue | 47 ++- web/src/features/home/HomeView.vue | 160 ++++--- web/src/features/trainings/TrainingsView.vue | 32 +- web/src/shared/session.ts | 4 +- web/src/shared/studyFields.ts | 4 +- web/src/shared/theme.ts | 9 +- web/src/shell/AdminShell.vue | 46 +- web/src/shell/Shell.vue | 48 ++- web/src/styles.css | 185 ++++++-- web/tsconfig.json | 1 + web/vite.config.ts | 1 + 19 files changed, 1117 insertions(+), 423 deletions(-) diff --git a/web/index.html b/web/index.html index 6ff828b..b8045f4 100644 --- a/web/index.html +++ b/web/index.html @@ -3,7 +3,18 @@ + EunivTools + +
diff --git a/web/src/App.vue b/web/src/App.vue index a05bd1f..7d20af9 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -1,6 +1,6 @@ @@ -65,10 +98,22 @@ function onLogin(next: AppSession) { -
+
+
+

暂时无法确认登录状态

+
+ 重试 +
+
+
+
+
+

暂时无法确认登录状态

+ 重试 +
- +
diff --git a/web/src/features/admin/CoursesView.vue b/web/src/features/admin/CoursesView.vue index 554e651..3687522 100644 --- a/web/src/features/admin/CoursesView.vue +++ b/web/src/features/admin/CoursesView.vue @@ -11,7 +11,6 @@ interface CourseRow { learners: string; released_on: string; updated_on: string; - comments: string; } interface KindOption { @@ -54,10 +53,19 @@ function asCourse(value: unknown): CourseRow | null { learners: textOf(value.learners), released_on: textOf(value.released_on), updated_on: textOf(value.updated_on), - comments: textOf(value.comments), }; } +function setError(next: string) { + if (errorText.value !== next) errorText.value = next; +} + +function courseKey(row: CourseRow, index: number) { + const base = row.url || row.title || "course"; + const first = items.value.findIndex((item) => (item.url || item.title || "course") === base); + return first === index ? base : `${base}#${index}`; +} + function formatTime(value: string | null) { if (!value) return ""; const date = new Date(value); @@ -66,9 +74,8 @@ function formatTime(value: string | null) { return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`; } -async function load() { - loading.value = items.value.length === 0; - errorText.value = ""; +async function load(clamp = true) { + if (items.value.length === 0) loading.value = true; try { const params = new URLSearchParams({ q: appliedQuery.value, @@ -79,11 +86,11 @@ async function load() { const response = await fetch(`/api/admin/courses?${params}`); const payload = await response.json().catch(() => ({})); if (!response.ok) { - errorText.value = isRecord(payload) && typeof payload.detail === "string" ? payload.detail : "课程清单没有获取到。"; + setError("课程清单没有获取到。"); return; } if (!isRecord(payload) || !Array.isArray(payload.items)) { - errorText.value = "课程清单没有获取到。"; + setError("数据异常"); return; } items.value = payload.items.map(asCourse).filter((item): item is CourseRow => item !== null); @@ -91,11 +98,17 @@ async function load() { syncedAt.value = typeof payload.synced_at === "string" ? payload.synced_at : null; kinds.value = Array.isArray(payload.kinds) ? payload.kinds.flatMap(asKind) : []; fetching.value = payload.running === true; - if (typeof payload.message === "string" && payload.message) errorText.value = payload.message; + const message = typeof payload.message === "string" ? payload.message : ""; + setError(message); if (fetching.value) startPoll(); else stopPoll(); + const maxPage = Math.max(1, Math.ceil(total.value / pageSize.value)); + if (clamp && page.value > maxPage) { + page.value = maxPage; + await load(false); + } } catch { - errorText.value = "课程清单没有获取到。"; + setError("课程清单没有获取到。"); } finally { loading.value = false; } @@ -112,20 +125,20 @@ function stopPoll() { } async function loadCourses() { - errorText.value = ""; + setError(""); fetching.value = true; try { const response = await fetch("/api/admin/courses/load", { method: "POST" }); - const payload = await response.json().catch(() => ({})); + await response.json().catch(() => ({})); if (!response.ok) { fetching.value = false; - errorText.value = isRecord(payload) && typeof payload.detail === "string" ? payload.detail : "课程清单没有获取到。"; + setError("课程清单没有获取到。"); return; } - startPoll(); + await load(); } catch { fetching.value = false; - errorText.value = "课程清单没有获取到。"; + setError("课程清单没有获取到。"); } } @@ -173,11 +186,11 @@ onUnmounted(() => stopPoll());