me-web? skeleton: Avalonia 12 app, server, packaging and CI
Build / Desktop, server and tools (push) Successful in 1m7s
Build / Desktop, server and tools (push) Successful in 1m7s
The first screen (online or not, a Check button, every language with a draft notice), the desktop and Android heads, the server's /api/info and /api/ip, a release tool that builds deb, rpm, a Windows exe, macOS zips, a signed APK and the server, and the Gitea workflows that run it. Rules adapted from passolo; AGPL-3.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012CzABvBkbcFqoHdmi8b9WB
This commit is contained in:
commit
7589121846
76 files changed
+3082
No files matched your search
@@ -0,0 +1,43 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace MeWeb.App.Services;
|
||||
|
||||
public class StoredSettings
|
||||
{
|
||||
public string Language { get; set; }
|
||||
}
|
||||
|
||||
public static class AppSettings
|
||||
{
|
||||
static readonly string Folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MeWeb");
|
||||
static readonly string FilePath = Path.Combine(Folder, "settings.json");
|
||||
|
||||
public static StoredSettings Read()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(FilePath)) return new StoredSettings();
|
||||
using var stream = File.OpenRead(FilePath);
|
||||
return JsonSerializer.Deserialize(stream, AppJsonContext.Default.StoredSettings) ?? new StoredSettings();
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or JsonException or UnauthorizedAccessException)
|
||||
{
|
||||
return new StoredSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Write(StoredSettings settings)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Folder);
|
||||
var temporary = FilePath + ".tmp";
|
||||
using (var stream = File.Create(temporary))
|
||||
JsonSerializer.Serialize(stream, settings, AppJsonContext.Default.StoredSettings);
|
||||
File.Move(temporary, FilePath, overwrite: true);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user