Compare commits

..

2 commits

Author SHA1 Message Date
2dust
c3e56e84f1 Bug fix
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
https://github.com/2dust/v2rayN/issues/6932
2025-03-18 16:18:27 +08:00
dependabot[bot]
f1ef5a1f51
Bump actions/setup-dotnet from 4.3.0 to 4.3.1 (#6929)
Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 4.3.0 to 4.3.1.
- [Release notes](https://github.com/actions/setup-dotnet/releases)
- [Commits](https://github.com/actions/setup-dotnet/compare/v4.3.0...v4.3.1)

---
updated-dependencies:
- dependency-name: actions/setup-dotnet
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-18 10:01:15 +08:00
11 changed files with 44 additions and 15 deletions

View file

@ -32,7 +32,7 @@ jobs:
fetch-depth: '0' fetch-depth: '0'
- name: Setup - name: Setup
uses: actions/setup-dotnet@v4.3.0 uses: actions/setup-dotnet@v4.3.1
with: with:
dotnet-version: '8.0.x' dotnet-version: '8.0.x'

View file

@ -32,7 +32,7 @@ jobs:
fetch-depth: '0' fetch-depth: '0'
- name: Setup - name: Setup
uses: actions/setup-dotnet@v4.3.0 uses: actions/setup-dotnet@v4.3.1
with: with:
dotnet-version: '8.0.x' dotnet-version: '8.0.x'

View file

@ -32,7 +32,7 @@ jobs:
fetch-depth: '0' fetch-depth: '0'
- name: Setup - name: Setup
uses: actions/setup-dotnet@v4.3.0 uses: actions/setup-dotnet@v4.3.1
with: with:
dotnet-version: '8.0.x' dotnet-version: '8.0.x'

View file

@ -30,7 +30,7 @@ jobs:
uses: actions/checkout@v4.2.2 uses: actions/checkout@v4.2.2
- name: Setup - name: Setup
uses: actions/setup-dotnet@v4.3.0 uses: actions/setup-dotnet@v4.3.1
with: with:
dotnet-version: '8.0.x' dotnet-version: '8.0.x'

View file

@ -63,6 +63,10 @@ public partial class App : Application
if (desktop.MainWindow != null) if (desktop.MainWindow != null)
{ {
var clipboardData = await AvaUtils.GetClipboardData(desktop.MainWindow); var clipboardData = await AvaUtils.GetClipboardData(desktop.MainWindow);
if (clipboardData.IsNullOrEmpty())
{
return;
}
var service = Locator.Current.GetService<MainWindowViewModel>(); var service = Locator.Current.GetService<MainWindowViewModel>();
if (service != null) if (service != null)
{ {

View file

@ -14,7 +14,10 @@ namespace v2rayN.Desktop.Common
{ {
var clipboard = TopLevel.GetTopLevel(owner)?.Clipboard; var clipboard = TopLevel.GetTopLevel(owner)?.Clipboard;
if (clipboard == null) if (clipboard == null)
{
return null; return null;
}
return await clipboard.GetTextAsync(); return await clipboard.GetTextAsync();
} }
catch catch

View file

@ -247,7 +247,7 @@ namespace v2rayN.Desktop.Views
case EViewAction.AddServerViaClipboard: case EViewAction.AddServerViaClipboard:
var clipboardData = await AvaUtils.GetClipboardData(this); var clipboardData = await AvaUtils.GetClipboardData(this);
if (ViewModel != null) if (clipboardData.IsNotEmpty() && ViewModel != null)
{ {
await ViewModel.AddServerViaClipboardAsync(clipboardData); await ViewModel.AddServerViaClipboardAsync(clipboardData);
} }
@ -315,7 +315,7 @@ namespace v2rayN.Desktop.Views
{ {
case Key.V: case Key.V:
var clipboardData = await AvaUtils.GetClipboardData(this); var clipboardData = await AvaUtils.GetClipboardData(this);
if (ViewModel != null) if (clipboardData.IsNotEmpty() && ViewModel != null)
{ {
await ViewModel.AddServerViaClipboardAsync(clipboardData); await ViewModel.AddServerViaClipboardAsync(clipboardData);
} }

View file

@ -109,13 +109,20 @@ namespace v2rayN.Desktop.Views
case EViewAction.SetClipboardData: case EViewAction.SetClipboardData:
if (obj is null) if (obj is null)
{
return false; return false;
}
await AvaUtils.SetClipboardData(this, (string)obj); await AvaUtils.SetClipboardData(this, (string)obj);
break; break;
case EViewAction.ImportRulesFromClipboard: case EViewAction.ImportRulesFromClipboard:
var clipboardData = await AvaUtils.GetClipboardData(this); var clipboardData = await AvaUtils.GetClipboardData(this);
ViewModel?.ImportRulesFromClipboardAsync(clipboardData); if (clipboardData.IsNotEmpty())
{
ViewModel?.ImportRulesFromClipboardAsync(clipboardData);
}
break; break;
} }

View file

@ -18,11 +18,11 @@ namespace v2rayN
/// <returns></returns> /// <returns></returns>
public static string? GetClipboardData() public static string? GetClipboardData()
{ {
string? strData = string.Empty; var strData = string.Empty;
try try
{ {
IDataObject data = Clipboard.GetDataObject(); var data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.UnicodeText)) if (data?.GetDataPresent(DataFormats.UnicodeText) == true)
{ {
strData = data.GetData(DataFormats.UnicodeText)?.ToString(); strData = data.GetData(DataFormats.UnicodeText)?.ToString();
} }

View file

@ -232,7 +232,10 @@ namespace v2rayN.Views
case EViewAction.AddServerViaClipboard: case EViewAction.AddServerViaClipboard:
var clipboardData = WindowsUtils.GetClipboardData(); var clipboardData = WindowsUtils.GetClipboardData();
ViewModel?.AddServerViaClipboardAsync(clipboardData); if (clipboardData.IsNotEmpty())
{
ViewModel?.AddServerViaClipboardAsync(clipboardData);
}
break; break;
case EViewAction.AdjustMainLvColWidth: case EViewAction.AdjustMainLvColWidth:
@ -284,11 +287,20 @@ namespace v2rayN.Views
{ {
case Key.V: case Key.V:
if (Keyboard.FocusedElement is TextBox) if (Keyboard.FocusedElement is TextBox)
{
return; return;
}
var clipboardData = WindowsUtils.GetClipboardData(); var clipboardData = WindowsUtils.GetClipboardData();
var service = Locator.Current.GetService<MainWindowViewModel>(); if (clipboardData.IsNotEmpty())
if (service != null) {
_ = service.AddServerViaClipboardAsync(clipboardData); var service = Locator.Current.GetService<MainWindowViewModel>();
if (service != null)
{
_ = service.AddServerViaClipboardAsync(clipboardData);
}
}
break; break;
case Key.S: case Key.S:

View file

@ -110,7 +110,10 @@ namespace v2rayN.Views
case EViewAction.ImportRulesFromClipboard: case EViewAction.ImportRulesFromClipboard:
var clipboardData = WindowsUtils.GetClipboardData(); var clipboardData = WindowsUtils.GetClipboardData();
ViewModel?.ImportRulesFromClipboardAsync(clipboardData); if (clipboardData.IsNotEmpty())
{
ViewModel?.ImportRulesFromClipboardAsync(clipboardData);
}
break; break;
} }