mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 09:19:56 -05:00
Feat: Home Re-Design & MacOS Detection Fix
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { store } from "@store/state.svelte";
|
||||
import { probeServer, loginBasic } from "@core/auth";
|
||||
|
||||
const MAX_ATTEMPTS = 10;
|
||||
const MAX_ATTEMPTS = 40;
|
||||
|
||||
export const boot = $state({
|
||||
serverProbeOk: false,
|
||||
@@ -15,20 +15,20 @@ export const boot = $state({
|
||||
loginBusy: false,
|
||||
});
|
||||
|
||||
let cancelProbe = false;
|
||||
let probeGeneration = 0;
|
||||
|
||||
export function startProbe() {
|
||||
cancelProbe = false;
|
||||
const gen = ++probeGeneration;
|
||||
boot.failed = false;
|
||||
boot.loginRequired = false;
|
||||
boot.unsupportedMode = false;
|
||||
let tries = 0;
|
||||
|
||||
async function probe() {
|
||||
if (cancelProbe) return;
|
||||
if (gen !== probeGeneration) return;
|
||||
tries++;
|
||||
const result = await probeServer();
|
||||
if (cancelProbe) return;
|
||||
if (gen !== probeGeneration) return;
|
||||
|
||||
if (result === "ok") {
|
||||
boot.serverProbeOk = true;
|
||||
@@ -59,14 +59,15 @@ export function startProbe() {
|
||||
}
|
||||
|
||||
if (tries >= MAX_ATTEMPTS) { boot.failed = true; return; }
|
||||
setTimeout(probe, 750);
|
||||
const delay = Math.min(750 + tries * 250, 3000);
|
||||
setTimeout(probe, delay);
|
||||
}
|
||||
|
||||
setTimeout(probe, 800);
|
||||
setTimeout(probe, 2000);
|
||||
}
|
||||
|
||||
export function stopProbe() {
|
||||
cancelProbe = true;
|
||||
probeGeneration++;
|
||||
}
|
||||
|
||||
export async function submitLogin(onSuccess: () => void) {
|
||||
@@ -99,7 +100,7 @@ export function retryBoot() {
|
||||
}
|
||||
|
||||
export function bypassBoot(onReady: () => void) {
|
||||
cancelProbe = true;
|
||||
probeGeneration++;
|
||||
boot.serverProbeOk = true;
|
||||
boot.loginRequired = false;
|
||||
boot.unsupportedMode = false;
|
||||
|
||||
@@ -224,6 +224,7 @@ class Store {
|
||||
markers: MarkerEntry[] = $state(saved?.markers ?? []);
|
||||
readLog: ReadLogEntry[] = $state(saved?.readLog ?? []);
|
||||
readingStats: ReadingStats = $state(saved?.readingStats ?? { ...DEFAULT_READING_STATS });
|
||||
dailyReadCounts: Record<string, number> = $state(saved?.dailyReadCounts ?? {});
|
||||
searchCache: Map<string, any> = $state(new Map());
|
||||
searchLibraryIds: Set<number> = $state(new Set());
|
||||
searchSrcOffset: number = $state(0);
|
||||
@@ -250,6 +251,7 @@ class Store {
|
||||
settings: this.settings, history: this.history,
|
||||
bookmarks: this.bookmarks, markers: this.markers,
|
||||
readLog: this.readLog, readingStats: this.readingStats,
|
||||
dailyReadCounts: this.dailyReadCounts,
|
||||
libraryUpdates: this.libraryUpdates,
|
||||
lastLibraryRefresh: this.lastLibraryRefresh,
|
||||
acknowledgedUpdateIds: [...this.acknowledgedUpdates],
|
||||
@@ -288,6 +290,8 @@ class Store {
|
||||
lastReadAt: entry.readAt, currentStreakDays: streak,
|
||||
longestStreakDays: Math.max(this.readingStats.longestStreakDays, streak), lastStreakDate: todayStr,
|
||||
};
|
||||
const dayKey = new Date().toISOString().slice(0, 10);
|
||||
this.dailyReadCounts = { ...this.dailyReadCounts, [dayKey]: (this.dailyReadCounts[dayKey] ?? 0) + 1 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +318,7 @@ class Store {
|
||||
getMarkersForChapter(chapterId: number) { return this.markers.filter(m => m.chapterId === chapterId); }
|
||||
getMarkersForManga(mangaId: number) { return this.markers.filter(m => m.mangaId === mangaId); }
|
||||
clearMarkersForManga(mangaId: number) { this.markers = this.markers.filter(m => m.mangaId !== mangaId); }
|
||||
clearHistory() { this.history = []; this.readLog = []; }
|
||||
clearHistory() { this.history = []; this.readLog = []; this.dailyReadCounts = {}; }
|
||||
|
||||
clearHistoryForManga(mangaId: number) {
|
||||
this.history = this.history.filter(x => x.mangaId !== mangaId);
|
||||
@@ -329,6 +333,7 @@ class Store {
|
||||
|
||||
wipeAllData() {
|
||||
this.history = []; this.readLog = []; this.markers = [];
|
||||
this.dailyReadCounts = {};
|
||||
this.readingStats = { ...DEFAULT_READING_STATS };
|
||||
this.settings = { ...this.settings, heroSlots: [null, null, null, null], mangaLinks: {} };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user