1.更换软件协议为AGPL

2.切换项目名称为Hua.Todo
This commit is contained in:
ShaoHua
2026-04-06 22:06:30 +08:00
parent 40a91e39b6
commit 758f6772c6
147 changed files with 1203 additions and 644 deletions
@@ -0,0 +1,64 @@
using Microsoft.Maui.Storage;
using System.Text.Json;
using Hua.Todo.Maui.Models;
namespace Hua.Todo.Maui.Services
{
public interface IHotKeySettingsService
{
HotKeyConfig GetConfig();
void SaveConfig(HotKeyConfig config);
void ResetToDefault();
}
public class HotKeySettingsService : IHotKeySettingsService
{
private const string SettingsKey = "HotKeyConfig";
private readonly AppSettings _appSettings;
public HotKeySettingsService(AppSettings appSettings)
{
_appSettings = appSettings;
}
public HotKeyConfig GetConfig()
{
var json = Preferences.Get(SettingsKey, string.Empty);
if (string.IsNullOrEmpty(json))
{
return GetDefaultConfig();
}
try
{
return JsonSerializer.Deserialize<HotKeyConfig>(json) ?? GetDefaultConfig();
}
catch
{
return GetDefaultConfig();
}
}
public void SaveConfig(HotKeyConfig config)
{
var json = JsonSerializer.Serialize(config);
Preferences.Set(SettingsKey, json);
}
public void ResetToDefault()
{
var defaultConfig = GetDefaultConfig();
SaveConfig(defaultConfig);
}
private HotKeyConfig GetDefaultConfig()
{
return new HotKeyConfig
{
Modifiers = _appSettings.HotKey.DefaultModifiers,
Key = _appSettings.HotKey.DefaultKey,
IsEnabled = _appSettings.HotKey.DefaultIsEnabled
};
}
}
}