mirror of https://github.com/2dust/v2rayN
add move to group
parent
781fab5aab
commit
576696b25e
|
@ -1217,6 +1217,22 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static int MoveToGroup(Config config, List<ProfileItem> lstProfile, string subid)
|
||||
{
|
||||
foreach (var it in lstProfile)
|
||||
{
|
||||
var item = LazyConfig.Instance.GetProfileItem(it.indexId);
|
||||
if (item is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
item.subid = subid;
|
||||
SqliteHelper.Instance.Update(item);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UI
|
||||
|
|
|
@ -807,6 +807,15 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Move to group 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuMoveToGroup {
|
||||
get {
|
||||
return ResourceManager.GetString("menuMoveToGroup", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Move to top (T) 的本地化字符串。
|
||||
/// </summary>
|
||||
|
|
|
@ -1060,4 +1060,7 @@
|
|||
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
|
||||
<value>Show console</value>
|
||||
</data>
|
||||
<data name="menuMoveToGroup" xml:space="preserve">
|
||||
<value>Move to group</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1060,4 +1060,7 @@
|
|||
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
|
||||
<value>显示控制台</value>
|
||||
</data>
|
||||
<data name="menuMoveToGroup" xml:space="preserve">
|
||||
<value>移至订阅分组</value>
|
||||
</data>
|
||||
</root>
|
|
@ -62,6 +62,8 @@ namespace v2rayN.ViewModels
|
|||
[Reactive]
|
||||
public SubItem SelectedSub { get; set; }
|
||||
[Reactive]
|
||||
public SubItem SelectedMoveToGroup { get; set; }
|
||||
[Reactive]
|
||||
public RoutingItem SelectedRouting { get; set; }
|
||||
[Reactive]
|
||||
public ComboItem SelectedServer { get; set; }
|
||||
|
@ -86,7 +88,7 @@ namespace v2rayN.ViewModels
|
|||
public ReactiveCommand<Unit, Unit> CopyServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SetDefaultServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> ShareServerCmd { get; }
|
||||
//servers move
|
||||
//servers move
|
||||
public ReactiveCommand<Unit, Unit> MoveTopCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> MoveUpCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> MoveDownCmd { get; }
|
||||
|
@ -205,6 +207,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
SelectedProfile = new();
|
||||
SelectedSub = new();
|
||||
SelectedMoveToGroup = new();
|
||||
SelectedRouting = new();
|
||||
SelectedServer = new();
|
||||
|
||||
|
@ -220,6 +223,10 @@ namespace v2rayN.ViewModels
|
|||
x => x.SelectedSub,
|
||||
y => y != null && !y.remarks.IsNullOrEmpty() && _subId != y.id)
|
||||
.Subscribe(c => SubSelectedChanged(c));
|
||||
this.WhenAnyValue(
|
||||
x => x.SelectedMoveToGroup,
|
||||
y => y != null && !y.remarks.IsNullOrEmpty())
|
||||
.Subscribe(c => MoveToGroup(c));
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.SelectedRouting,
|
||||
|
@ -305,7 +312,7 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
ShareServer();
|
||||
}, canEditRemove);
|
||||
//servers move
|
||||
//servers move
|
||||
MoveTopCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
MoveServer(EMove.Top);
|
||||
|
@ -767,7 +774,7 @@ namespace v2rayN.ViewModels
|
|||
private int GetProfileItems(out List<ProfileItem> lstSelecteds)
|
||||
{
|
||||
lstSelecteds = new List<ProfileItem>();
|
||||
if (SelectedProfiles == null && SelectedProfiles.Count() <= 0)
|
||||
if (SelectedProfiles == null || SelectedProfiles.Count() <= 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -1015,6 +1022,26 @@ namespace v2rayN.ViewModels
|
|||
}
|
||||
|
||||
//move server
|
||||
private void MoveToGroup(bool c)
|
||||
{
|
||||
if (!c)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetProfileItems(out List<ProfileItem> lstSelecteds) < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigHandler.MoveToGroup(_config, lstSelecteds, SelectedMoveToGroup.id);
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
|
||||
RefreshServers();
|
||||
SelectedMoveToGroup = new();
|
||||
//Reload();
|
||||
}
|
||||
|
||||
public void MoveServer(EMove eMove)
|
||||
{
|
||||
var item = _lstProfile.FirstOrDefault(t => t.indexId == SelectedProfile.indexId);
|
||||
|
|
|
@ -451,6 +451,23 @@
|
|||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="{x:Static resx:ResUI.menuShareServer}" />
|
||||
<Separator />
|
||||
<MenuItem
|
||||
x:Name="menuMoveToGroup"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="{x:Static resx:ResUI.menuMoveToGroup}">
|
||||
<MenuItem Height="Auto">
|
||||
<MenuItem.Header>
|
||||
<DockPanel>
|
||||
<ComboBox
|
||||
x:Name="cmbMoveToGroup"
|
||||
Width="200"
|
||||
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.menuSubscription}"
|
||||
DisplayMemberPath="remarks"
|
||||
Style="{StaticResource MaterialDesignFilledComboBox}" />
|
||||
</DockPanel>
|
||||
</MenuItem.Header>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
x:Name="menuMoveTop"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
|
|
|
@ -66,6 +66,9 @@ namespace v2rayN.Views
|
|||
this.BindCommand(ViewModel, vm => vm.ShareServerCmd, v => v.menuShareServer).DisposeWith(disposables);
|
||||
|
||||
//servers move
|
||||
this.OneWayBind(ViewModel, vm => vm.SubItems, v => v.cmbMoveToGroup.ItemsSource).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedMoveToGroup, v => v.cmbMoveToGroup.SelectedItem).DisposeWith(disposables);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.MoveTopCmd, v => v.menuMoveTop).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.MoveUpCmd, v => v.menuMoveUp).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.MoveDownCmd, v => v.menuMoveDown).DisposeWith(disposables);
|
||||
|
|
Loading…
Reference in New Issue