Skip to content

Commit 027252e

Browse files
committed
Move ShowInTaskbar and RunningCoreType to AppManager
1 parent 5478c90 commit 027252e

15 files changed

Lines changed: 35 additions & 34 deletions

File tree

v2rayN/ServiceLib/Handler/ConfigHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ public static async Task<RetResult> AddGroupServer4Multiple(Config config, List<
12731273
}
12741274
else if (node.ConfigType == EConfigType.Custom && node.PreSocksPort > 0)
12751275
{
1276-
var preCoreType = config.RunningCoreType = config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray;
1276+
var preCoreType = AppManager.Instance.RunningCoreType = config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray;
12771277
itemSocks = new ProfileItem()
12781278
{
12791279
CoreType = preCoreType,

v2rayN/ServiceLib/Manager/AppManager.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ public int StatePort2
3131

3232
public string LinuxSudoPwd { get; set; }
3333

34+
public bool ShowInTaskbar { get; set; }
35+
36+
public ECoreType RunningCoreType { get; set; }
37+
38+
public bool IsRunningCore(ECoreType type)
39+
{
40+
switch (type)
41+
{
42+
case ECoreType.Xray when RunningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5:
43+
case ECoreType.sing_box when RunningCoreType is ECoreType.sing_box or ECoreType.mihomo:
44+
return true;
45+
46+
default:
47+
return false;
48+
}
49+
}
50+
3451
#endregion Property
3552

3653
#region App

v2rayN/ServiceLib/Manager/CoreManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public async Task CoreStop()
167167

168168
private async Task CoreStart(ProfileItem node)
169169
{
170-
var coreType = _config.RunningCoreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
170+
var coreType = AppManager.Instance.RunningCoreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
171171
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(coreType);
172172

173173
var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog;

v2rayN/ServiceLib/Models/Config.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,6 @@ public class Config
88
public string IndexId { get; set; }
99
public string SubIndexId { get; set; }
1010

11-
public ECoreType RunningCoreType { get; set; }
12-
13-
public bool IsRunningCore(ECoreType type)
14-
{
15-
switch (type)
16-
{
17-
case ECoreType.Xray when RunningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5:
18-
case ECoreType.sing_box when RunningCoreType is ECoreType.sing_box or ECoreType.mihomo:
19-
return true;
20-
21-
default:
22-
return false;
23-
}
24-
}
25-
2611
#endregion property
2712

2813
#region other entities

v2rayN/ServiceLib/Models/ConfigItems.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ public class UIItem
9999
public bool EnableDragDropSort { get; set; }
100100
public bool DoubleClick2Activate { get; set; }
101101
public bool AutoHideStartup { get; set; }
102-
public bool Hide2TrayWhenClose { get; set; }
103-
public bool ShowInTaskbar { get; set; }
102+
public bool Hide2TrayWhenClose { get; set; }
104103
public bool MacOSShowInDock { get; set; }
105104
public List<ColumnItem> MainColumnItem { get; set; }
106105
public List<WindowSizeItem> WindowSizeItem { get; set; }

v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxInboundService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ private async Task<int> GenInbounds(SingboxConfig singboxConfig)
1010
singboxConfig.inbounds = [];
1111

1212
if (!_config.TunModeItem.EnableTun
13-
|| (_config.TunModeItem.EnableTun && _config.TunModeItem.EnableExInbound && _config.RunningCoreType == ECoreType.sing_box))
13+
|| (_config.TunModeItem.EnableTun && _config.TunModeItem.EnableExInbound && AppManager.Instance.RunningCoreType == ECoreType.sing_box))
1414
{
1515
var inbound = new Inbound4Sbox()
1616
{

v2rayN/ServiceLib/Services/Statistics/StatisticsSingboxService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private async Task Run()
6161
await Task.Delay(1000);
6262
try
6363
{
64-
if (!_config.IsRunningCore(ECoreType.sing_box))
64+
if (!AppManager.Instance.IsRunningCore(ECoreType.sing_box))
6565
{
6666
continue;
6767
}

v2rayN/ServiceLib/Services/Statistics/StatisticsXrayService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private async Task Run()
3030
await Task.Delay(1000);
3131
try
3232
{
33-
if (_config.RunningCoreType != ECoreType.Xray)
33+
if (AppManager.Instance.RunningCoreType != ECoreType.Xray)
3434
{
3535
continue;
3636
}

v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public async Task DelayTestTask()
128128
{
129129
await Task.Delay(1000 * 5);
130130
numOfExecuted++;
131-
if (!(AutoRefresh && _config.UiItem.ShowInTaskbar && _config.IsRunningCore(ECoreType.sing_box)))
131+
if (!(AutoRefresh && AppManager.Instance.ShowInTaskbar && AppManager.Instance.IsRunningCore(ECoreType.sing_box)))
132132
{
133133
continue;
134134
}

v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ public async Task DelayTestTask()
437437
{
438438
await Task.Delay(1000 * 60);
439439
numOfExecuted++;
440-
if (!(AutoRefresh && _config.UiItem.ShowInTaskbar && _config.IsRunningCore(ECoreType.sing_box)))
440+
if (!(AutoRefresh && AppManager.Instance.ShowInTaskbar && AppManager.Instance.IsRunningCore(ECoreType.sing_box)))
441441
{
442442
continue;
443443
}

0 commit comments

Comments
 (0)