mirror of
https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies.git
synced 2026-07-25 06:14:31 +00:00
8ff960189e
- Update: Added "Copy Password" to Mafile context menu (if available) - Update: "Save Password" now pre-fills the current password in the "Login Again" dialog when encryption is enabled - Fix: Prevented overlapping confirmation cycles in AutoConfirmer - Fix: Added a Snackbar notification when a confirmation cycle is skipped due to a too frequent timer interval - Fix: Fixed a rare bug where the previous proxy was used instead of the current one during session refresh - Fix: Corrected "Session Permanently Expired" message showing on unrelated errors (e.g. network issues) - UI-Fix: Fixed visual glitch where proxy input appeared non-empty when switching to a mafile-specific proxy - Cleanup: Refactored and cleaned up codebase, improved styling and formatting via ReSharper
73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.IO;
|
|
using System.Windows.Media;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using NebulaAuth.Core;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace NebulaAuth.Model;
|
|
|
|
public partial class Settings : ObservableObject
|
|
{
|
|
public static Settings Instance { get; }
|
|
|
|
static Settings()
|
|
{
|
|
if (File.Exists("settings.json") == false)
|
|
{
|
|
Instance = new Settings();
|
|
Instance.PropertyChanged += SettingsOnPropertyChanged;
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
var json = File.ReadAllText("settings.json");
|
|
var settings = JsonConvert.DeserializeObject<Settings>(json) ?? throw new NullReferenceException();
|
|
Instance = settings;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SnackbarController.SendSnackbar("Ошибка при загрузке настроек. Настройки были сброшены");
|
|
SnackbarController.SendSnackbar(ex.Message);
|
|
Instance = new Settings();
|
|
}
|
|
|
|
Instance.PropertyChanged += SettingsOnPropertyChanged;
|
|
}
|
|
|
|
private static void SettingsOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
|
{
|
|
Save();
|
|
}
|
|
|
|
public static void Save()
|
|
{
|
|
var json = JsonConvert.SerializeObject(Instance, Formatting.Indented);
|
|
File.WriteAllText("settings.json", json);
|
|
}
|
|
|
|
#region Properties
|
|
|
|
[ObservableProperty] private BackgroundMode _backgroundMode = BackgroundMode.Default;
|
|
[ObservableProperty] private bool _hideToTray;
|
|
[ObservableProperty] private int _timerSeconds = 60;
|
|
[ObservableProperty] private Color? _backgroundColor;
|
|
[ObservableProperty] private Color? _iconColor;
|
|
[ObservableProperty] private bool _isPasswordSet;
|
|
[ObservableProperty] private LocalizationLanguage _language = LocalizationLanguage.English;
|
|
[ObservableProperty] private bool _legacyMode = true;
|
|
[ObservableProperty] private bool _allowAutoUpdate;
|
|
[ObservableProperty] private bool _useAccountNameAsMafileName;
|
|
[ObservableProperty] private bool _ignorePatchTuesdayErrors;
|
|
|
|
#endregion
|
|
}
|
|
|
|
public enum BackgroundMode
|
|
{
|
|
Default,
|
|
Custom,
|
|
Color
|
|
} |