优化项目结构,移除第三方包,单文件生成打包

This commit is contained in:
czz_y
2025-01-16 15:35:34 +08:00
parent 3a0fda0e56
commit 64e30b4350
16 changed files with 248 additions and 340 deletions
-75
View File
@@ -1,75 +0,0 @@
using Newtonsoft.Json.Linq;
using System.IO;
namespace AntdUIDemo.Utils
{
public class AppSetting
{
private static readonly string configFilePath = "appsettings.json";
public static JObject GetAppSettings(string configFilePath = "appsettings.json")
{
if (!File.Exists(configFilePath))
{
// 如果文件不存在,创建默认的配置文件
CreateDefaultConfigFile(configFilePath);
}
var json = File.ReadAllText(configFilePath);
var jsonObj = JObject.Parse(json);
return (JObject)jsonObj["AppSettings"];
}
public static void UpdateAppSetting(string key, string value)
{
// 检查配置文件是否存在
if (!File.Exists(configFilePath))
{
// 如果文件不存在,创建默认的配置文件
CreateDefaultConfigFile(configFilePath);
}
// 读取并解析现有的 appsettings.json 文件
var json = File.ReadAllText(configFilePath);
var jsonObj = JObject.Parse(json);
// 获取或创建 "AppSettings" 节点
var appSettings = jsonObj["AppSettings"] as JObject;
if (appSettings == null)
{
appSettings = new JObject();
jsonObj["AppSettings"] = appSettings;
}
// 检查 key 是否存在,存在则更新,不存在则添加
if (appSettings[key] != null)
{
appSettings[key] = value;
}
else
{
appSettings.Add(key, value);
}
// 保存更改回 appsettings.json 文件
File.WriteAllText(configFilePath, jsonObj.ToString());
}
private static void CreateDefaultConfigFile(string configFilePath)
{
// 创建一个新的 appsettings.json 文件,并写入默认的 AppSettings
var configJson = @"{
""AppSettings"": {
""ColorMode"": ""Auto"",
""Animation"": ""True"",
""ShadowEnabled"": ""True"",
""ScrollBarHide"": ""False"",
""ShowInWindow"": ""True"",
""ShowOffset"": ""0""
}
}";
File.WriteAllText(configFilePath, configJson);
}
}
}
-9
View File
@@ -1,9 +0,0 @@
using NLog;
namespace AntdUIDemo.Utils
{
public class LoggerHelper
{
public static readonly Logger Logger = LogManager.GetCurrentClassLogger();
}
}
+9 -9
View File
@@ -27,22 +27,22 @@ namespace AntdUIDemo.Utils
/// <summary>
/// 设置明暗颜色
/// </summary>
/// <param name="window"></param>
/// <param name="isLight"></param>
/// <param name="window">父窗口</param>
/// <param name="isLight">是否亮色</param>
public static void SetColorMode(AntdUI.Window window, bool isLight)
{
if (!isLight)
{
AntdUI.Config.IsDark = true;// 设置为深色模式
window.BackColor = Color.FromArgb(31, 31, 31);
window.ForeColor = Color.White;
}
else
if (isLight)
{
AntdUI.Config.IsLight = true;
window.BackColor = Color.White;
window.ForeColor = Color.Black;
}
else
{
AntdUI.Config.IsDark = true;// 设置为深色模式
window.BackColor = Color.FromArgb(31, 31, 31);
window.ForeColor = Color.White;
}
}
}
}