From b275a3668b140d9ce4663de646519d2dbd4297e7 Mon Sep 17 00:00:00 2001 From: 苏向夜 Date: Tue, 24 Feb 2026 22:41:36 +0800 Subject: refactor: rewrite login and settings pages --- packages/ui-new/src/components/bottom-bar.tsx | 157 +++++++------------------- 1 file changed, 39 insertions(+), 118 deletions(-) (limited to 'packages/ui-new/src/components/bottom-bar.tsx') diff --git a/packages/ui-new/src/components/bottom-bar.tsx b/packages/ui-new/src/components/bottom-bar.tsx index a0c2c00..2653880 100644 --- a/packages/ui-new/src/components/bottom-bar.tsx +++ b/packages/ui-new/src/components/bottom-bar.tsx @@ -1,11 +1,13 @@ import { invoke } from "@tauri-apps/api/core"; import { listen, type UnlistenFn } from "@tauri-apps/api/event"; -import { Check, ChevronDown, Play, Terminal, User } from "lucide-react"; +import { Check, ChevronDown, Play, User } from "lucide-react"; import { useCallback, useEffect, useRef, useState } from "react"; -import { useAuthStore } from "@/stores/auth-store"; +import { cn } from "@/lib/utils"; +import { useAuthStore } from "@/models/auth"; import { useGameStore } from "@/stores/game-store"; import { useInstancesStore } from "@/stores/instances-store"; -import { useUIStore } from "@/stores/ui-store"; +import { LoginModal } from "./login-modal"; +import { Button } from "./ui/button"; interface InstalledVersion { id: string; @@ -16,15 +18,13 @@ export function BottomBar() { const authStore = useAuthStore(); const gameStore = useGameStore(); const instancesStore = useInstancesStore(); - const uiStore = useUIStore(); const [isVersionDropdownOpen, setIsVersionDropdownOpen] = useState(false); const [installedVersions, setInstalledVersions] = useState< InstalledVersion[] >([]); const [isLoadingVersions, setIsLoadingVersions] = useState(true); - - const dropdownRef = useRef(null); + const [showLoginModal, setShowLoginModal] = useState(false); const loadInstalledVersions = useCallback(async () => { if (!instancesStore.activeInstanceId) { @@ -61,17 +61,6 @@ export function BottomBar() { useEffect(() => { loadInstalledVersions(); - const handleClickOutside = (event: MouseEvent) => { - if ( - dropdownRef.current && - !dropdownRef.current.contains(event.target as Node) - ) { - setIsVersionDropdownOpen(false); - } - }; - - document.addEventListener("mousedown", handleClickOutside); - // Listen for backend events that should refresh installed versions. let unlistenDownload: UnlistenFn | null = null; let unlistenVersionDeleted: UnlistenFn | null = null; @@ -98,7 +87,6 @@ export function BottomBar() { })(); return () => { - document.removeEventListener("mousedown", handleClickOutside); try { if (unlistenDownload) unlistenDownload(); } catch { @@ -120,12 +108,12 @@ export function BottomBar() { }; const handleStartGame = async () => { - await gameStore.startGame( - authStore.currentAccount, - authStore.openLoginModal, - instancesStore.activeInstanceId, - uiStore.setView, - ); + // await gameStore.startGame( + // authStore.currentAccount, + // authStore.openLoginModal, + // instancesStore.activeInstanceId, + // uiStore.setView, + // ); }; const getVersionTypeColor = (type: string) => { @@ -155,8 +143,7 @@ export function BottomBar() { return (
-
- {/* Left: Instance Info */} +
@@ -166,104 +153,38 @@ export function BottomBar() { {instancesStore.activeInstance?.name || "No instance selected"}
- - {/* Version Selector */} -
- - - {/* Dropdown */} - {isVersionDropdownOpen && ( -
-
- {versionOptions.map((option) => ( - - ))} -
-
- )} -
- {/* Right: Action Buttons */}
- {/* Console Toggle */} - - - {/* User Login/Info */} - - - {/* Start Game */} - + {authStore.account ? ( + + ) : ( + + )}
+ + setShowLoginModal(false)} + />
); } -- cgit v1.2.3-70-g09d2