feat: 学习进度轮询、学时依据与首页代理弹窗

This commit is contained in:
2026-11-15 05:13:48 +08:00
parent f0a2bdd854
commit 5acbea35fb
17 changed files with 921 additions and 221 deletions
+27 -27
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref } from "vue";
import { NAlert, NButton, NIcon, NInput, NPagination, NTooltip } from "naive-ui";
import { FlashOutline, RefreshOutline } from "@vicons/ionicons5";
import { NAlert, NButton, NIcon, NInput, NPagination, NSpin, NTooltip } from "naive-ui";
import { RefreshOutline } from "@vicons/ionicons5";
interface ProxyRow {
id: number;
@@ -89,6 +89,12 @@ function formatLatency(value: number | null) {
return `${value} ms`;
}
const probingHost = computed(() => {
if (probingId.value == null) return "";
const row = items.value.find((item) => item.id === probingId.value);
return row ? `${row.host}:${row.port}` : "";
});
function schemeLabel(value: string) {
return value ? value.toUpperCase() : "—";
}
@@ -261,14 +267,9 @@ onUnmounted(() => stopPoll());
</template>
立即更新
</n-tooltip>
<n-tooltip>
<template #trigger>
<n-button quaternary circle attr-type="button" :loading="probingAll" :disabled="probingAll || fetching || !items.length" aria-label="测试全部延迟" @click="probeAll">
<template #icon><n-icon><FlashOutline /></n-icon></template>
</n-button>
</template>
测试全部延迟
</n-tooltip>
<n-button size="small" attr-type="button" :loading="probingAll" :disabled="probingAll || fetching || !items.length" @click="probeAll">
测试全部
</n-button>
<n-input v-model:value="query" placeholder="地址" clearable @clear="search" />
<n-button attr-type="submit">搜索</n-button>
</form>
@@ -287,6 +288,8 @@ onUnmounted(() => stopPoll());
</button>
</div>
<n-alert v-if="errorText" class="admin-alert" type="error">{{ errorText }}</n-alert>
<n-alert v-if="probingAll" class="admin-alert" type="info">正在测试全部代理延迟</n-alert>
<n-alert v-else-if="probingId != null" class="admin-alert" type="info">正在测试 {{ probingHost }} 延迟</n-alert>
<div class="admin-scroll">
<p v-if="loading" class="admin-status">正在获取</p>
<p v-else-if="fetching && !items.length" class="admin-status">正在获取</p>
@@ -314,26 +317,23 @@ onUnmounted(() => stopPoll());
<td>{{ schemeLabel(row.scheme) }}</td>
<td>{{ row.anonymity }}</td>
<td>{{ row.source }}</td>
<td class="when">{{ formatLatency(row.latency_ms) }}</td>
<td class="when">
<span v-if="probingAll || probingId === row.id" class="probe-loading">
<n-spin :size="14" />测试中
</span>
<template v-else>{{ formatLatency(row.latency_ms) }}</template>
</td>
<td :class="statusClass(row)">{{ row.status_text }}</td>
<td class="when">{{ formatTime(row.last_checked_at) || "—" }}</td>
<td>
<n-tooltip>
<template #trigger>
<n-button
size="small"
quaternary
circle
:loading="probingId === row.id"
:disabled="probingAll || fetching || (probingId != null && probingId !== row.id)"
:aria-label="`测试 ${row.host} 延迟`"
@click="probeOne(row)"
>
<template #icon><n-icon><FlashOutline /></n-icon></template>
</n-button>
</template>
测试延迟
</n-tooltip>
<n-button
size="tiny"
:loading="probingId === row.id"
:disabled="probingAll || fetching || (probingId != null && probingId !== row.id)"
@click="probeOne(row)"
>
测试
</n-button>
</td>
</tr>
</tbody>