mirror of
https://github.com/leiurayer/downkyi.git
synced 2025-01-30 05:40:20 +08:00
VideoDetail页面完善Upper()和CopyCoverUrl()方法
This commit is contained in:
parent
63b7fd9063
commit
e075463ccf
@ -3,4 +3,8 @@
|
|||||||
public interface IClipboardService
|
public interface IClipboardService
|
||||||
{
|
{
|
||||||
Task<string> GetTextAsync();
|
Task<string> GetTextAsync();
|
||||||
|
|
||||||
|
Task SetTextAsync(string text);
|
||||||
|
|
||||||
|
Task SetImageAsync(object obj);
|
||||||
}
|
}
|
@ -1,8 +1,12 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Downkyi.Core.Log;
|
||||||
|
using Downkyi.Core.Settings;
|
||||||
|
using Downkyi.Core.Settings.Models;
|
||||||
using Downkyi.UI.Models;
|
using Downkyi.UI.Models;
|
||||||
using Downkyi.UI.Mvvm;
|
using Downkyi.UI.Mvvm;
|
||||||
using Downkyi.UI.ViewModels.DownloadManager;
|
using Downkyi.UI.ViewModels.DownloadManager;
|
||||||
|
using Downkyi.UI.ViewModels.User;
|
||||||
|
|
||||||
namespace Downkyi.UI.ViewModels.Video;
|
namespace Downkyi.UI.ViewModels.Video;
|
||||||
|
|
||||||
@ -74,20 +78,53 @@ public partial class VideoDetailViewModel : ViewModelBase
|
|||||||
private void CopyCover() { }
|
private void CopyCover() { }
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void CopyCoverUrl() { }
|
private async Task CopyCoverUrl()
|
||||||
|
{
|
||||||
|
// 复制封面url到剪贴板
|
||||||
|
await ClipboardService.SetTextAsync(VideoInfoView.CoverUrl);
|
||||||
|
Log.Logger.Info("复制封面url到剪贴板");
|
||||||
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand(FlowExceptionsToTaskScheduler = true)]
|
||||||
private void Upper() { }
|
private async Task Upper()
|
||||||
|
{
|
||||||
|
await NavigateToViewUserSpace(VideoInfoView.UpperMid);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导航到用户空间,
|
||||||
|
/// 如果传入的mid与本地登录的mid一致,
|
||||||
|
/// 则进入我的用户空间。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mid"></param>
|
||||||
|
private async Task NavigateToViewUserSpace(long mid)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> parameter = new()
|
||||||
|
{
|
||||||
|
{ "key", Key },
|
||||||
|
{ "value", mid },
|
||||||
|
};
|
||||||
|
|
||||||
|
UserInfoSettings userInfo = SettingsManager.GetInstance().GetUserInfo();
|
||||||
|
if (userInfo != null && userInfo.Mid == mid)
|
||||||
|
{
|
||||||
|
await NavigationService.ForwardAsync(MySpaceViewModel.Key, parameter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await NavigationService.ForwardAsync(UserSpaceViewModel.Key, parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnNavigatedTo(Dictionary<string, object>? parameter)
|
public override void OnNavigatedTo(Dictionary<string, object>? parameter)
|
||||||
{
|
{
|
||||||
base.OnNavigatedTo(parameter);
|
base.OnNavigatedTo(parameter);
|
||||||
|
|
||||||
if (parameter!.ContainsKey("value"))
|
if (parameter!.TryGetValue("value", out object? value))
|
||||||
{
|
{
|
||||||
_input = (string)parameter["value"];
|
_input = (string)value;
|
||||||
InputText = _input;
|
InputText = _input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,4 +16,19 @@ public class ClipboardService : IClipboardService
|
|||||||
|
|
||||||
return await provider.GetTextAsync() ?? string.Empty;
|
return await provider.GetTextAsync() ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task SetTextAsync(string text)
|
||||||
|
{
|
||||||
|
if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
|
||||||
|
desktop.MainWindow?.Clipboard is not { } provider)
|
||||||
|
throw new NullReferenceException("Missing Clipboard instance.");
|
||||||
|
|
||||||
|
await provider.SetTextAsync(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task SetImageAsync(object obj)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user