mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 01:09:56 -05:00
Fix: Cache-Boot (KCEF Corruption)
This commit is contained in:
+10
-8
@@ -91,6 +91,13 @@
|
||||
return () => clearTimeout(timer);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!appReady) return;
|
||||
downloadStore.poll();
|
||||
const dlInterval = setInterval(() => downloadStore.poll(), 2000);
|
||||
return () => clearInterval(dlInterval);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (store.settings.discordRpc) {
|
||||
initRpc();
|
||||
@@ -125,9 +132,11 @@
|
||||
applyZoom();
|
||||
});
|
||||
|
||||
|
||||
const unlistenClose = await win.listen("tauri://close-requested", handleCloseRequested);
|
||||
|
||||
await initStore();
|
||||
startProbe();
|
||||
|
||||
if (store.settings.autoStartServer) {
|
||||
invoke<void>("spawn_server", { binary: store.settings.serverBinary }).catch((err: any) => {
|
||||
if (err?.kind === "NotConfigured") boot.notConfigured = true;
|
||||
@@ -135,20 +144,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
await initStore();
|
||||
startProbe();
|
||||
|
||||
const unlistenDownload = await listen<{ chapterId: number; mangaId: number; progress: number }[]>(
|
||||
"download-progress",
|
||||
e => setActiveDownloads(e.payload),
|
||||
);
|
||||
|
||||
await downloadStore.poll();
|
||||
const dlInterval = setInterval(() => downloadStore.poll(), 2000);
|
||||
|
||||
return () => {
|
||||
stopProbe();
|
||||
clearInterval(dlInterval);
|
||||
unlistenResize();
|
||||
unlistenScale();
|
||||
unlistenDownload();
|
||||
|
||||
@@ -559,15 +559,15 @@
|
||||
.page-loader-single {
|
||||
width: min(100%, var(--effective-width, 100%));
|
||||
max-width: var(--effective-width, 100%);
|
||||
max-height: calc(100vh - 80px);
|
||||
max-height: calc(var(--visual-vh, 100vh) - 80px);
|
||||
aspect-ratio: 2 / 3;
|
||||
}
|
||||
|
||||
.img { display: block; user-select: none; image-rendering: auto; }
|
||||
.img:global(.optimize-contrast) { image-rendering: -webkit-optimize-contrast; }
|
||||
:global(.fit-width) { max-width: var(--effective-width, 100%); width: 100%; height: auto; }
|
||||
:global(.fit-height) { max-height: calc(100vh - 80px); width: auto; max-width: var(--effective-width, 100%); height: auto; }
|
||||
:global(.fit-screen) { max-width: var(--effective-width, 100%); max-height: calc(100vh - 80px); object-fit: contain; height: auto; }
|
||||
:global(.fit-height) { max-height: calc(var(--visual-vh, 100vh) - 80px); width: auto; max-width: var(--effective-width, 100%); height: auto; }
|
||||
:global(.fit-screen) { max-width: var(--effective-width, 100%); max-height: calc(var(--visual-vh, 100vh) - 80px); object-fit: contain; height: auto; }
|
||||
:global(.fit-original) { max-width: 100%; width: auto; height: auto; }
|
||||
:global(.strip-gap) { margin-bottom: 8px; }
|
||||
|
||||
|
||||
+66
-43
@@ -4,7 +4,8 @@ import { trackingState } from "@features/tracking/store/tracki
|
||||
import { loadAllStores } from "@core/persistence/persist";
|
||||
import { notifyReauthSuccess } from "@api/client";
|
||||
|
||||
const MAX_ATTEMPTS = 40;
|
||||
const MAX_ATTEMPTS = 15;
|
||||
const BG_MAX_ATTEMPTS = 60;
|
||||
|
||||
export const boot = $state({
|
||||
serverProbeOk: false,
|
||||
@@ -26,6 +27,44 @@ export async function initStore() {
|
||||
store.hydrate(saved);
|
||||
}
|
||||
|
||||
function handleProbeSuccess(gen: number) {
|
||||
if (gen !== probeGeneration) return;
|
||||
boot.serverProbeOk = true;
|
||||
boot.failed = false;
|
||||
boot.skipped = false;
|
||||
trackingState.bootSync().catch(() => {});
|
||||
}
|
||||
|
||||
function handleAuthRequired(gen: number) {
|
||||
if (gen !== probeGeneration) return;
|
||||
boot.serverProbeOk = true;
|
||||
boot.failed = false;
|
||||
const mode = store.settings.serverAuthMode ?? "NONE";
|
||||
if (mode === "BASIC_AUTH") {
|
||||
const user = store.settings.serverAuthUser?.trim() ?? "";
|
||||
const pass = store.settings.serverAuthPass?.trim() ?? "";
|
||||
if (user && pass) {
|
||||
loginBasic(user, pass)
|
||||
.then(() => { if (gen === probeGeneration) trackingState.bootSync().catch(() => {}); })
|
||||
.catch(() => {
|
||||
if (gen !== probeGeneration) return;
|
||||
boot.loginUser = store.settings.serverAuthUser ?? "";
|
||||
boot.loginRequired = true;
|
||||
});
|
||||
return;
|
||||
}
|
||||
boot.loginUser = store.settings.serverAuthUser ?? "";
|
||||
boot.loginRequired = true;
|
||||
return;
|
||||
}
|
||||
if (mode === "UI_LOGIN") {
|
||||
boot.loginUser = store.settings.serverAuthUser ?? "";
|
||||
boot.loginRequired = true;
|
||||
return;
|
||||
}
|
||||
trackingState.bootSync().catch(() => {});
|
||||
}
|
||||
|
||||
export function startProbe() {
|
||||
const gen = ++probeGeneration;
|
||||
boot.failed = false;
|
||||
@@ -36,51 +75,36 @@ export function startProbe() {
|
||||
async function probe() {
|
||||
if (gen !== probeGeneration) return;
|
||||
tries++;
|
||||
|
||||
const result = await probeServer();
|
||||
if (gen !== probeGeneration) return;
|
||||
|
||||
if (result === "ok") {
|
||||
boot.serverProbeOk = true;
|
||||
trackingState.bootSync().catch(() => {});
|
||||
return;
|
||||
}
|
||||
if (result === "ok") { handleProbeSuccess(gen); return; }
|
||||
if (result === "auth_required") { handleAuthRequired(gen); return; }
|
||||
if (tries >= MAX_ATTEMPTS) { boot.failed = true; startBackgroundProbe(gen); return; }
|
||||
|
||||
if (result === "auth_required") {
|
||||
boot.serverProbeOk = true;
|
||||
const mode = store.settings.serverAuthMode ?? "NONE";
|
||||
|
||||
if (mode === "BASIC_AUTH") {
|
||||
const user = store.settings.serverAuthUser?.trim() ?? "";
|
||||
const pass = store.settings.serverAuthPass?.trim() ?? "";
|
||||
if (user && pass) {
|
||||
try {
|
||||
await loginBasic(user, pass);
|
||||
if (gen !== probeGeneration) return;
|
||||
trackingState.bootSync().catch(() => {});
|
||||
return;
|
||||
} catch {}
|
||||
}
|
||||
boot.loginUser = store.settings.serverAuthUser ?? "";
|
||||
boot.loginRequired = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode === "UI_LOGIN") {
|
||||
boot.loginUser = store.settings.serverAuthUser ?? "";
|
||||
boot.loginRequired = true;
|
||||
return;
|
||||
}
|
||||
|
||||
trackingState.bootSync().catch(() => {});
|
||||
return;
|
||||
}
|
||||
|
||||
if (tries >= MAX_ATTEMPTS) { boot.failed = true; return; }
|
||||
setTimeout(probe, Math.min(750 + tries * 250, 3000));
|
||||
setTimeout(probe, Math.min(300 + tries * 150, 1500));
|
||||
}
|
||||
|
||||
setTimeout(probe, 2000);
|
||||
setTimeout(probe, 100);
|
||||
}
|
||||
|
||||
function startBackgroundProbe(gen: number) {
|
||||
let bgTries = 0;
|
||||
|
||||
async function bgProbe() {
|
||||
if (gen !== probeGeneration) return;
|
||||
bgTries++;
|
||||
const result = await probeServer();
|
||||
if (gen !== probeGeneration) return;
|
||||
|
||||
if (result === "ok") { handleProbeSuccess(gen); return; }
|
||||
if (result === "auth_required") { handleAuthRequired(gen); return; }
|
||||
if (bgTries >= BG_MAX_ATTEMPTS) return;
|
||||
|
||||
setTimeout(bgProbe, 2000);
|
||||
}
|
||||
|
||||
setTimeout(bgProbe, 2000);
|
||||
}
|
||||
|
||||
export function stopProbe() {
|
||||
@@ -94,7 +118,6 @@ export async function submitLogin(onSuccess: () => void): Promise<void> {
|
||||
}
|
||||
boot.loginBusy = true;
|
||||
boot.loginError = null;
|
||||
|
||||
try {
|
||||
const mode = store.settings.serverAuthMode ?? "NONE";
|
||||
if (mode === "UI_LOGIN") {
|
||||
@@ -102,7 +125,6 @@ export async function submitLogin(onSuccess: () => void): Promise<void> {
|
||||
} else {
|
||||
await loginBasic(boot.loginUser.trim(), boot.loginPass.trim());
|
||||
}
|
||||
|
||||
boot.loginRequired = false;
|
||||
boot.sessionExpired = false;
|
||||
boot.skipped = false;
|
||||
@@ -128,10 +150,11 @@ export function retryBoot() {
|
||||
}
|
||||
|
||||
export function bypassBoot(onReady: () => void) {
|
||||
probeGeneration++;
|
||||
const gen = probeGeneration;
|
||||
boot.serverProbeOk = true;
|
||||
boot.loginRequired = false;
|
||||
boot.sessionExpired = false;
|
||||
boot.skipped = true;
|
||||
onReady();
|
||||
startBackgroundProbe(gen);
|
||||
}
|
||||
Reference in New Issue
Block a user