https://github.com/2dust/v2rayN/issues/9593
This commit is contained in:
2dust
2026-06-26 10:18:02 +08:00
parent 8d94997ba0
commit 7100b3f0a5
7 changed files with 42 additions and 41 deletions

View File

@@ -43,14 +43,14 @@ public class CheckUpdateViewModel : MyReactiveObject
private void RefreshCheckUpdateItems()
{
var models = CoreInfoManager.Instance.GetCheckUpdateCoreTypes()
.Select(t => GetCheckUpdateModel(t))
.ToList();
models.Add(GetGeoFileCheckUpdateModel());
CheckUpdateModels.Clear();
foreach (var type in CoreInfoManager.Instance.GetCheckUpdateCoreTypes())
{
CheckUpdateModels.Add(GetCheckUpdateModel(type));
}
CheckUpdateModels.Add(GetGeoFileCheckUpdateModel());
CheckUpdateModels.AddRange(models);
}
private CheckUpdateModel GetCheckUpdateModel(ECoreType coreType)

View File

@@ -187,6 +187,7 @@ public class ClashProxiesViewModel : MyReactiveObject
var selectedName = SelectedGroup?.Name;
ProxyGroups.Clear();
var lstProxyGroups = new List<ClashProxyModel>();
var proxyGroups = ClashApiManager.Instance.GetClashProxyGroups();
if (proxyGroups is { Count: > 0 })
{
@@ -200,7 +201,7 @@ public class ClashProxiesViewModel : MyReactiveObject
{
continue;
}
ProxyGroups.Add(new ClashProxyModel()
lstProxyGroups.Add(new ClashProxyModel()
{
Now = item.now,
Name = item.name,
@@ -216,12 +217,12 @@ public class ClashProxiesViewModel : MyReactiveObject
{
continue;
}
var item = ProxyGroups.FirstOrDefault(t => t.Name == kv.Key);
var item = lstProxyGroups.FirstOrDefault(t => t.Name == kv.Key);
if (item != null && item.Name.IsNotEmpty())
{
continue;
}
ProxyGroups.Add(new ClashProxyModel()
lstProxyGroups.Add(new ClashProxyModel()
{
Now = kv.Value.now,
Name = kv.Key,
@@ -229,6 +230,8 @@ public class ClashProxiesViewModel : MyReactiveObject
});
}
ProxyGroups.AddRange(lstProxyGroups);
if (ProxyGroups is { Count: > 0 })
{
if (selectedName != null && ProxyGroups.Any(t => t.Name == selectedName))

View File

@@ -161,19 +161,17 @@ public class ProfilesSelectViewModel : MyReactiveObject
await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null);
}
public async Task RefreshSubscriptions()
private async Task RefreshSubscriptions()
{
var subItems = await AppManager.Instance.SubItems();
subItems.Insert(0, new SubItem { Remarks = ResUI.AllGroupServers });
SubItems.Clear();
SubItems.AddRange(subItems);
SubItems.Add(new SubItem { Remarks = ResUI.AllGroupServers });
foreach (var item in await AppManager.Instance.SubItems())
{
SubItems.Add(item);
}
SelectedSub = (_config.SubIndexId.IsNotEmpty()
? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
: null) ?? SubItems.FirstOrDefault();
? subItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
: null) ?? subItems.FirstOrDefault();
}
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)

View File

@@ -397,17 +397,15 @@ public class ProfilesViewModel : MyReactiveObject
private async Task RefreshSubscriptions()
{
var subItems = await AppManager.Instance.SubItems();
subItems.Insert(0, new SubItem { Remarks = ResUI.AllGroupServers });
SubItems.Clear();
SubItems.AddRange(subItems);
SubItems.Add(new SubItem { Remarks = ResUI.AllGroupServers });
foreach (var item in await AppManager.Instance.SubItems())
{
SubItems.Add(item);
}
SelectedSub = (_config.SubIndexId.IsNotEmpty()
? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
: null) ?? SubItems.FirstOrDefault();
? subItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
: null) ?? subItems.FirstOrDefault();
}
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)

View File

@@ -95,6 +95,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
{
RulesItems.Clear();
var models = new List<RulesItemModel>();
foreach (var item in _rules)
{
var it = new RulesItemModel()
@@ -110,8 +111,9 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
Enabled = item.Enabled,
Remarks = item.Remarks,
};
RulesItems.Add(it);
models.Add(it);
}
RulesItems.AddRange(models);
}
public async Task RuleEditAsync(bool blNew)

View File

@@ -83,6 +83,7 @@ public class RoutingSettingViewModel : MyReactiveObject
public async Task RefreshRoutingItems()
{
RoutingItems.Clear();
var models = new List<RoutingItemModel>();
var routings = await AppManager.Instance.RoutingItems();
foreach (var item in routings)
@@ -98,8 +99,9 @@ public class RoutingSettingViewModel : MyReactiveObject
CustomRulesetPath4Singbox = item.CustomRulesetPath4Singbox,
Sort = item.Sort,
};
RoutingItems.Add(it);
models.Add(it);
}
RoutingItems.AddRange(models);
}
/// <summary>

View File

@@ -234,6 +234,8 @@ public class StatusBarViewModel : MyReactiveObject
await RefreshRoutingsMenu();
await InboundDisplayStatus();
await ChangeSystemProxyAsync(_config.SystemProxyItem.SysProxyType, true);
BlRouting = true;
}
public void InitUpdateView(Func<EViewAction, object?, Task<bool>>? updateView)
@@ -312,18 +314,20 @@ public class StatusBarViewModel : MyReactiveObject
return;
}
var models = new List<ComboItem>();
BlServers = true;
foreach (var it in lstModel)
{
var name = it.GetSummary();
var item = new ComboItem() { ID = it.IndexId, Text = name };
Servers.Add(item);
models.Add(item);
if (_config.IndexId == it.IndexId)
{
SelectedServer = item;
}
}
Servers.AddRange(models);
}
private void ServerSelectedChanged(bool c)
@@ -408,18 +412,12 @@ public class StatusBarViewModel : MyReactiveObject
private async Task RefreshRoutingsMenu()
{
RoutingItems.Clear();
BlRouting = true;
var routings = await AppManager.Instance.RoutingItems();
foreach (var item in routings)
{
RoutingItems.Add(item);
if (item.IsActive)
{
SelectedRouting = item;
}
}
RoutingItems.Clear();
RoutingItems.AddRange(routings);
SelectedRouting = routings.FirstOrDefault(t => t.IsActive == true);
}
private async Task RoutingSelectedChangedAsync(bool c)