Merge branch 'test'

This commit is contained in:
2026-07-28 21:24:54 +08:00
5 changed files with 241 additions and 250 deletions
+4 -12
View File
@@ -29,7 +29,6 @@ async function apiFetch(endpoint, options = {}) {
headers: { ...headers, ...(options.headers || {}) },
});
// ---- 统一处理 401 认证失效 ----
if (res.status === 401) {
clearAuthState();
window.dispatchEvent(new CustomEvent("auth:expired"));
@@ -298,7 +297,7 @@ const app = createApp({
let logTimer = null;
let logFetching = false;
// ---- Ping 延迟检测(移到 setup 内部) ----
// ---- Ping 延迟检测 ----
const pingLatency = ref(null);
let pingTimer = null;
const PING_INTERVAL_MS = 30000;
@@ -313,7 +312,6 @@ const app = createApp({
const pingIcon = computed(() => {
if (pingLatency.value === null) {
// 未接入/失败 —— 断开图标
return `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 256 256">
<path d="M0 0h256v256H0z" fill="none"/>
<g fill="currentColor">
@@ -323,13 +321,11 @@ const app = createApp({
</svg>`;
}
if (pingLatency.value < 1000) {
// 延迟好 —— 实心信号图标(青色/绿色)
return `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 25 24">
<path d="M0 0h25v24H0z" fill="none"/>
<path fill="currentColor" d="M2.046 6.725c6.192-4.967 15.05-4.967 21.243 0l.779.625l-11.4 14.25L1.265 7.35z"/>
</svg>`;
}
// 延迟一般(1000-5000ms)—— 空心信号图标(黄色/橙色)
return `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24">
<path d="M0 0h24v24H0z" fill="none"/>
<path fill="none" stroke="currentColor" stroke-width="2" d="M21.996 7.505L12 20L2.004 7.505c5.827-4.673 14.165-4.673 19.992 0Z"/>
@@ -337,7 +333,6 @@ const app = createApp({
});
async function doPing() {
// 如果 frpc 未运行,直接显示 --ms
if (!frpcRunning.value) {
pingLatency.value = null;
return;
@@ -347,9 +342,7 @@ const app = createApp({
try {
const res = await fetch(
`/api/ping?target=${encodeURIComponent(addr)}`,
{
signal: AbortSignal.timeout(PING_TIMEOUT_MS),
},
{ signal: AbortSignal.timeout(PING_TIMEOUT_MS) },
);
if (!res.ok) throw new Error("Ping failed");
const end = performance.now();
@@ -408,7 +401,7 @@ const app = createApp({
watch(frpcRunning, (running) => {
if (!running) {
stopPingPolling();
pingLatency.value = null; // 显示 --ms
pingLatency.value = null;
} else if (loggedIn.value) {
startPingPolling();
}
@@ -810,7 +803,6 @@ const app = createApp({
showToken,
// ---- 新增 Ping 相关导出 ----
pingLatency,
pingStatusClass,
pingIcon,
@@ -818,4 +810,4 @@ const app = createApp({
},
});
app.mount("#app");
app.mount("#app");