mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Improve code quality
This commit is contained in:
parent
ba1ada7bf1
commit
b2edea4201
2 changed files with 24 additions and 14 deletions
|
|
@ -26,6 +26,7 @@ using Flow.Launcher.ViewModel;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.VisualStudio.Threading;
|
using Microsoft.VisualStudio.Threading;
|
||||||
|
using Squirrel;
|
||||||
|
|
||||||
namespace Flow.Launcher
|
namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
|
|
@ -334,9 +335,27 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
#region Restart
|
#region Restart
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Restart the application without changing the user privileges.
|
||||||
|
/// </summary>
|
||||||
|
public static void RestartApp(bool forceAdmin = false)
|
||||||
|
{
|
||||||
|
if (Win32Helper.IsAdministrator() || forceAdmin)
|
||||||
|
{
|
||||||
|
RestartAppAsAdministrator();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Restart requires Squirrel's Update.exe to be present in the parent folder,
|
||||||
|
// it is only published from the project's release pipeline. When debugging without it,
|
||||||
|
// the project may not restart or just terminates. This is expected.
|
||||||
|
UpdateManager.RestartApp(Constant.ApplicationFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Since Squirrel does not provide a way to restart the app as administrator,
|
// Since Squirrel does not provide a way to restart the app as administrator,
|
||||||
// we need to do it manually by starting the update.exe with the runas verb
|
// we need to do it manually by starting the update.exe with the runas verb
|
||||||
public static void RestartAppAsAdministrator()
|
private static void RestartAppAsAdministrator()
|
||||||
{
|
{
|
||||||
var startInfo = new ProcessStartInfo
|
var startInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ using Flow.Launcher.Plugin.SharedModels;
|
||||||
using Flow.Launcher.Plugin.SharedCommands;
|
using Flow.Launcher.Plugin.SharedCommands;
|
||||||
using Flow.Launcher.ViewModel;
|
using Flow.Launcher.ViewModel;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Squirrel;
|
|
||||||
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;
|
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;
|
||||||
|
|
||||||
namespace Flow.Launcher
|
namespace Flow.Launcher
|
||||||
|
|
@ -85,18 +84,10 @@ namespace Flow.Launcher
|
||||||
// Wait for all image caches to be saved before restarting
|
// Wait for all image caches to be saved before restarting
|
||||||
await ImageLoader.WaitSaveAsync();
|
await ImageLoader.WaitSaveAsync();
|
||||||
|
|
||||||
// If app is run as administrator already, we continue to restart app as administrator
|
// Restart requires Squirrel's Update.exe to be present in the parent folder,
|
||||||
if (Win32Helper.IsAdministrator())
|
// it is only published from the project's release pipeline. When debugging without it,
|
||||||
{
|
// the project may not restart or just terminates. This is expected.
|
||||||
App.RestartAppAsAdministrator();
|
App.RestartApp();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Restart requires Squirrel's Update.exe to be present in the parent folder,
|
|
||||||
// it is only published from the project's release pipeline. When debugging without it,
|
|
||||||
// the project may not restart or just terminates. This is expected.
|
|
||||||
UpdateManager.RestartApp(Constant.ApplicationFileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowMainWindow() => _mainVM.Show();
|
public void ShowMainWindow() => _mainVM.Show();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue