mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-30 14:56:19 +00:00
修复:窗口隐藏启动时闪烁的问题
This commit is contained in:
parent
f29e1f8c45
commit
c23c4c27f2
4 changed files with 27 additions and 12 deletions
|
@ -14,6 +14,7 @@
|
||||||
ShareSub,
|
ShareSub,
|
||||||
ShareServer,
|
ShareServer,
|
||||||
ShowHideWindow,
|
ShowHideWindow,
|
||||||
|
ShowInTaskbar,
|
||||||
ScanScreenTask,
|
ScanScreenTask,
|
||||||
ScanImageTask,
|
ScanImageTask,
|
||||||
Shutdown,
|
Shutdown,
|
||||||
|
|
|
@ -218,7 +218,6 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
await Reload();
|
await Reload();
|
||||||
await AutoHideStartup();
|
|
||||||
Locator.Current.GetService<StatusBarViewModel>()?.RefreshRoutingsMenu();
|
Locator.Current.GetService<StatusBarViewModel>()?.RefreshRoutingsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,6 +330,7 @@ namespace ServiceLib.ViewModels
|
||||||
public void ShowHideWindow(bool? blShow)
|
public void ShowHideWindow(bool? blShow)
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.ShowHideWindow, blShow);
|
_updateView?.Invoke(EViewAction.ShowHideWindow, blShow);
|
||||||
|
_updateView?.Invoke(EViewAction.ShowInTaskbar, blShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Actions
|
#endregion Actions
|
||||||
|
@ -586,14 +586,6 @@ namespace ServiceLib.ViewModels
|
||||||
await CoreHandler.Instance.CoreStop();
|
await CoreHandler.Instance.CoreStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AutoHideStartup()
|
|
||||||
{
|
|
||||||
if (_config.UiItem.AutoHideStartup)
|
|
||||||
{
|
|
||||||
ShowHideWindow(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion core job
|
#endregion core job
|
||||||
|
|
||||||
#region Presets
|
#region Presets
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Splat;
|
using Splat;
|
||||||
|
@ -30,10 +31,20 @@ public partial class App : Application
|
||||||
{
|
{
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
AppHandler.Instance.InitComponents();
|
|
||||||
|
|
||||||
desktop.Exit += OnExit;
|
desktop.Exit += OnExit;
|
||||||
desktop.MainWindow = new MainWindow();
|
|
||||||
|
// 先完成组件初始化
|
||||||
|
AppHandler.Instance.InitComponents();
|
||||||
|
var mainWindow = new MainWindow();
|
||||||
|
if (AppHandler.Instance.Config.UiItem.AutoHideStartup)
|
||||||
|
{
|
||||||
|
// 创建主窗口实例但暂不显示
|
||||||
|
mainWindow.ShowInTaskbar = false;
|
||||||
|
mainWindow.WindowState = WindowState.Minimized;
|
||||||
|
mainWindow.IsVisible = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
desktop.MainWindow = mainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
base.OnFrameworkInitializationCompleted();
|
||||||
|
|
|
@ -207,6 +207,11 @@ namespace v2rayN.Desktop.Views
|
||||||
DispatcherPriority.Default);
|
DispatcherPriority.Default);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EViewAction.ShowInTaskbar:
|
||||||
|
Dispatcher.UIThread.Post(() =>
|
||||||
|
showInTaskbar((bool?)obj),
|
||||||
|
DispatcherPriority.Default);
|
||||||
|
break;
|
||||||
case EViewAction.DispatcherStatistics:
|
case EViewAction.DispatcherStatistics:
|
||||||
if (obj is null) return false;
|
if (obj is null) return false;
|
||||||
Dispatcher.UIThread.Post(() =>
|
Dispatcher.UIThread.Post(() =>
|
||||||
|
@ -383,6 +388,12 @@ namespace v2rayN.Desktop.Views
|
||||||
|
|
||||||
#region UI
|
#region UI
|
||||||
|
|
||||||
|
private void showInTaskbar(bool? blShow)
|
||||||
|
{
|
||||||
|
var bl = blShow ?? this.WindowState == WindowState.Normal;
|
||||||
|
this.ShowInTaskbar = bl;
|
||||||
|
}
|
||||||
|
|
||||||
public void ShowHideWindow(bool? blShow)
|
public void ShowHideWindow(bool? blShow)
|
||||||
{
|
{
|
||||||
var bl = blShow ?? !_config.UiItem.ShowInTaskbar;
|
var bl = blShow ?? !_config.UiItem.ShowInTaskbar;
|
||||||
|
|
Loading…
Reference in a new issue