调整C#调用方式,减少编译次数,优化参数传递

This commit is contained in:
fofolee
2025-01-14 10:44:43 +08:00
parent 55be953eef
commit 601df1f1e3
13 changed files with 956 additions and 1060 deletions

View File

@@ -1,16 +1,9 @@
const fs = require("fs");
const path = require("path");
// 读取 monitor.cs 模板
const monitorTemplate = fs.readFileSync(
path.join(__dirname, "..", "..", "csharp", "monitor.cs"),
"utf8"
);
const { runCsharpFeature } = require("../../csharp");
// 监控剪贴板变化
const watchClipboard = async function () {
const args = ["-type", "clipboard", "-once"];
const result = await quickcommand.runCsharp(monitorTemplate, args);
const result = await runCsharpFeature("monitor", args);
if (result && result.startsWith("Error:")) {
throw new Error(result.substring(7));
}
@@ -35,7 +28,7 @@ const watchFileSystem = async function (watchPath, options = {}) {
args.push("-recursive", "false");
}
const result = await quickcommand.runCsharp(monitorTemplate, args);
const result = await runCsharpFeature("monitor", args);
if (result && result.startsWith("Error:")) {
throw new Error(result.substring(7));
}