This commit is contained in:
yu committed 2026-10-30 10:52:41 +08:00
commit a25f8c76b6
8 files changed
+442 -61

No files matched your search

+19 -6
View File
@@ -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);
+3 -1
View File
@@ -111,7 +111,9 @@ register("FTP_CreateDir", async (ctx, node, args) => {
const client = await requireClient(node.id);
const dir = requireText(args, ["dirname"], "目录名", node.id);
await client.ensureDir(dir);
client.cd(dir).catch(() => {});
// 创建后进入该目录;必须 await,否则下个节点的命令与本次 cd 并发,
// basic-ftp 会以 "task while another one is still running" 关闭客户端
await client.cd(dir).catch(() => {});
ctx.log("已创建目录:" + dir, "info", node.id);
return { created: true, dir };
});
+7 -1
View File
@@ -87,6 +87,12 @@ register("System_SetInputMethodState", async (ctx, node, args) => {
register("File_OpenFile", async (ctx, node, args) => {
const p = reqText(args, ["path"], "文件夹路径", node.id);
await run("explorer.exe", [p], { windowsHide: true });
try {
await run("explorer.exe", [p], { windowsHide: true });
} catch (error) {
// explorer.exe 打开成功也会返回退出码 1(Windows 已知行为),仅路径不存在时才是真失败
const code = (error as { code?: unknown }).code;
if (code !== 1) throw error;
}
return { opened: true, path: p };
});