fix: 主动登出后误弹「登录已失效」与游客埋点 403

- apiLogout 成功后复位 sessionSeen:主动登出不再被后续 401 误判为「被顶下线」,消除登出后登录页误弹 AccountGuard 弹窗,及其引发的二次 logout 清掉刚补发 CSRF cookie、首次登录报「CSRF token 缺失」的问题

- apiTelemetryPageView 无 CSRF cookie 时跳过上报:游客首屏(cookie 尚未由 GET 补发)不再产生必然失败的 403,cookie 补发后照常上报
This commit is contained in:
2026-09-26 04:55:27 +08:00
parent 794654e327
commit 21174dc5cb

View File

@@ -1449,6 +1449,11 @@ export async function apiLogout() {
method: "POST", method: "POST",
headers: clientHeaders(), headers: clientHeaders(),
}); });
// 主动登出后本标签页不再算"曾登录":否则登出后收到的首个 401 会被
// notifySessionEnded 误判为"被顶下线",误弹"登录已失效"弹窗
if (res.ok) {
sessionSeen = false;
}
return res.json(); return res.json();
} }
@@ -1626,6 +1631,9 @@ export async function apiAdminAnalytics(range: "7d" | "30d" = "7d"): Promise<Ana
} }
export async function apiTelemetryPageView(path: string, ref: string): Promise<void> { export async function apiTelemetryPageView(path: string, ref: string): Promise<void> {
// 游客尚无 CSRF cookie 时该 POST 必然 403(响应补发的 cookie 本请求用不上),
// 直接跳过:后续 GET 补发 cookie 之后的页面浏览照常上报
if (!getCSRFToken()) return;
try { try {
await fetchWithRefresh("/api/telemetry/pageview", { await fetchWithRefresh("/api/telemetry/pageview", {
method: "POST", method: "POST",