From 19eb53b5d8148c6c4a3538f2cc1093ff8f4a46c4 Mon Sep 17 00:00:00 2001 From: yu <191972707@qq.com> Date: Fri, 30 Oct 2026 10:14:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=BB=84=205=20=E5=A4=84=E7=9B=AE=E5=BD=95=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=B8=8E=E5=AE=9E=E7=8E=B0=E9=94=AE=E5=90=8D=E8=84=B1=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - File_CreateFile: 目录字段 folder_path/name,实现读 path → 必报文件路径为空 - File_GetFileInfo / File_WaitFile: 目录字段 file_path,实现读 path → 读不到 - File_CompressFile: 目录字段 file_path,实现读 pathSrc → 压缩源找不到 - File_Move: 目录字段 file_path/target_path/name,实现与 File_File_Move 共用 pathSrc/pathDest → 读不到;补齐别名兼容 --- src/main/capabilities/files.ts | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/capabilities/files.ts b/src/main/capabilities/files.ts index 6ca2641..31387da 100644 --- a/src/main/capabilities/files.ts +++ b/src/main/capabilities/files.ts @@ -59,7 +59,10 @@ register("File_Write", async (_ctx, node, args) => { }); register(["File_CreateFile"], async (_ctx, node, args) => { - const filePath = requirePath(pick(args, ["path", "file", "file_path"]), "文件路径", node.id, node.componentId); + // catalog 字段为 folder_path + name(组合成完整路径),兼容旧键 path + const base = pick(args, ["folder_path", "path", "file", "file_path"]); + const name = pick(args, ["name"]); + const filePath = requirePath(name ? path.join(base, name) : base, "文件路径", node.id, node.componentId); await fs.mkdir(path.dirname(filePath), { recursive: true }); await fs.writeFile(filePath, "", { flag: "a" }); return filePath; @@ -80,8 +83,15 @@ register("File_Copy", async (_ctx, node, args) => { }); register(["File_File_Move", "File_Move"], async (_ctx, node, args) => { - const source = requirePath(pick(args, ["pathSrc", "src", "source"]), "源路径", node.id, node.componentId); - const target = requirePath(pick(args, ["pathDest", "dest", "target"]), "目标路径", node.id, node.componentId); + // File_Move 的 catalog 字段为 file_type + file_path/folder_path + target_path(+name),与 File_File_Move 的 pathSrc/pathDest 兼容 + const isFolder = String(args.file_type ?? "file") === "folder"; + const source = requirePath(pick(args, ["pathSrc", isFolder ? "folder_path" : "file_path", "src", "source"]), "源路径", node.id, node.componentId); + let target = pick(args, ["pathDest", "dest"]); + if (!target) { + const destDir = pick(args, ["target_path"]); + const newName = truthy(args.rename) ? pick(args, ["name"]) : ""; + target = requirePath(newName ? path.join(destDir, newName) : destDir, "目的地路径", node.id, node.componentId); + } await fs.mkdir(path.dirname(target), { recursive: true }); try { await fs.rename(source, target); @@ -152,7 +162,8 @@ register(["File_PathSize", "File_PathSizeNew"], async (_ctx, node, args) => { }); register("File_GetFileInfo", async (_ctx, node, args) => { - const target = requirePath(pick(args, ["path", "file"]), "路径", node.id, node.componentId); + // catalog 字段为 file_path,兼容 path/file + const target = requirePath(pick(args, ["file_path", "path", "file"]), "路径", node.id, node.componentId); const stat = await fs.stat(target); return { path: target, @@ -165,7 +176,8 @@ register("File_GetFileInfo", async (_ctx, node, args) => { }); register("File_WaitFile", async (ctx, node, args) => { - const target = requirePath(pick(args, ["path", "file"]), "文件路径", node.id, node.componentId); + // catalog 字段为 file_path,兼容 path/file + const target = requirePath(pick(args, ["file_path", "path", "file"]), "文件路径", node.id, node.componentId); const timeout = Math.max(1, Number(args.time_out ?? args.timeout ?? 30)) * 1000; const started = Date.now(); while (Date.now() - started < timeout) { @@ -185,7 +197,8 @@ register("File_WaitFile", async (ctx, node, args) => { }); register("File_CompressFile", async (_ctx, node, args) => { - const source = requirePath(pick(args, ["pathSrc", "path", "folder_path"]), "源路径", node.id, node.componentId); + // catalog 字段为 file_path(文件模式)/folder_path(文件夹模式)+ out_path,兼容旧键 + const source = requirePath(pick(args, ["file_path", "pathSrc", "path", "folder_path"]), "源路径", node.id, node.componentId); const target = requirePath(pick(args, ["pathDest", "zip_path", "out_path"]), "压缩包路径", node.id, node.componentId); const zip = new AdmZip(); const stat = await fs.stat(source);