Skip to content

Commit 510cdc4

Browse files
committed
修改下载速度,加入更新下载源设置
1 parent 76ad5c6 commit 510cdc4

4 files changed

Lines changed: 24 additions & 10 deletions

File tree

Round.NET.AvaloniaApp.EncodeCalculator/Models/Config/Config.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class RootConfig
1818
true,
1919
true
2020
};
21+
public bool UpdateChannelAcceleration { get; set; } = true;
2122
}
2223

2324
public static void LoadConfig()

Round.NET.AvaloniaApp.EncodeCalculator/Models/Update/Update.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ private static async Task DownloadFileAsync(string url, string fileName,Progress
116116
{
117117
var downloadOpt = new DownloadConfiguration()
118118
{
119-
BufferBlockSize = 10240,
120-
ChunkCount = 64,
121-
MaxTryAgainOnFailover = 5,
122-
ParallelDownload = true,
123-
ParallelCount = 10,
119+
//BufferBlockSize = 1024,
120+
//ChunkCount = 256,
121+
//MaxTryAgainOnFailover = 5,
122+
//ParallelDownload = true,
123+
//ParallelCount = 256,
124124
Timeout = 1000,
125-
ClearPackageOnCompletionWithFailure = true,
126-
MinimumSizeOfChunking = 1024,
127-
ReserveStorageSpaceBeforeStartingDownload = true
125+
//ClearPackageOnCompletionWithFailure = true,
126+
//MinimumSizeOfChunking = 1024,
127+
//ReserveStorageSpaceBeforeStartingDownload = true
128128
};
129129

130130
var downloader = new DownloadService(downloadOpt);
@@ -143,13 +143,20 @@ private static async Task DownloadFileAsync(string url, string fileName,Progress
143143
string filePath = Path.Combine(Directory.GetCurrentDirectory(), fileName);
144144
Console.WriteLine($"开始下载文件到: {filePath}");
145145

146-
await downloader.DownloadFileTaskAsync(url, filePath);
146+
if (Config.Config.MainConfig.UpdateChannelAcceleration)
147+
{
148+
await downloader.DownloadFileTaskAsync($"https://gh.api.99988866.xyz/{url}", filePath);
149+
}
150+
else
151+
{
152+
await downloader.DownloadFileTaskAsync($"{url}", filePath);
153+
}
147154
Console.WriteLine($"文件已成功下载到: {filePath}");
148155

149156
Process.Start(filePath);
150157
Task.Run(() =>
151158
{
152-
Thread.Sleep(3000);
159+
Thread.Sleep(800);
153160
Environment.Exit(0);
154161
});
155162
}

Round.NET.AvaloniaApp.EncodeCalculator/Views/Pages/SubPages/SettingPage.axaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
<CheckBox IsChecked="True" x:Name="Suc">普通信息</CheckBox>
2323
</DockPanel>
2424
</DockPanel>
25+
<DockPanel>
26+
<Label VerticalAlignment="Center">更新渠道加速:</Label>
27+
<CheckBox Name="UpdateChannelAccelerationBox">加速</CheckBox>
28+
</DockPanel>
2529
</StackPanel>
2630
</ScrollViewer>
2731
</Grid>

Round.NET.AvaloniaApp.EncodeCalculator/Views/Pages/SubPages/SettingPage.axaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void RefreshControl()
3232
Suc.IsChecked = _config.MessageModel[2];
3333

3434
FontSizeBar.Value = _config.OutBoxFontSize;
35+
UpdateChannelAccelerationBox.IsChecked = _config.UpdateChannelAcceleration;
3536
}
3637

3738
public void GetConfig()
@@ -41,6 +42,7 @@ public void GetConfig()
4142
_config.MessageModel[2] = (bool)Suc.IsChecked;
4243

4344
_config.OutBoxFontSize = (int)FontSizeBar.Value;
45+
_config.UpdateChannelAcceleration = (bool)UpdateChannelAccelerationBox.IsChecked;
4446
}
4547

4648
public SettingPage()

0 commit comments

Comments
 (0)