From e606f5da1d512ec18e6ae1188be672c0cefe020a Mon Sep 17 00:00:00 2001 From: NtskwK Date: Thu, 26 Mar 2026 09:56:05 +0800 Subject: style: format code and update biome schema --- packages/ui/src/components/bottom-bar.tsx | 14 ++++++++++---- packages/ui/src/components/instance-editor-modal.tsx | 8 ++++---- packages/ui/src/components/ui/avatar.tsx | 4 ++-- packages/ui/src/components/ui/card.tsx | 8 ++++---- packages/ui/src/components/ui/dropdown-menu.tsx | 10 +++++----- packages/ui/src/components/ui/field.tsx | 12 ++++-------- packages/ui/src/components/ui/radio-group.tsx | 14 +++++++------- packages/ui/src/components/ui/tabs.tsx | 2 +- packages/ui/src/models/auth.ts | 5 ++++- packages/ui/src/models/instance.ts | 5 ++++- packages/ui/src/pages/index.tsx | 7 ++++++- packages/ui/src/pages/instances-view.tsx | 16 ++++++++++++---- packages/ui/src/stores/auth-store.ts | 6 +++--- packages/ui/src/stores/game-store.ts | 4 +++- 14 files changed, 69 insertions(+), 46 deletions(-) (limited to 'packages/ui') diff --git a/packages/ui/src/components/bottom-bar.tsx b/packages/ui/src/components/bottom-bar.tsx index 8f70985..2746e00 100644 --- a/packages/ui/src/components/bottom-bar.tsx +++ b/packages/ui/src/components/bottom-bar.tsx @@ -21,13 +21,17 @@ export function BottomBar() { const account = useAuthStore((state) => state.account); const instances = useInstanceStore((state) => state.instances); const activeInstance = useInstanceStore((state) => state.activeInstance); - const setActiveInstance = useInstanceStore((state) => state.setActiveInstance); + const setActiveInstance = useInstanceStore( + (state) => state.setActiveInstance, + ); const selectedVersion = useGameStore((state) => state.selectedVersion); const setSelectedVersion = useGameStore((state) => state.setSelectedVersion); const startGame = useGameStore((state) => state.startGame); const stopGame = useGameStore((state) => state.stopGame); const runningInstanceId = useGameStore((state) => state.runningInstanceId); - const launchingInstanceId = useGameStore((state) => state.launchingInstanceId); + const launchingInstanceId = useGameStore( + (state) => state.launchingInstanceId, + ); const stoppingInstanceId = useGameStore((state) => state.stoppingInstanceId); const [showLoginModal, setShowLoginModal] = useState(false); @@ -39,7 +43,7 @@ export function BottomBar() { } setSelectedVersion(nextVersion); - }, [activeInstance?.id, activeInstance?.versionId, selectedVersion, setSelectedVersion]); + }, [activeInstance?.versionId, selectedVersion, setSelectedVersion]); const handleInstanceChange = useCallback( async (instanceId: string) => { @@ -47,7 +51,9 @@ export function BottomBar() { return; } - const nextInstance = instances.find((instance) => instance.id === instanceId); + const nextInstance = instances.find( + (instance) => instance.id === instanceId, + ); if (!nextInstance) { return; } diff --git a/packages/ui/src/components/instance-editor-modal.tsx b/packages/ui/src/components/instance-editor-modal.tsx index d964185..ad0c809 100644 --- a/packages/ui/src/components/instance-editor-modal.tsx +++ b/packages/ui/src/components/instance-editor-modal.tsx @@ -101,7 +101,7 @@ export function InstanceEditorModal({ open, instance, onOpenChange }: Props) { setFileList(files || []); } catch (err) { console.error("Failed to load files:", err); - toast.error("Failed to load files: " + String(err)); + toast.error(`Failed to load files: ${String(err)}`); setFileList([]); } finally { setLoadingFiles(false); @@ -141,7 +141,7 @@ export function InstanceEditorModal({ open, instance, onOpenChange }: Props) { toast.success("Deleted"); } catch (err) { console.error("Failed to delete file:", err); - toast.error("Failed to delete file: " + String(err)); + toast.error(`Failed to delete file: ${String(err)}`); } finally { setDeletingPath(null); } @@ -152,7 +152,7 @@ export function InstanceEditorModal({ open, instance, onOpenChange }: Props) { await invoke("open_file_explorer", { path: filePath }); } catch (err) { console.error("Failed to open in explorer:", err); - toast.error("Failed to open file explorer: " + String(err)); + toast.error(`Failed to open file explorer: ${String(err)}`); } } @@ -184,7 +184,7 @@ export function InstanceEditorModal({ open, instance, onOpenChange }: Props) { } catch (err) { console.error("Failed to save instance:", err); setErrorMessage(String(err)); - toast.error("Failed to save instance: " + String(err)); + toast.error(`Failed to save instance: ${String(err)}`); } finally { setSaving(false); } diff --git a/packages/ui/src/components/ui/avatar.tsx b/packages/ui/src/components/ui/avatar.tsx index 9fd72a2..961d0bd 100644 --- a/packages/ui/src/components/ui/avatar.tsx +++ b/packages/ui/src/components/ui/avatar.tsx @@ -99,9 +99,9 @@ function AvatarGroupCount({ export { Avatar, - AvatarImage, + AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, - AvatarBadge, + AvatarImage, }; diff --git a/packages/ui/src/components/ui/card.tsx b/packages/ui/src/components/ui/card.tsx index b7084a0..3caf2b5 100644 --- a/packages/ui/src/components/ui/card.tsx +++ b/packages/ui/src/components/ui/card.tsx @@ -94,10 +94,10 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) { export { Card, - CardHeader, - CardFooter, - CardTitle, CardAction, - CardDescription, CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, }; diff --git a/packages/ui/src/components/ui/dropdown-menu.tsx b/packages/ui/src/components/ui/dropdown-menu.tsx index ee97374..33dce1b 100644 --- a/packages/ui/src/components/ui/dropdown-menu.tsx +++ b/packages/ui/src/components/ui/dropdown-menu.tsx @@ -252,18 +252,18 @@ function DropdownMenuShortcut({ export { DropdownMenu, - DropdownMenuPortal, - DropdownMenuTrigger, + DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, - DropdownMenuLabel, DropdownMenuItem, - DropdownMenuCheckboxItem, + DropdownMenuLabel, + DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, - DropdownMenuSubTrigger, DropdownMenuSubContent, + DropdownMenuSubTrigger, + DropdownMenuTrigger, }; diff --git a/packages/ui/src/components/ui/field.tsx b/packages/ui/src/components/ui/field.tsx index ab9fb71..84505da 100644 --- a/packages/ui/src/components/ui/field.tsx +++ b/packages/ui/src/components/ui/field.tsx @@ -197,12 +197,8 @@ function FieldError({ return ( ); @@ -226,13 +222,13 @@ function FieldError({ export { Field, - FieldLabel, + FieldContent, FieldDescription, FieldError, FieldGroup, + FieldLabel, FieldLegend, FieldSeparator, FieldSet, - FieldContent, FieldTitle, }; diff --git a/packages/ui/src/components/ui/radio-group.tsx b/packages/ui/src/components/ui/radio-group.tsx index d8b39dd..df831e8 100644 --- a/packages/ui/src/components/ui/radio-group.tsx +++ b/packages/ui/src/components/ui/radio-group.tsx @@ -1,7 +1,7 @@ -import { Radio as RadioPrimitive } from "@base-ui/react/radio" -import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group" +import { Radio as RadioPrimitive } from "@base-ui/react/radio"; +import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) { return ( @@ -10,7 +10,7 @@ function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) { className={cn("grid w-full gap-2", className)} {...props} /> - ) + ); } function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) { @@ -19,7 +19,7 @@ function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) { data-slot="radio-group-item" className={cn( "border-input dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 dark:aria-invalid:border-destructive/50 group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3", - className + className, )} {...props} > @@ -30,7 +30,7 @@ function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) { - ) + ); } -export { RadioGroup, RadioGroupItem } +export { RadioGroup, RadioGroupItem }; diff --git a/packages/ui/src/components/ui/tabs.tsx b/packages/ui/src/components/ui/tabs.tsx index c66893f..8afbb42 100644 --- a/packages/ui/src/components/ui/tabs.tsx +++ b/packages/ui/src/components/ui/tabs.tsx @@ -77,4 +77,4 @@ function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) { ); } -export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }; +export { Tabs, TabsContent, TabsList, TabsTrigger, tabsListVariants }; diff --git a/packages/ui/src/models/auth.ts b/packages/ui/src/models/auth.ts index 9c814d2..d64b67a 100644 --- a/packages/ui/src/models/auth.ts +++ b/packages/ui/src/models/auth.ts @@ -95,7 +95,10 @@ export const useAuthStore = create((set, get) => ({ } catch (error) { const message = getAuthErrorMessage(error); console.error("Failed to start Microsoft login:", error); - set({ loginMode: null, statusMessage: `Failed to start login: ${message}` }); + set({ + loginMode: null, + statusMessage: `Failed to start login: ${message}`, + }); toast.error(`Failed to start Microsoft login: ${message}`); } }, diff --git a/packages/ui/src/models/instance.ts b/packages/ui/src/models/instance.ts index e1eb7c1..2f338b5 100644 --- a/packages/ui/src/models/instance.ts +++ b/packages/ui/src/models/instance.ts @@ -26,7 +26,10 @@ interface InstanceState { setActiveInstance: (instance: Instance) => Promise; duplicate: (id: string, newName: string) => Promise; exportArchive: (id: string, archivePath: string) => Promise; - importArchive: (archivePath: string, newName?: string) => Promise; + importArchive: ( + archivePath: string, + newName?: string, + ) => Promise; repair: () => Promise; get: (id: string) => Promise; } diff --git a/packages/ui/src/pages/index.tsx b/packages/ui/src/pages/index.tsx index 209a1b2..b93bb9b 100644 --- a/packages/ui/src/pages/index.tsx +++ b/packages/ui/src/pages/index.tsx @@ -22,7 +22,12 @@ export function IndexPage() { void initGameLifecycle().catch((error) => { console.error("Failed to initialize game lifecycle:", error); }); - }, [authStore.init, settingsStore.refresh, instanceStore.refresh, initGameLifecycle]); + }, [ + authStore.init, + settingsStore.refresh, + instanceStore.refresh, + initGameLifecycle, + ]); return (
diff --git a/packages/ui/src/pages/instances-view.tsx b/packages/ui/src/pages/instances-view.tsx index 07a2135..7bb3302 100644 --- a/packages/ui/src/pages/instances-view.tsx +++ b/packages/ui/src/pages/instances-view.tsx @@ -35,7 +35,9 @@ export function InstancesView() { const startGame = useGameStore((state) => state.startGame); const stopGame = useGameStore((state) => state.stopGame); const runningInstanceId = useGameStore((state) => state.runningInstanceId); - const launchingInstanceId = useGameStore((state) => state.launchingInstanceId); + const launchingInstanceId = useGameStore( + (state) => state.launchingInstanceId, + ); const stoppingInstanceId = useGameStore((state) => state.stoppingInstanceId); const [isImporting, setIsImporting] = useState(false); const [repairing, setRepairing] = useState(false); @@ -191,7 +193,8 @@ export function InstancesView() { const isRunning = runningInstanceId === instance.id; const isLaunching = launchingInstanceId === instance.id; const isStopping = stoppingInstanceId === instance.id; - const otherInstanceRunning = runningInstanceId !== null && !isRunning; + const otherInstanceRunning = + runningInstanceId !== null && !isRunning; return (
  • undefined, ); }} - disabled={otherInstanceRunning || isLaunching || isStopping} + disabled={ + otherInstanceRunning || isLaunching || isStopping + } > {isLaunching || isStopping ? ( ... diff --git a/packages/ui/src/stores/auth-store.ts b/packages/ui/src/stores/auth-store.ts index bf7e3c5..54f30d3 100644 --- a/packages/ui/src/stores/auth-store.ts +++ b/packages/ui/src/stores/auth-store.ts @@ -123,7 +123,7 @@ export const useAuthStore = create((set, get) => ({ }); } catch (error) { // Keep UI-friendly behavior consistent with prior code - alert("Login failed: " + String(error)); + alert(`Login failed: ${String(error)}`); } }, @@ -234,7 +234,7 @@ export const useAuthStore = create((set, get) => ({ if (errStr.includes("authorization_pending")) { // Still waiting — keep polling } else { - set({ msLoginStatus: "Error: " + errStr }); + set({ msLoginStatus: `Error: ${errStr}` }); if ( errStr.includes("expired_token") || @@ -247,7 +247,7 @@ export const useAuthStore = create((set, get) => ({ authProgressUnlisten(); set({ authProgressUnlisten: null }); } - alert("Login failed: " + errStr); + alert(`Login failed: ${errStr}`); set({ loginMode: "select" }); } } diff --git a/packages/ui/src/stores/game-store.ts b/packages/ui/src/stores/game-store.ts index 1eaf7e7..7b6e746 100644 --- a/packages/ui/src/stores/game-store.ts +++ b/packages/ui/src/stores/game-store.ts @@ -70,7 +70,9 @@ export const useGameStore = create((set, get) => ({ }); if (wasStopped) { - toast.success(`Stopped Minecraft ${versionId} for instance ${instanceId}`); + toast.success( + `Stopped Minecraft ${versionId} for instance ${instanceId}`, + ); } else { toast.info(`Minecraft ${versionId} exited for instance ${instanceId}`); } -- cgit v1.2.3-70-g09d2