-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #417 from ACaiCat/master
更新: apm u支持排除插件,支持自动更新插件,apm l优化显示 & 修复: 插件更新回旧版本,更新插件后不重启仍提示更新
- Loading branch information
Showing
5 changed files
with
152 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace AutoPluginManager; | ||
|
||
public class Config | ||
{ | ||
public const string Path = "tshock/AutoPluginManager.json"; | ||
|
||
public static Config PluginConfig = new(); | ||
|
||
public void Write() | ||
{ | ||
using FileStream fileStream = new(Path, FileMode.Create, FileAccess.Write, FileShare.Write); | ||
Write(fileStream); | ||
} | ||
|
||
private void Write(Stream stream) | ||
{ | ||
string value = JsonConvert.SerializeObject(this, Formatting.Indented); | ||
using (StreamWriter streamWriter = new(stream)) | ||
{ | ||
streamWriter.Write(value); | ||
} | ||
} | ||
|
||
public static void Read() | ||
{ | ||
Config? result; | ||
if (!File.Exists(Path)) | ||
{ | ||
result = new Config(); | ||
result.Write(); | ||
} | ||
else | ||
{ | ||
using FileStream fileStream = new(Path, FileMode.Open, FileAccess.Read, FileShare.Read); | ||
result = Read(fileStream); | ||
} | ||
PluginConfig = result!; | ||
} | ||
|
||
private static Config? Read(Stream stream) | ||
{ | ||
Config? result; | ||
using StreamReader streamReader = new(stream); | ||
result = JsonConvert.DeserializeObject<Config>(streamReader.ReadToEnd()); | ||
return result; | ||
} | ||
[JsonProperty("允许自动更新插件")] public bool AutoUpdate = false; | ||
[JsonProperty("插件排除列表")] public List<string> UpdateBlackList = new(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters