import { useEffect } from "react"; import { Outlet } from "react-router"; import { BottomBar } from "@/components/bottom-bar"; import { DownloadMonitor } from "@/components/download-monitor"; import { GameConsole } from "@/components/game-console"; import { LoginModal } from "@/components/login-modal"; import { ParticleBackground } from "@/components/particle-background"; import { Sidebar } from "@/components/sidebar"; import { useAuthStore } from "@/stores/auth-store"; import { useGameStore } from "@/stores/game-store"; import { useInstancesStore } from "@/stores/instances-store"; import { useLogsStore } from "@/stores/logs-store"; import { useSettingsStore } from "@/stores/settings-store"; import { useUIStore } from "@/stores/ui-store"; export function IndexPage() { const authStore = useAuthStore(); const settingsStore = useSettingsStore(); const uiStore = useUIStore(); const instancesStore = useInstancesStore(); const gameStore = useGameStore(); const logsStore = useLogsStore(); useEffect(() => { // ENFORCE DARK MODE: Always add 'dark' class and attribute document.documentElement.classList.add("dark"); document.documentElement.setAttribute("data-theme", "dark"); document.documentElement.classList.remove("light"); // Initialize stores // Include store functions in the dependency array to satisfy hooks lint. // These functions are stable in our store implementation, so listing them // here is safe and prevents lint warnings. authStore.checkAccount(); settingsStore.loadSettings(); logsStore.init(); settingsStore.detectJava(); instancesStore.loadInstances(); gameStore.loadVersions(); // Note: getVersion() would need Tauri API setup // getVersion().then((v) => uiStore.setAppVersion(v)); }, [ authStore.checkAccount, settingsStore.loadSettings, logsStore.init, settingsStore.detectJava, instancesStore.loadInstances, gameStore.loadVersions, ]); // Refresh versions when active instance changes useEffect(() => { if (instancesStore.activeInstanceId) { gameStore.loadVersions(); } else { gameStore.setVersions([]); } }, [ instancesStore.activeInstanceId, gameStore.loadVersions, gameStore.setVersions, ]); return (
{/* Modern Animated Background */}
{settingsStore.settings.customBackgroundPath && ( Background console.error("Failed to load main background:", e)} /> )} {/* Dimming Overlay for readability */} {settingsStore.settings.customBackgroundPath && (
)} {!settingsStore.settings.customBackgroundPath && ( <> {settingsStore.settings.theme === "dark" ? (
) : (
)} {uiStore.currentView === "home" && }
)} {/* Subtle Grid Overlay */}
{/* Content Wrapper */}
{/* Floating Sidebar */} {/* Main Content Area - Transparent & Flat */}
{/* Window Drag Region */}
{/* App Content */}
{/* Views Container */}
{/* Download Monitor Overlay */}
{/* Bottom Bar */} {uiStore.currentView === "home" && }
{/* Logout Confirmation Dialog */} {authStore.isLogoutConfirmOpen && (

Logout

Are you sure you want to logout{" "} {authStore.currentAccount?.username} ?

)} {uiStore.showConsole && (
)}
); }