mirror of
https://github.com/2dust/v2rayN.git
synced 2025-12-24 23:59:27 +00:00
Move ShowInTaskbar and RunningCoreType to AppManager
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release Linux / rpm (push) Blocked by required conditions
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release Linux / rpm (push) Blocked by required conditions
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
This commit is contained in:
parent
5478c90180
commit
027252e687
15 changed files with 35 additions and 34 deletions
|
|
@ -1273,7 +1273,7 @@ public static class ConfigHandler
|
||||||
}
|
}
|
||||||
else if (node.ConfigType == EConfigType.Custom && node.PreSocksPort > 0)
|
else if (node.ConfigType == EConfigType.Custom && node.PreSocksPort > 0)
|
||||||
{
|
{
|
||||||
var preCoreType = config.RunningCoreType = config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray;
|
var preCoreType = AppManager.Instance.RunningCoreType = config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray;
|
||||||
itemSocks = new ProfileItem()
|
itemSocks = new ProfileItem()
|
||||||
{
|
{
|
||||||
CoreType = preCoreType,
|
CoreType = preCoreType,
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,23 @@ public sealed class AppManager
|
||||||
|
|
||||||
public string LinuxSudoPwd { get; set; }
|
public string LinuxSudoPwd { get; set; }
|
||||||
|
|
||||||
|
public bool ShowInTaskbar { get; set; }
|
||||||
|
|
||||||
|
public ECoreType RunningCoreType { get; set; }
|
||||||
|
|
||||||
|
public bool IsRunningCore(ECoreType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case ECoreType.Xray when RunningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5:
|
||||||
|
case ECoreType.sing_box when RunningCoreType is ECoreType.sing_box or ECoreType.mihomo:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Property
|
#endregion Property
|
||||||
|
|
||||||
#region App
|
#region App
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ public class CoreManager
|
||||||
|
|
||||||
private async Task CoreStart(ProfileItem node)
|
private async Task CoreStart(ProfileItem node)
|
||||||
{
|
{
|
||||||
var coreType = _config.RunningCoreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
var coreType = AppManager.Instance.RunningCoreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
||||||
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(coreType);
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(coreType);
|
||||||
|
|
||||||
var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog;
|
var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog;
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,6 @@ public class Config
|
||||||
public string IndexId { get; set; }
|
public string IndexId { get; set; }
|
||||||
public string SubIndexId { get; set; }
|
public string SubIndexId { get; set; }
|
||||||
|
|
||||||
public ECoreType RunningCoreType { get; set; }
|
|
||||||
|
|
||||||
public bool IsRunningCore(ECoreType type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ECoreType.Xray when RunningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5:
|
|
||||||
case ECoreType.sing_box when RunningCoreType is ECoreType.sing_box or ECoreType.mihomo:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion property
|
#endregion property
|
||||||
|
|
||||||
#region other entities
|
#region other entities
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,7 @@ public class UIItem
|
||||||
public bool EnableDragDropSort { get; set; }
|
public bool EnableDragDropSort { get; set; }
|
||||||
public bool DoubleClick2Activate { get; set; }
|
public bool DoubleClick2Activate { get; set; }
|
||||||
public bool AutoHideStartup { get; set; }
|
public bool AutoHideStartup { get; set; }
|
||||||
public bool Hide2TrayWhenClose { get; set; }
|
public bool Hide2TrayWhenClose { get; set; }
|
||||||
public bool ShowInTaskbar { get; set; }
|
|
||||||
public bool MacOSShowInDock { get; set; }
|
public bool MacOSShowInDock { get; set; }
|
||||||
public List<ColumnItem> MainColumnItem { get; set; }
|
public List<ColumnItem> MainColumnItem { get; set; }
|
||||||
public List<WindowSizeItem> WindowSizeItem { get; set; }
|
public List<WindowSizeItem> WindowSizeItem { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ public partial class CoreConfigSingboxService
|
||||||
singboxConfig.inbounds = [];
|
singboxConfig.inbounds = [];
|
||||||
|
|
||||||
if (!_config.TunModeItem.EnableTun
|
if (!_config.TunModeItem.EnableTun
|
||||||
|| (_config.TunModeItem.EnableTun && _config.TunModeItem.EnableExInbound && _config.RunningCoreType == ECoreType.sing_box))
|
|| (_config.TunModeItem.EnableTun && _config.TunModeItem.EnableExInbound && AppManager.Instance.RunningCoreType == ECoreType.sing_box))
|
||||||
{
|
{
|
||||||
var inbound = new Inbound4Sbox()
|
var inbound = new Inbound4Sbox()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class StatisticsSingboxService
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_config.IsRunningCore(ECoreType.sing_box))
|
if (!AppManager.Instance.IsRunningCore(ECoreType.sing_box))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class StatisticsXrayService
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_config.RunningCoreType != ECoreType.Xray)
|
if (AppManager.Instance.RunningCoreType != ECoreType.Xray)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ public class ClashConnectionsViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
await Task.Delay(1000 * 5);
|
await Task.Delay(1000 * 5);
|
||||||
numOfExecuted++;
|
numOfExecuted++;
|
||||||
if (!(AutoRefresh && _config.UiItem.ShowInTaskbar && _config.IsRunningCore(ECoreType.sing_box)))
|
if (!(AutoRefresh && AppManager.Instance.ShowInTaskbar && AppManager.Instance.IsRunningCore(ECoreType.sing_box)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -437,7 +437,7 @@ public class ClashProxiesViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
await Task.Delay(1000 * 60);
|
await Task.Delay(1000 * 60);
|
||||||
numOfExecuted++;
|
numOfExecuted++;
|
||||||
if (!(AutoRefresh && _config.UiItem.ShowInTaskbar && _config.IsRunningCore(ECoreType.sing_box)))
|
if (!(AutoRefresh && AppManager.Instance.ShowInTaskbar && AppManager.Instance.IsRunningCore(ECoreType.sing_box)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task Init()
|
private async Task Init()
|
||||||
{
|
{
|
||||||
_config.UiItem.ShowInTaskbar = true;
|
AppManager.Instance.ShowInTaskbar = true;
|
||||||
|
|
||||||
//await ConfigHandler.InitBuiltinRouting(_config);
|
//await ConfigHandler.InitBuiltinRouting(_config);
|
||||||
await ConfigHandler.InitBuiltinDNS(_config);
|
await ConfigHandler.InitBuiltinDNS(_config);
|
||||||
|
|
@ -306,7 +306,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task UpdateStatisticsHandler(ServerSpeedItem update)
|
private async Task UpdateStatisticsHandler(ServerSpeedItem update)
|
||||||
{
|
{
|
||||||
if (!_config.UiItem.ShowInTaskbar)
|
if (!AppManager.Instance.ShowInTaskbar)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -560,7 +560,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
});
|
});
|
||||||
AppEvents.TestServerRequested.Publish();
|
AppEvents.TestServerRequested.Publish();
|
||||||
|
|
||||||
var showClashUI = _config.IsRunningCore(ECoreType.sing_box);
|
var showClashUI = AppManager.Instance.IsRunningCore(ECoreType.sing_box);
|
||||||
if (showClashUI)
|
if (showClashUI)
|
||||||
{
|
{
|
||||||
AppEvents.ProxiesReloadRequested.Publish();
|
AppEvents.ProxiesReloadRequested.Publish();
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class MsgViewModel : MyReactiveObject
|
||||||
|
|
||||||
EnqueueQueueMsg(msg);
|
EnqueueQueueMsg(msg);
|
||||||
|
|
||||||
if (!_config.UiItem.ShowInTaskbar)
|
if (!AppManager.Instance.ShowInTaskbar)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -549,7 +549,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_config.IsRunningCore(ECoreType.sing_box))
|
if (AppManager.Instance.IsRunningCore(ECoreType.sing_box))
|
||||||
{
|
{
|
||||||
SpeedProxyDisplay = string.Format(ResUI.SpeedDisplayText, EInboundProtocol.mixed, Utils.HumanFy(update.ProxyUp), Utils.HumanFy(update.ProxyDown));
|
SpeedProxyDisplay = string.Format(ResUI.SpeedDisplayText, EInboundProtocol.mixed, Utils.HumanFy(update.ProxyUp), Utils.HumanFy(update.ProxyDown));
|
||||||
SpeedDirectDisplay = string.Empty;
|
SpeedDirectDisplay = string.Empty;
|
||||||
|
|
|
||||||
|
|
@ -409,8 +409,8 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||||
{
|
{
|
||||||
var bl = blShow ??
|
var bl = blShow ??
|
||||||
(Utils.IsLinux()
|
(Utils.IsLinux()
|
||||||
? (!_config.UiItem.ShowInTaskbar ^ (WindowState == WindowState.Minimized))
|
? (!AppManager.Instance.ShowInTaskbar ^ (WindowState == WindowState.Minimized))
|
||||||
: !_config.UiItem.ShowInTaskbar);
|
: !AppManager.Instance.ShowInTaskbar);
|
||||||
if (bl)
|
if (bl)
|
||||||
{
|
{
|
||||||
Show();
|
Show();
|
||||||
|
|
@ -436,7 +436,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
_config.UiItem.ShowInTaskbar = bl;
|
AppManager.Instance.ShowInTaskbar = bl;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnLoaded(object? sender, RoutedEventArgs e)
|
protected override void OnLoaded(object? sender, RoutedEventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -376,7 +376,7 @@ public partial class MainWindow
|
||||||
|
|
||||||
public void ShowHideWindow(bool? blShow)
|
public void ShowHideWindow(bool? blShow)
|
||||||
{
|
{
|
||||||
var bl = blShow ?? !_config.UiItem.ShowInTaskbar;
|
var bl = blShow ?? !AppManager.Instance.ShowInTaskbar;
|
||||||
if (bl)
|
if (bl)
|
||||||
{
|
{
|
||||||
this?.Show();
|
this?.Show();
|
||||||
|
|
@ -391,7 +391,7 @@ public partial class MainWindow
|
||||||
{
|
{
|
||||||
this?.Hide();
|
this?.Hide();
|
||||||
}
|
}
|
||||||
_config.UiItem.ShowInTaskbar = bl;
|
AppManager.Instance.ShowInTaskbar = bl;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnLoaded(object? sender, RoutedEventArgs e)
|
protected override void OnLoaded(object? sender, RoutedEventArgs e)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue