fix: 补上清单里还没对上的登录拒绝、会话回退和代理清理

This commit is contained in:
2026-11-16 16:46:37 +08:00
parent a1e2b6e65c
commit 3cff9dc37a
19 changed files with 223 additions and 65 deletions
+13 -9
View File
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { apiFetch } from "../../shared/http";
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
import { NAlert, NButton, NForm, NFormItem, NIcon, NInputNumber, NModal, NProgress, NSelect, NSwitch, NTimePicker, NTooltip } from "naive-ui";
import { GlobeOutline, PlayOutline, RefreshOutline, StopOutline } from "@vicons/ionicons5";
@@ -17,6 +18,7 @@ interface HomeSummary {
total_hours: string;
total_score: string;
points: string | number | null;
limited?: boolean;
}
interface StudyWorker {
@@ -165,6 +167,7 @@ function asSummary(value: unknown): HomeSummary | null {
total_hours: String(text("total_hours") ?? ""),
total_score: String(text("total_score") ?? ""),
points: typeof row.points === "number" || typeof row.points === "string" ? row.points : null,
limited: row.limited === true,
};
}
@@ -241,7 +244,7 @@ async function loadSummary() {
const hadData = summary.value !== null;
if (!hadData) summaryState.value = "loading";
try {
const response = await fetch("/api/home/summary");
const response = await apiFetch("/api/home/summary");
const payload = await response.json().catch(() => ({}));
if (!response.ok) {
summaryError.value = "个人学习信息没有获取到。";
@@ -280,7 +283,7 @@ function refresh() {
async function loadTarget() {
try {
const res = await fetch("/api/settings/monthly-target");
const res = await apiFetch("/api/settings/monthly-target");
if (!res.ok) return false;
const data = await res.json();
monthlyTarget.value = data.monthly_target ?? 600;
@@ -314,7 +317,7 @@ const startTime = computed({
async function loadStart() {
try {
const res = await fetch("/api/settings/study-start");
const res = await apiFetch("/api/settings/study-start");
if (!res.ok) return false;
const data = await res.json();
startDay.value = typeof data.day === "number" ? data.day : STUDY_DAY_DEFAULT;
@@ -335,7 +338,7 @@ const scheduleReady = computed(() => targetLoaded.value && startLoaded.value &&
async function loadWorkers() {
try {
const res = await fetch("/api/settings/course-workers");
const res = await apiFetch("/api/settings/course-workers");
if (!res.ok) return false;
const data = await res.json();
courseWorkers.value = typeof data.workers === "number" ? data.workers : 1;
@@ -347,7 +350,7 @@ async function loadWorkers() {
}
async function putJson(url: string, body: Record<string, unknown>, fallback: string) {
const res = await fetch(url, {
const res = await apiFetch(url, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
@@ -451,7 +454,7 @@ const proxyOptions = [
async function loadProxy() {
try {
const res = await fetch("/api/settings/proxy");
const res = await apiFetch("/api/settings/proxy");
const data = await res.json().catch(() => ({}));
if (!res.ok) return false;
proxyScheme.value = typeof data.scheme === "string" && data.scheme ? data.scheme : "off";
@@ -499,7 +502,7 @@ async function saveProxy() {
}
proxySaving.value = true;
try {
const res = await fetch("/api/settings/proxy", {
const res = await apiFetch("/api/settings/proxy", {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(
@@ -566,7 +569,7 @@ function applyStudyControl(payload: Record<string, unknown>) {
async function loadStudyControl() {
try {
const res = await fetch("/api/settings/study-control");
const res = await apiFetch("/api/settings/study-control");
if (res.status === 401) {
stopStudySocket();
return;
@@ -743,7 +746,7 @@ async function toggleStudy() {
studyError.value = "";
const action = studyControl.value.started ? "stop" : "start";
try {
const res = await fetch("/api/settings/study-control", {
const res = await apiFetch("/api/settings/study-control", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ action }),
@@ -830,6 +833,7 @@ onUnmounted(() => {
</dd>
</div>
</dl>
<p v-if="summary?.limited" class="study-live-hint">只统计了最近 50 页</p>
</section>
<section class="panel-card study-card" :class="{ 'is-busy': studyingWorkers.length > 0 }">