diff options
| author | 2026-03-30 16:49:08 +0800 | |
|---|---|---|
| committer | 2026-03-30 16:49:08 +0800 | |
| commit | 878d66f9add4e4026a26ae2fa2a1226b5259154d (patch) | |
| tree | af78680c8d4f357843ab336bdac6e56a622de3c7 /packages/ui/src/models/instance.ts | |
| parent | f8b4bcb3bdc8f11323103081ef8c05b06159d684 (diff) | |
| parent | c4dc0676d794bca2613be282867d369328ebf073 (diff) | |
| download | DropOut-878d66f9add4e4026a26ae2fa2a1226b5259154d.tar.gz DropOut-878d66f9add4e4026a26ae2fa2a1226b5259154d.zip | |
Merge branch 'main' of https://github.com/HydroRoll-Team/DropOut
Diffstat (limited to 'packages/ui/src/models/instance.ts')
| -rw-r--r-- | packages/ui/src/models/instance.ts | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/packages/ui/src/models/instance.ts b/packages/ui/src/models/instance.ts index e1eb7c1..8c108c1 100644 --- a/packages/ui/src/models/instance.ts +++ b/packages/ui/src/models/instance.ts @@ -20,13 +20,16 @@ interface InstanceState { activeInstance: Instance | null; refresh: () => Promise<void>; - create: (name: string) => Promise<Instance | null>; + create: (name: string) => Promise<Instance>; delete: (id: string) => Promise<void>; update: (instance: Instance) => Promise<void>; setActiveInstance: (instance: Instance) => Promise<void>; duplicate: (id: string, newName: string) => Promise<Instance | null>; exportArchive: (id: string, archivePath: string) => Promise<void>; - importArchive: (archivePath: string, newName?: string) => Promise<Instance | null>; + importArchive: ( + archivePath: string, + newName?: string, + ) => Promise<Instance | null>; repair: () => Promise<void>; get: (id: string) => Promise<Instance | null>; } @@ -61,17 +64,11 @@ export const useInstanceStore = create<InstanceState>((set, get) => ({ create: async (name) => { const { refresh } = get(); - try { - const instance = await createInstance(name); - await setActiveInstanceCommand(instance.id); - await refresh(); - toast.success(`Instance "${name}" created successfully`); - return instance; - } catch (e) { - console.error("Failed to create instance:", e); - toast.error(String(e)); - return null; - } + const instance = await createInstance(name); + await setActiveInstanceCommand(instance.id); + await refresh(); + toast.success(`Instance "${name}" created successfully`); + return instance; }, delete: async (id) => { |