From 9e40b5b7bea60e6802a4b448ef315b14fba4de7f Mon Sep 17 00:00:00 2001 From: 苏向夜 Date: Mon, 2 Mar 2026 10:26:21 +0800 Subject: feat(ui): java config --- packages/ui/src/models/java.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/ui/src/models/java.ts (limited to 'packages/ui/src/models/java.ts') diff --git a/packages/ui/src/models/java.ts b/packages/ui/src/models/java.ts new file mode 100644 index 0000000..3e5d2d0 --- /dev/null +++ b/packages/ui/src/models/java.ts @@ -0,0 +1,25 @@ +import { create } from "zustand/react"; +import { detectJava, refreshJavaCatalog } from "@/client"; +import type { JavaCatalog, JavaInstallation } from "@/types"; + +export interface JavaState { + catalog: JavaCatalog | null; + installations: JavaInstallation[] | null; + + refresh: () => Promise; + refreshInstallations: () => Promise; +} + +export const useJavaStore = create((set) => ({ + catalog: null, + installations: null, + + refresh: async () => { + const catalog = await refreshJavaCatalog(); + set({ catalog }); + }, + refreshInstallations: async () => { + const installations = await detectJava(); + set({ installations }); + }, +})); -- cgit v1.2.3-70-g09d2