Implementing IsAdministrator for non-Windows

This commit is contained in:
2dust
2024-10-06 10:23:44 +08:00
parent 75d86cf883
commit 409fe5290e
5 changed files with 42 additions and 45 deletions

View File

@@ -40,7 +40,7 @@ namespace v2rayN.Desktop.Views
menuCheckUpdate.Click += MenuCheckUpdate_Click;
menuBackupAndRestore.Click += MenuBackupAndRestore_Click;
var IsAdministrator = true;//WindowsUtils.IsAdministrator();
var IsAdministrator = Utils.IsAdministrator();
MessageBus.Current.Listen<string>(Global.CommandSendSnackMsg).Subscribe(x => DelegateSnackMsg(x));
ViewModel = new MainWindowViewModel(IsAdministrator, UpdateViewHandler);
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
@@ -119,14 +119,13 @@ namespace v2rayN.Desktop.Views
}
});
this.Title = $"{Utils.GetVersion()} - {(IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";
if (Utils.IsWindows())
{
this.Title = $"{Utils.GetVersion()} - {(IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";
menuGlobalHotkeySetting.IsVisible = false;
}
else
{
this.Title = $"{Utils.GetVersion()}";
menuRebootAsAdmin.IsVisible = false;
menuSettingsSetUWP.IsVisible = false;
menuGlobalHotkeySetting.IsVisible = false;