>Export Base64-encoded Share Links to Clipboard

pull/5550/head
2dust 2024-08-17 20:53:42 +08:00
parent 7faabdc375
commit 770e8b8cfa
7 changed files with 117 additions and 36 deletions

View File

@ -79,7 +79,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Batch export share URL to clipboard successfully 的本地化字符串。 /// 查找类似 Export Share Link to Clipboard Successfully 的本地化字符串。
/// </summary> /// </summary>
public static string BatchExportURLSuccessfully { public static string BatchExportURLSuccessfully {
get { get {
@ -610,7 +610,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Import bulk URL from clipboard (Ctrl+V) 的本地化字符串。 /// 查找类似 Importing Share Links from clipboard (Ctrl+V) 的本地化字符串。
/// </summary> /// </summary>
public static string menuAddServerViaClipboard { public static string menuAddServerViaClipboard {
get { get {
@ -772,7 +772,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Export selected server for client configuration 的本地化字符串。 /// 查找类似 Export selected server for complete configuration 的本地化字符串。
/// </summary> /// </summary>
public static string menuExport2ClientConfig { public static string menuExport2ClientConfig {
get { get {
@ -781,7 +781,16 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Export share URLs to clipboard (Ctrl+C) 的本地化字符串。 /// 查找类似 Export selected server for complete configuration to clipboard 的本地化字符串。
/// </summary>
public static string menuExport2ClientConfigClipboard {
get {
return ResourceManager.GetString("menuExport2ClientConfigClipboard", resourceCulture);
}
}
/// <summary>
/// 查找类似 Export Share Link to Clipboard (Ctrl+C) 的本地化字符串。
/// </summary> /// </summary>
public static string menuExport2ShareUrl { public static string menuExport2ShareUrl {
get { get {
@ -789,6 +798,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Export Base64-encoded Share Links to Clipboard 的本地化字符串。
/// </summary>
public static string menuExport2ShareUrlBase64 {
get {
return ResourceManager.GetString("menuExport2ShareUrlBase64", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Global Hotkey Setting 的本地化字符串。 /// 查找类似 Global Hotkey Setting 的本地化字符串。
/// </summary> /// </summary>
@ -1934,7 +1952,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Scan import URL successfully 的本地化字符串。 /// 查找类似 Scan import the shared link successfully 的本地化字符串。
/// </summary> /// </summary>
public static string SuccessfullyImportedServerViaScan { public static string SuccessfullyImportedServerViaScan {
get { get {

View File

@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="BatchExportURLSuccessfully" xml:space="preserve"> <data name="BatchExportURLSuccessfully" xml:space="preserve">
<value>Batch export share URL to clipboard successfully</value> <value>Export Share Link to Clipboard Successfully</value>
</data> </data>
<data name="CheckServerSettings" xml:space="preserve"> <data name="CheckServerSettings" xml:space="preserve">
<value>Please check the server settings first</value> <value>Please check the server settings first</value>
@ -299,7 +299,7 @@
<value>{0} servers have been imported from clipboard</value> <value>{0} servers have been imported from clipboard</value>
</data> </data>
<data name="SuccessfullyImportedServerViaScan" xml:space="preserve"> <data name="SuccessfullyImportedServerViaScan" xml:space="preserve">
<value>Scan import URL successfully</value> <value>Scan import the shared link successfully</value>
</data> </data>
<data name="TestMeOutput" xml:space="preserve"> <data name="TestMeOutput" xml:space="preserve">
<value>The ping of current service: {0} ms</value> <value>The ping of current service: {0} ms</value>
@ -491,7 +491,7 @@
<value>Language (Restart)</value> <value>Language (Restart)</value>
</data> </data>
<data name="menuAddServerViaClipboard" xml:space="preserve"> <data name="menuAddServerViaClipboard" xml:space="preserve">
<value>Import bulk URL from clipboard (Ctrl+V)</value> <value>Importing Share Links from clipboard (Ctrl+V)</value>
</data> </data>
<data name="menuAddServerViaScan" xml:space="preserve"> <data name="menuAddServerViaScan" xml:space="preserve">
<value>Scan QR code on the screen (Ctrl+S)</value> <value>Scan QR code on the screen (Ctrl+S)</value>
@ -524,10 +524,10 @@
<value>Test servers with tcping (Ctrl+O)</value> <value>Test servers with tcping (Ctrl+O)</value>
</data> </data>
<data name="menuExport2ClientConfig" xml:space="preserve"> <data name="menuExport2ClientConfig" xml:space="preserve">
<value>Export selected server for client configuration</value> <value>Export selected server for complete configuration</value>
</data> </data>
<data name="menuExport2ShareUrl" xml:space="preserve"> <data name="menuExport2ShareUrl" xml:space="preserve">
<value>Export share URLs to clipboard (Ctrl+C)</value> <value>Export Share Link to Clipboard (Ctrl+C)</value>
</data> </data>
<data name="menuAddCustomServer" xml:space="preserve"> <data name="menuAddCustomServer" xml:space="preserve">
<value>Add a custom configuration server</value> <value>Add a custom configuration server</value>
@ -1264,4 +1264,10 @@
<data name="menuProfileAutofitColumnWidth" xml:space="preserve"> <data name="menuProfileAutofitColumnWidth" xml:space="preserve">
<value>Auto column width adjustment</value> <value>Auto column width adjustment</value>
</data> </data>
<data name="menuExport2ShareUrlBase64" xml:space="preserve">
<value>Export Base64-encoded Share Links to Clipboard</value>
</data>
<data name="menuExport2ClientConfigClipboard" xml:space="preserve">
<value>Export selected server for complete configuration to clipboard</value>
</data>
</root> </root>

View File

@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="BatchExportURLSuccessfully" xml:space="preserve"> <data name="BatchExportURLSuccessfully" xml:space="preserve">
<value>批量导出分享URL至剪贴板成功</value> <value>导出分享链接至剪贴板成功</value>
</data> </data>
<data name="CheckServerSettings" xml:space="preserve"> <data name="CheckServerSettings" xml:space="preserve">
<value>请先检查服务器设置</value> <value>请先检查服务器设置</value>
@ -299,7 +299,7 @@
<value>成功从剪贴板导入 {0} 个服务器</value> <value>成功从剪贴板导入 {0} 个服务器</value>
</data> </data>
<data name="SuccessfullyImportedServerViaScan" xml:space="preserve"> <data name="SuccessfullyImportedServerViaScan" xml:space="preserve">
<value>扫描导入URL成功</value> <value>扫描导入分享链接成功</value>
</data> </data>
<data name="TestMeOutput" xml:space="preserve"> <data name="TestMeOutput" xml:space="preserve">
<value>当前服务的真连接延迟: {0} ms</value> <value>当前服务的真连接延迟: {0} ms</value>
@ -491,7 +491,7 @@
<value>语言(重启)</value> <value>语言(重启)</value>
</data> </data>
<data name="menuAddServerViaClipboard" xml:space="preserve"> <data name="menuAddServerViaClipboard" xml:space="preserve">
<value>从剪贴板导入批量URL (Ctrl+V)</value> <value>从剪贴板导入分享链接 (Ctrl+V)</value>
</data> </data>
<data name="menuAddServerViaScan" xml:space="preserve"> <data name="menuAddServerViaScan" xml:space="preserve">
<value>扫描屏幕上的二维码 (Ctrl+S)</value> <value>扫描屏幕上的二维码 (Ctrl+S)</value>
@ -524,10 +524,10 @@
<value>测试服务器延迟Tcping(多选) (Ctrl+O)</value> <value>测试服务器延迟Tcping(多选) (Ctrl+O)</value>
</data> </data>
<data name="menuExport2ClientConfig" xml:space="preserve"> <data name="menuExport2ClientConfig" xml:space="preserve">
<value>导出所选服务器为客户端配置</value> <value>导出所选服务器完整配置</value>
</data> </data>
<data name="menuExport2ShareUrl" xml:space="preserve"> <data name="menuExport2ShareUrl" xml:space="preserve">
<value>批量导出分享URL至剪贴板(多选) (Ctrl+C)</value> <value>导出分享链接至剪贴板(多选) (Ctrl+C)</value>
</data> </data>
<data name="menuAddCustomServer" xml:space="preserve"> <data name="menuAddCustomServer" xml:space="preserve">
<value>添加自定义配置服务器</value> <value>添加自定义配置服务器</value>
@ -1261,4 +1261,10 @@
<data name="menuProfileAutofitColumnWidth" xml:space="preserve"> <data name="menuProfileAutofitColumnWidth" xml:space="preserve">
<value>自动调整列宽</value> <value>自动调整列宽</value>
</data> </data>
<data name="menuExport2ShareUrlBase64" xml:space="preserve">
<value>导出分享链接至剪贴板(多选) Base64编码</value>
</data>
<data name="menuExport2ClientConfigClipboard" xml:space="preserve">
<value>导出所选服务器完整配置至剪贴板</value>
</data>
</root> </root>

View File

@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="BatchExportURLSuccessfully" xml:space="preserve"> <data name="BatchExportURLSuccessfully" xml:space="preserve">
<value>批次匯出分享URL至剪貼簿成功</value> <value>匯出分享链接至剪貼簿成功</value>
</data> </data>
<data name="CheckServerSettings" xml:space="preserve"> <data name="CheckServerSettings" xml:space="preserve">
<value>請先檢查伺服器設定</value> <value>請先檢查伺服器設定</value>
@ -298,7 +298,7 @@
<value>成功從剪貼簿匯入 {0} 個伺服器</value> <value>成功從剪貼簿匯入 {0} 個伺服器</value>
</data> </data>
<data name="SuccessfullyImportedServerViaScan" xml:space="preserve"> <data name="SuccessfullyImportedServerViaScan" xml:space="preserve">
<value>掃描匯入URL成功</value> <value>掃描匯入分享链接成功</value>
</data> </data>
<data name="TestMeOutput" xml:space="preserve"> <data name="TestMeOutput" xml:space="preserve">
<value>目前服務的真連接延遲: {0} ms</value> <value>目前服務的真連接延遲: {0} ms</value>
@ -490,7 +490,7 @@
<value>語言(重啟)</value> <value>語言(重啟)</value>
</data> </data>
<data name="menuAddServerViaClipboard" xml:space="preserve"> <data name="menuAddServerViaClipboard" xml:space="preserve">
<value>從剪貼簿匯入批次URL (Ctrl+V)</value> <value>從剪貼簿導入分享鏈接 (Ctrl+V)</value>
</data> </data>
<data name="menuAddServerViaScan" xml:space="preserve"> <data name="menuAddServerViaScan" xml:space="preserve">
<value>掃描螢幕上的二維碼 (Ctrl+S)</value> <value>掃描螢幕上的二維碼 (Ctrl+S)</value>
@ -523,10 +523,10 @@
<value>測試伺服器延遲Tcping(多選) (Ctrl+O)</value> <value>測試伺服器延遲Tcping(多選) (Ctrl+O)</value>
</data> </data>
<data name="menuExport2ClientConfig" xml:space="preserve"> <data name="menuExport2ClientConfig" xml:space="preserve">
<value>匯出所選伺服器為用戶端配置</value> <value>匯出所選伺服器完整配置</value>
</data> </data>
<data name="menuExport2ShareUrl" xml:space="preserve"> <data name="menuExport2ShareUrl" xml:space="preserve">
<value>批次匯出分享URL至剪貼簿(多選) (Ctrl+C)</value> <value>匯出分享链接至剪貼簿(多選) (Ctrl+C)</value>
</data> </data>
<data name="menuAddCustomServer" xml:space="preserve"> <data name="menuAddCustomServer" xml:space="preserve">
<value>新增自訂配置伺服器</value> <value>新增自訂配置伺服器</value>
@ -1141,4 +1141,10 @@
<data name="menuProfileAutofitColumnWidth" xml:space="preserve"> <data name="menuProfileAutofitColumnWidth" xml:space="preserve">
<value>自動調整列寬</value> <value>自動調整列寬</value>
</data> </data>
<data name="menuExport2ShareUrlBase64" xml:space="preserve">
<value>匯出分享链接至剪貼簿(多選) Base64编码</value>
</data>
<data name="menuExport2ClientConfigClipboard" xml:space="preserve">
<value>匯出所選伺服器完整配置至剪貼簿</value>
</data>
</root> </root>

View File

@ -90,7 +90,9 @@ namespace v2rayN.ViewModels
//servers export //servers export
public ReactiveCommand<Unit, Unit> Export2ClientConfigCmd { get; } public ReactiveCommand<Unit, Unit> Export2ClientConfigCmd { get; }
public ReactiveCommand<Unit, Unit> Export2ClientConfigClipboardCmd { get; }
public ReactiveCommand<Unit, Unit> Export2ShareUrlCmd { get; } public ReactiveCommand<Unit, Unit> Export2ShareUrlCmd { get; }
public ReactiveCommand<Unit, Unit> Export2ShareUrlBase64Cmd { get; }
public ReactiveCommand<Unit, Unit> AddSubCmd { get; } public ReactiveCommand<Unit, Unit> AddSubCmd { get; }
public ReactiveCommand<Unit, Unit> EditSubCmd { get; } public ReactiveCommand<Unit, Unit> EditSubCmd { get; }
@ -216,11 +218,19 @@ namespace v2rayN.ViewModels
//servers export //servers export
Export2ClientConfigCmd = ReactiveCommand.Create(() => Export2ClientConfigCmd = ReactiveCommand.Create(() =>
{ {
Export2ClientConfig(); Export2ClientConfig(false);
}, canEditRemove);
Export2ClientConfigClipboardCmd = ReactiveCommand.Create(() =>
{
Export2ClientConfig(true);
}, canEditRemove); }, canEditRemove);
Export2ShareUrlCmd = ReactiveCommand.Create(() => Export2ShareUrlCmd = ReactiveCommand.Create(() =>
{ {
Export2ShareUrl(); Export2ShareUrl(false);
}, canEditRemove);
Export2ShareUrlBase64Cmd = ReactiveCommand.Create(() =>
{
Export2ShareUrl(true);
}, canEditRemove); }, canEditRemove);
//Subscription //Subscription
@ -670,7 +680,7 @@ namespace v2rayN.ViewModels
} }
} }
private void Export2ClientConfig() private void Export2ClientConfig(bool blClipboard)
{ {
var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId); var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId);
if (item is null) if (item is null)
@ -678,8 +688,22 @@ namespace v2rayN.ViewModels
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer); _noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
return; return;
} }
if (blClipboard)
_updateView?.Invoke(EViewAction.SaveFileDialog, item); {
if (CoreConfigHandler.GenerateClientConfig(item, null, out string msg, out string content) != 0)
{
Locator.Current.GetService<NoticeHandler>()?.Enqueue(msg);
}
else
{
WindowsUtils.SetClipboardData(content);
_noticeHandler?.SendMessage(ResUI.OperationSuccess);
}
}
else
{
_updateView?.Invoke(EViewAction.SaveFileDialog, item);
}
} }
public void Export2ClientConfigResult(string fileName, ProfileItem 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<ProfileItem> lstSelecteds, true) < 0) if (GetProfileItems(out List<ProfileItem> lstSelecteds, true) < 0)
{ {
@ -719,7 +743,14 @@ namespace v2rayN.ViewModels
} }
if (sb.Length > 0) 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); _noticeHandler?.SendMessage(ResUI.BatchExportURLSuccessfully);
} }
} }

View File

@ -192,14 +192,26 @@
Click="menuSelectAll_Click" Click="menuSelectAll_Click"
Header="{x:Static resx:ResUI.menuSelectAll}" /> Header="{x:Static resx:ResUI.menuSelectAll}" />
<Separator /> <Separator />
<MenuItem <MenuItem Header="{x:Static resx:ResUI.menuExport2ClientConfig}">
x:Name="menuExport2ClientConfig" <MenuItem
Height="{StaticResource MenuItemHeight}" x:Name="menuExport2ClientConfig"
Header="{x:Static resx:ResUI.menuExport2ClientConfig}" /> Height="{StaticResource MenuItemHeight}"
<MenuItem Header="{x:Static resx:ResUI.menuExport2ClientConfig}" />
x:Name="menuExport2ShareUrl" <MenuItem
Height="{StaticResource MenuItemHeight}" x:Name="menuExport2ClientConfigClipboard"
Header="{x:Static resx:ResUI.menuExport2ShareUrl}" /> Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuExport2ClientConfigClipboard}" />
</MenuItem>
<MenuItem Header="{x:Static resx:ResUI.menuExport2ShareUrl}">
<MenuItem
x:Name="menuExport2ShareUrl"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuExport2ShareUrl}" />
<MenuItem
x:Name="menuExport2ShareUrlBase64"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuExport2ShareUrlBase64}" />
</MenuItem>
</ContextMenu> </ContextMenu>
</DataGrid.ContextMenu> </DataGrid.ContextMenu>
<DataGrid.Resources> <DataGrid.Resources>

View File

@ -87,7 +87,9 @@ namespace v2rayN.Views
//servers export //servers export
this.BindCommand(ViewModel, vm => vm.Export2ClientConfigCmd, v => v.menuExport2ClientConfig).DisposeWith(disposables); 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.Export2ShareUrlCmd, v => v.menuExport2ShareUrl).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.Export2ShareUrlBase64Cmd, v => v.menuExport2ShareUrlBase64).DisposeWith(disposables);
}); });
RestoreUI(); RestoreUI();
@ -236,7 +238,7 @@ namespace v2rayN.Views
break; break;
case Key.C: case Key.C:
ViewModel?.Export2ShareUrl(); ViewModel?.Export2ShareUrl(false);
break; break;
case Key.D: case Key.D: