mirror of
https://github.com/2dust/v2rayN.git
synced 2026-10-17 18:55:01 +03:00
Added Copy Terminal proxy command to clipboard in tray menu
https://github.com/2dust/v2rayN/issues/6482
This commit is contained in:
@@ -32,6 +32,7 @@ namespace ServiceLib.ViewModels
|
||||
public ReactiveCommand<Unit, Unit> AddServerViaScanCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SubUpdateCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SubUpdateViaProxyCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> CopyProxyCmdToClipboardCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> NotifyLeftClickCmd { get; }
|
||||
|
||||
#region System Proxy
|
||||
@@ -128,6 +129,11 @@ namespace ServiceLib.ViewModels
|
||||
y => y == true)
|
||||
.Subscribe(async c => await DoEnableTun(c));
|
||||
|
||||
CopyProxyCmdToClipboardCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await CopyProxyCmdToClipboard();
|
||||
});
|
||||
|
||||
NotifyLeftClickCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(null);
|
||||
@@ -198,6 +204,23 @@ namespace ServiceLib.ViewModels
|
||||
await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null);
|
||||
}
|
||||
|
||||
private async Task CopyProxyCmdToClipboard()
|
||||
{
|
||||
var cmd = Utils.IsWindows() ? "set" : "export";
|
||||
var address = $"{Global.Loopback}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)}";
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"{cmd} http_proxy=http://{address}");
|
||||
sb.AppendLine($"{cmd} https_proxy=http://{address}");
|
||||
sb.AppendLine($"{cmd} all_proxy=socks5://{address}");
|
||||
sb.AppendLine("");
|
||||
sb.AppendLine($"{cmd} HTTP_PROXY=http://{address}");
|
||||
sb.AppendLine($"{cmd} HTTPS_PROXY=http://{address}");
|
||||
sb.AppendLine($"{cmd} ALL_PROXY=socks5://{address}");
|
||||
|
||||
await _updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString());
|
||||
}
|
||||
|
||||
private async Task AddServerViaClipboard()
|
||||
{
|
||||
var service = Locator.Current.GetService<MainWindowViewModel>();
|
||||
|
||||
Reference in New Issue
Block a user