using System.Text.Json; namespace FanControl.ChromeboxEC; /// 插件配置,对应 ectool 命令参数。参见 docs/ectool-commands-zh.md public sealed class PluginConfig { /// ectool 可执行文件路径,默认 Coolstar 安装路径 public string EctoolPath { get; set; } = @"C:\Program Files\crosec\ectool.exe"; /// 读取温度:ectool temps <sensorid>。默认 ["temps", "0"],可用 tempsinfo 查本机传感器 ID public string[] TempArgs { get; set; } = ["temps", "0"]; /// 读取转速:ectool pwmgetfanrpm [index|all]。默认 ["pwmgetfanrpm", "0"] public string[] FanRpmArgs { get; set; } = ["pwmgetfanrpm", "0"]; /// 恢复自动风扇:ectool autofanctrl。禁用控制时调用 public string[] AutoFanCtrlArgs { get; set; } = ["autofanctrl"]; public static PluginConfig Load() { var paths = new[] { Path.Combine(AppContext.BaseDirectory, "FanControl.ChromeboxEC.json"), Path.Combine(Path.GetDirectoryName(typeof(PluginConfig).Assembly.Location) ?? "", "FanControl.ChromeboxEC.json"), Path.Combine(AppContext.BaseDirectory, "Plugins", "FanControl.ChromeboxEC.json"), }; foreach (var configPath in paths) { if (string.IsNullOrEmpty(configPath) || !File.Exists(configPath)) continue; try { var json = File.ReadAllText(configPath); var cfg = JsonSerializer.Deserialize(json); if (cfg != null) return cfg; } catch { /* try next path */ } } return new PluginConfig(); } }