Refactor settings and enhance download manager
Refactor application to use SettingService for managing settings. Update project to target Windows desktop application. Enhance DownloadManagerService for better task handling. Add new dependencies and remove obsolete settings files. Improve UI feedback and notifications for user actions.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using DownloadManager.Utilities;
|
||||
using System.IO;
|
||||
|
||||
namespace DownloadManager.Models.UrlGetter
|
||||
{
|
||||
@@ -6,8 +7,15 @@ namespace DownloadManager.Models.UrlGetter
|
||||
{
|
||||
public async Task<FileUrl> GetFileUrl(string taskUrl)
|
||||
{
|
||||
var fileName = System.IO.Path.GetFileName(taskUrl).ToUnescapedString();
|
||||
string? fileName = null;
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var extension = Path.GetExtension(taskUrl);
|
||||
fileName = string.IsNullOrEmpty(extension) ? "index.html" : Path.GetFileName(taskUrl).ToUnescapedString();
|
||||
});
|
||||
|
||||
return new FileUrl(taskUrl, fileName, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
return type switch
|
||||
{
|
||||
UrlGetterType.Direct => new DirectUrlGetter(),
|
||||
UrlGetterType.Yande => new YandeUrlGetter(),
|
||||
UrlGetterType.YandePost => new YandeUrlGetter(),
|
||||
_ => throw new ArgumentException("Invalid UrlGetterType"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ namespace DownloadManager.Models.UrlGetter
|
||||
[Description("Direct")]
|
||||
Direct,
|
||||
[Description("Yande post URL")]
|
||||
Yande,
|
||||
YandePost,
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,9 @@ public class YandeUrlGetter : IUrlGetter
|
||||
|
||||
public async Task<FileUrl> GetFileUrl(string taskUrl)
|
||||
{
|
||||
if (!taskUrl.StartsWith("https://yande.re/post/show/"))
|
||||
return new FileUrl(null, null, null);
|
||||
|
||||
// Get the ID of the post from the URL
|
||||
var id = taskUrl.Split("https://yande.re/post/show/").Last();
|
||||
|
||||
|
||||
18
Models/UserSetting.cs
Normal file
18
Models/UserSetting.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Wpf.Ui.Appearance;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace DownloadManager.Models
|
||||
{
|
||||
public class UserSetting
|
||||
{
|
||||
public ApplicationTheme Theme { get; set; } = ApplicationTheme.Dark;
|
||||
public WindowBackdropType Backdrop { get; set; } = WindowBackdropType.Mica;
|
||||
public string DefaultSaveLocation { get; set; } = string.Empty;
|
||||
public int SplitCount { get; set; } = 1;
|
||||
public bool UseParallelDownload { get; set; } = false;
|
||||
public int RetryCount { get; set; } = 5;
|
||||
public int MaxActiveDownloadCount { get; set; } = 3;
|
||||
|
||||
public bool SystemNotification { get; set; } = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user