From 97fe5046f68b5e4ee5f750945bcc39a27f5eb37b Mon Sep 17 00:00:00 2001
From: 苏向夜 <fu050409@163.com>
Date: Sun, 29 Mar 2026 00:54:21 +0800
Subject: chore(ui): refactor effect instance check

---
 packages/ui/src/components/instance-editor-modal.tsx | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

(limited to 'packages/ui/src/components/instance-editor-modal.tsx')

diff --git a/packages/ui/src/components/instance-editor-modal.tsx b/packages/ui/src/components/instance-editor-modal.tsx
index d964185..2a2bd7d 100644
--- a/packages/ui/src/components/instance-editor-modal.tsx
+++ b/packages/ui/src/components/instance-editor-modal.tsx
@@ -1,8 +1,8 @@
-import { invoke } from "@tauri-apps/api/core";
+
+import { toNumber } from "es-toolkit/compat";
 import { Folder, Loader2, Save, Trash2, X } from "lucide-react";
 import { useCallback, useEffect, useState } from "react";
 import { toast } from "sonner";
-
 import { Button } from "@/components/ui/button";
 import {
   Dialog,
@@ -14,12 +14,11 @@ import {
 } from "@/components/ui/dialog";
 import { Input } from "@/components/ui/input";
 import { Textarea } from "@/components/ui/textarea";
-
-import { toNumber } from "@/lib/tsrs-utils";
 import { useInstanceStore } from "@/models/instance";
 import { useSettingsStore } from "@/models/settings";
 import type { FileInfo } from "../types/bindings/core";
 import type { Instance } from "../types/bindings/instance";
+import { deleteInstanceFile, listInstanceDirectory, openFileExplorer } from "@/client";
 
 type Props = {
   open: boolean;
@@ -94,11 +93,8 @@ export function InstanceEditorModal({ open, instance, onOpenChange }: Props) {
       if (!instance) return;
       setLoadingFiles(true);
       try {
-        const files = await invoke<FileInfo[]>("list_instance_directory", {
-          instanceId: instance.id,
-          folder,
-        });
-        setFileList(files || []);
+        const files = await listInstanceDirectory(instance.id, folder);
+        setFileList(files);
       } catch (err) {
         console.error("Failed to load files:", err);
         toast.error("Failed to load files: " + String(err));
@@ -135,7 +131,7 @@ export function InstanceEditorModal({ open, instance, onOpenChange }: Props) {
     }
     setDeletingPath(filePath);
     try {
-      await invoke("delete_instance_file", { path: filePath });
+      await deleteInstanceFile(filePath);
       // refresh the currently selected folder
       await loadFileList(selectedFileFolder);
       toast.success("Deleted");
@@ -149,7 +145,7 @@ export function InstanceEditorModal({ open, instance, onOpenChange }: Props) {
 
   async function openInExplorer(filePath: string) {
     try {
-      await invoke("open_file_explorer", { path: filePath });
+      await openFileExplorer(filePath);
     } catch (err) {
       console.error("Failed to open in explorer:", err);
       toast.error("Failed to open file explorer: " + String(err));
-- 
cgit v1.2.3-70-g09d2

