From 9430bee86fbf943283eb5a6f63bd750b875ff433 Mon Sep 17 00:00:00 2001 From: 苏向夜 Date: Fri, 23 Jan 2026 20:51:28 +0800 Subject: feat(ui): add new ui project --- packages/ui-new/src/pages/index.tsx | 189 ++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 packages/ui-new/src/pages/index.tsx (limited to 'packages/ui-new/src/pages/index.tsx') diff --git a/packages/ui-new/src/pages/index.tsx b/packages/ui-new/src/pages/index.tsx new file mode 100644 index 0000000..180cf0c --- /dev/null +++ b/packages/ui-new/src/pages/index.tsx @@ -0,0 +1,189 @@ +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 && ( +
+
+ +
+
+ )} +
+ ); +} -- cgit v1.2.3-70-g09d2