From 770e8b8cfa4d6f81e0b37572a7d39ed9680af5c1 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Sat, 17 Aug 2024 20:53:42 +0800
Subject: [PATCH] >Export Base64-encoded Share Links to Clipboard
---
v2rayN/v2rayN/Resx/ResUI.Designer.cs | 28 +++++++++---
v2rayN/v2rayN/Resx/ResUI.resx | 16 ++++---
v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx | 16 ++++---
v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx | 16 ++++---
v2rayN/v2rayN/ViewModels/ProfilesViewModel.cs | 45 ++++++++++++++++---
v2rayN/v2rayN/Views/ProfilesView.xaml | 28 ++++++++----
v2rayN/v2rayN/Views/ProfilesView.xaml.cs | 4 +-
7 files changed, 117 insertions(+), 36 deletions(-)
diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs
index 025f9ab5..9cab6ac7 100644
--- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs
+++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs
@@ -79,7 +79,7 @@ namespace v2rayN.Resx {
}
///
- /// 查找类似 Batch export share URL to clipboard successfully 的本地化字符串。
+ /// 查找类似 Export Share Link to Clipboard Successfully 的本地化字符串。
///
public static string BatchExportURLSuccessfully {
get {
@@ -610,7 +610,7 @@ namespace v2rayN.Resx {
}
///
- /// 查找类似 Import bulk URL from clipboard (Ctrl+V) 的本地化字符串。
+ /// 查找类似 Importing Share Links from clipboard (Ctrl+V) 的本地化字符串。
///
public static string menuAddServerViaClipboard {
get {
@@ -772,7 +772,7 @@ namespace v2rayN.Resx {
}
///
- /// 查找类似 Export selected server for client configuration 的本地化字符串。
+ /// 查找类似 Export selected server for complete configuration 的本地化字符串。
///
public static string menuExport2ClientConfig {
get {
@@ -781,7 +781,16 @@ namespace v2rayN.Resx {
}
///
- /// 查找类似 Export share URLs to clipboard (Ctrl+C) 的本地化字符串。
+ /// 查找类似 Export selected server for complete configuration to clipboard 的本地化字符串。
+ ///
+ public static string menuExport2ClientConfigClipboard {
+ get {
+ return ResourceManager.GetString("menuExport2ClientConfigClipboard", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Export Share Link to Clipboard (Ctrl+C) 的本地化字符串。
///
public static string menuExport2ShareUrl {
get {
@@ -789,6 +798,15 @@ namespace v2rayN.Resx {
}
}
+ ///
+ /// 查找类似 Export Base64-encoded Share Links to Clipboard 的本地化字符串。
+ ///
+ public static string menuExport2ShareUrlBase64 {
+ get {
+ return ResourceManager.GetString("menuExport2ShareUrlBase64", resourceCulture);
+ }
+ }
+
///
/// 查找类似 Global Hotkey Setting 的本地化字符串。
///
@@ -1934,7 +1952,7 @@ namespace v2rayN.Resx {
}
///
- /// 查找类似 Scan import URL successfully 的本地化字符串。
+ /// 查找类似 Scan import the shared link successfully 的本地化字符串。
///
public static string SuccessfullyImportedServerViaScan {
get {
diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx
index ed56bf04..d7c8b6c2 100644
--- a/v2rayN/v2rayN/Resx/ResUI.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.resx
@@ -118,7 +118,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- Batch export share URL to clipboard successfully
+ Export Share Link to Clipboard Successfully
Please check the server settings first
@@ -299,7 +299,7 @@
{0} servers have been imported from clipboard
- Scan import URL successfully
+ Scan import the shared link successfully
The ping of current service: {0} ms
@@ -491,7 +491,7 @@
Language (Restart)
- Import bulk URL from clipboard (Ctrl+V)
+ Importing Share Links from clipboard (Ctrl+V)
Scan QR code on the screen (Ctrl+S)
@@ -524,10 +524,10 @@
Test servers with tcping (Ctrl+O)
- Export selected server for client configuration
+ Export selected server for complete configuration
- Export share URLs to clipboard (Ctrl+C)
+ Export Share Link to Clipboard (Ctrl+C)
Add a custom configuration server
@@ -1264,4 +1264,10 @@
Auto column width adjustment
+
+ Export Base64-encoded Share Links to Clipboard
+
+
+ Export selected server for complete configuration to clipboard
+
\ No newline at end of file
diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
index 85835b85..1334b3dd 100644
--- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
@@ -118,7 +118,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- 批量导出分享URL至剪贴板成功
+ 导出分享链接至剪贴板成功
请先检查服务器设置
@@ -299,7 +299,7 @@
成功从剪贴板导入 {0} 个服务器
- 扫描导入URL成功
+ 扫描导入分享链接成功
当前服务的真连接延迟: {0} ms
@@ -491,7 +491,7 @@
语言(重启)
- 从剪贴板导入批量URL (Ctrl+V)
+ 从剪贴板导入分享链接 (Ctrl+V)
扫描屏幕上的二维码 (Ctrl+S)
@@ -524,10 +524,10 @@
测试服务器延迟Tcping(多选) (Ctrl+O)
- 导出所选服务器为客户端配置
+ 导出所选服务器完整配置
- 批量导出分享URL至剪贴板(多选) (Ctrl+C)
+ 导出分享链接至剪贴板(多选) (Ctrl+C)
添加自定义配置服务器
@@ -1261,4 +1261,10 @@
自动调整列宽
+
+ 导出分享链接至剪贴板(多选) Base64编码
+
+
+ 导出所选服务器完整配置至剪贴板
+
\ No newline at end of file
diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx
index 18aa6d58..ad392c08 100644
--- a/v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx
@@ -118,7 +118,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- 批次匯出分享URL至剪貼簿成功
+ 匯出分享链接至剪貼簿成功
請先檢查伺服器設定
@@ -298,7 +298,7 @@
成功從剪貼簿匯入 {0} 個伺服器
- 掃描匯入URL成功
+ 掃描匯入分享链接成功
目前服務的真連接延遲: {0} ms
@@ -490,7 +490,7 @@
語言(重啟)
- 從剪貼簿匯入批次URL (Ctrl+V)
+ 從剪貼簿導入分享鏈接 (Ctrl+V)
掃描螢幕上的二維碼 (Ctrl+S)
@@ -523,10 +523,10 @@
測試伺服器延遲Tcping(多選) (Ctrl+O)
- 匯出所選伺服器為用戶端配置
+ 匯出所選伺服器完整配置
- 批次匯出分享URL至剪貼簿(多選) (Ctrl+C)
+ 匯出分享链接至剪貼簿(多選) (Ctrl+C)
新增自訂配置伺服器
@@ -1141,4 +1141,10 @@
自動調整列寬
+
+ 匯出分享链接至剪貼簿(多選) Base64编码
+
+
+ 匯出所選伺服器完整配置至剪貼簿
+
\ No newline at end of file
diff --git a/v2rayN/v2rayN/ViewModels/ProfilesViewModel.cs b/v2rayN/v2rayN/ViewModels/ProfilesViewModel.cs
index 2eeb7f95..0d395a16 100644
--- a/v2rayN/v2rayN/ViewModels/ProfilesViewModel.cs
+++ b/v2rayN/v2rayN/ViewModels/ProfilesViewModel.cs
@@ -90,7 +90,9 @@ namespace v2rayN.ViewModels
//servers export
public ReactiveCommand Export2ClientConfigCmd { get; }
+ public ReactiveCommand Export2ClientConfigClipboardCmd { get; }
public ReactiveCommand Export2ShareUrlCmd { get; }
+ public ReactiveCommand Export2ShareUrlBase64Cmd { get; }
public ReactiveCommand AddSubCmd { get; }
public ReactiveCommand EditSubCmd { get; }
@@ -216,11 +218,19 @@ namespace v2rayN.ViewModels
//servers export
Export2ClientConfigCmd = ReactiveCommand.Create(() =>
{
- Export2ClientConfig();
+ Export2ClientConfig(false);
+ }, canEditRemove);
+ Export2ClientConfigClipboardCmd = ReactiveCommand.Create(() =>
+ {
+ Export2ClientConfig(true);
}, canEditRemove);
Export2ShareUrlCmd = ReactiveCommand.Create(() =>
{
- Export2ShareUrl();
+ Export2ShareUrl(false);
+ }, canEditRemove);
+ Export2ShareUrlBase64Cmd = ReactiveCommand.Create(() =>
+ {
+ Export2ShareUrl(true);
}, canEditRemove);
//Subscription
@@ -670,7 +680,7 @@ namespace v2rayN.ViewModels
}
}
- private void Export2ClientConfig()
+ private void Export2ClientConfig(bool blClipboard)
{
var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId);
if (item is null)
@@ -678,8 +688,22 @@ namespace v2rayN.ViewModels
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
return;
}
-
- _updateView?.Invoke(EViewAction.SaveFileDialog, item);
+ if (blClipboard)
+ {
+ if (CoreConfigHandler.GenerateClientConfig(item, null, out string msg, out string content) != 0)
+ {
+ Locator.Current.GetService()?.Enqueue(msg);
+ }
+ else
+ {
+ WindowsUtils.SetClipboardData(content);
+ _noticeHandler?.SendMessage(ResUI.OperationSuccess);
+ }
+ }
+ else
+ {
+ _updateView?.Invoke(EViewAction.SaveFileDialog, item);
+ }
}
public void Export2ClientConfigResult(string fileName, ProfileItem item)
@@ -699,7 +723,7 @@ namespace v2rayN.ViewModels
}
}
- public void Export2ShareUrl()
+ public void Export2ShareUrl(bool blEncode)
{
if (GetProfileItems(out List lstSelecteds, true) < 0)
{
@@ -719,7 +743,14 @@ namespace v2rayN.ViewModels
}
if (sb.Length > 0)
{
- WindowsUtils.SetClipboardData(sb.ToString());
+ if (blEncode)
+ {
+ WindowsUtils.SetClipboardData(Utils.Base64Encode(sb.ToString()));
+ }
+ else
+ {
+ WindowsUtils.SetClipboardData(sb.ToString());
+ }
_noticeHandler?.SendMessage(ResUI.BatchExportURLSuccessfully);
}
}
diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml b/v2rayN/v2rayN/Views/ProfilesView.xaml
index a108f54b..a1f08a91 100644
--- a/v2rayN/v2rayN/Views/ProfilesView.xaml
+++ b/v2rayN/v2rayN/Views/ProfilesView.xaml
@@ -192,14 +192,26 @@
Click="menuSelectAll_Click"
Header="{x:Static resx:ResUI.menuSelectAll}" />
-
-
+
+
+
+
+
diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs
index 96a53920..d0b5c27d 100644
--- a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs
+++ b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs
@@ -87,7 +87,9 @@ namespace v2rayN.Views
//servers export
this.BindCommand(ViewModel, vm => vm.Export2ClientConfigCmd, v => v.menuExport2ClientConfig).DisposeWith(disposables);
+ this.BindCommand(ViewModel, vm => vm.Export2ClientConfigClipboardCmd, v => v.menuExport2ClientConfigClipboard).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.Export2ShareUrlCmd, v => v.menuExport2ShareUrl).DisposeWith(disposables);
+ this.BindCommand(ViewModel, vm => vm.Export2ShareUrlBase64Cmd, v => v.menuExport2ShareUrlBase64).DisposeWith(disposables);
});
RestoreUI();
@@ -236,7 +238,7 @@ namespace v2rayN.Views
break;
case Key.C:
- ViewModel?.Export2ShareUrl();
+ ViewModel?.Export2ShareUrl(false);
break;
case Key.D: