Fix CHSI catalogue session verification and pagination
This commit is contained in:
+31
-13
@@ -1857,16 +1857,22 @@ function SettingsPanel({ notify }: { notify: Notify }) {
|
||||
const browserWaiting =
|
||||
auth && ["opening", "waiting"].includes(auth.browser_state);
|
||||
useEffect(() => {
|
||||
if (!browserWaiting) return;
|
||||
const timer = setInterval(
|
||||
() =>
|
||||
api<Auth>("/auth")
|
||||
.then(setAuth)
|
||||
.catch(() => {}),
|
||||
2000,
|
||||
);
|
||||
return () => clearInterval(timer);
|
||||
}, [browserWaiting]);
|
||||
if (busy) return;
|
||||
let active = true;
|
||||
const refreshAuth = () =>
|
||||
api<Auth>("/auth")
|
||||
.then((result) => {
|
||||
if (active) setAuth(result);
|
||||
})
|
||||
.catch(() => {});
|
||||
const timer = setInterval(refreshAuth, 2000);
|
||||
window.addEventListener("focus", refreshAuth);
|
||||
return () => {
|
||||
active = false;
|
||||
clearInterval(timer);
|
||||
window.removeEventListener("focus", refreshAuth);
|
||||
};
|
||||
}, [busy]);
|
||||
async function save(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setBusy("save");
|
||||
@@ -2020,12 +2026,24 @@ function SettingsPanel({ notify }: { notify: Notify }) {
|
||||
<Badge tone={auth?.valid ? "green" : "amber"}>
|
||||
{auth?.valid
|
||||
? "已验证"
|
||||
: auth?.saved
|
||||
? "已保存,待验证"
|
||||
: "尚未登录"}
|
||||
: auth?.state === "captcha_required"
|
||||
? "需人工验证"
|
||||
: auth?.state === "login_required"
|
||||
? "需重新登录"
|
||||
: auth?.saved
|
||||
? "已保存,待验证"
|
||||
: "尚未登录"}
|
||||
</Badge>
|
||||
</div>
|
||||
<p>{auth?.message}</p>
|
||||
{auth?.checked_at && (
|
||||
<p className="form-hint">
|
||||
最近检查:
|
||||
{new Date(auth.checked_at).toLocaleString("zh-CN", {
|
||||
hour12: false,
|
||||
})}
|
||||
</p>
|
||||
)}
|
||||
<div className="browser-login">
|
||||
<div>
|
||||
<Globe2 size={22} />
|
||||
|
||||
Reference in New Issue
Block a user