feat: 下载器
This commit is contained in:
@@ -253,11 +253,47 @@ Public Module ModDownloadLib
|
||||
Version = sender.Parent.Parent.Tag
|
||||
End If
|
||||
RunInThread(Sub()
|
||||
Dim Json As JObject = NetGetCodeByRequestRetry(Version("url"), IsJson:=True)
|
||||
If Json("downloads")?("server") Is Nothing Then
|
||||
Dim Json As JObject
|
||||
Try
|
||||
Json = NetGetCodeByRequestRetry(Version("url"), IsJson:=True)
|
||||
Catch ex As Exception
|
||||
Log(ex, "未找能获取到服务端文件,文件可能不存在")
|
||||
End Try
|
||||
If Json?("downloads")?("server") Is Nothing Then
|
||||
Hint("此版本暂未有服务端文件提供下载")
|
||||
Else
|
||||
PageOtherTest.StartCustomDownload(Json("downloads")("server")("url").ToString(), Version("id").ToString() & "-server.jar")
|
||||
RunInUi(Sub()
|
||||
Try
|
||||
Dim Url As String = Json("downloads")("server")("url").ToString()
|
||||
Dim FileName As String = Version("id").ToString() & "-server.jar"
|
||||
Dim VersionID As String = Version("id").ToString()
|
||||
Dim Target As String = SelectAs("选择保存位置", FileName, "原版服务端 (*.jar)|*.jar")
|
||||
If Not Target.Contains("\") Then Exit Sub
|
||||
|
||||
'重复任务检查
|
||||
For Each OngoingLoader In LoaderTaskbar
|
||||
If OngoingLoader.Name <> $"{VersionID} 服务端下载" Then Continue For
|
||||
Hint("该服务端文件正在下载中!", HintType.Critical)
|
||||
Exit Sub
|
||||
Next
|
||||
|
||||
'构造步骤加载器
|
||||
Dim Loaders As New List(Of LoaderBase)
|
||||
'下载
|
||||
Dim Address As New List(Of String)
|
||||
Address.Add(Url)
|
||||
Loaders.Add(New LoaderDownload("下载服务端文件", New List(Of NetFile) From {New NetFile(Address.ToArray, Target, New FileChecker(MinSize:=1024 * 64))}) With {.ProgressWeight = 15})
|
||||
'启动
|
||||
Dim Loader As New LoaderCombo(Of JObject)($"{VersionID} 服务端下载", Loaders) With {.OnStateChanged = AddressOf DownloadStateSave}
|
||||
Loader.Start(Json("downloads")("server"))
|
||||
LoaderTaskbarAdd(Loader)
|
||||
FrmMain.BtnExtraDownload.ShowRefresh()
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
|
||||
Catch ex As Exception
|
||||
Log(ex, "开始服务端文件下载失败", LogLevel.Feedback)
|
||||
End Try
|
||||
End Sub)
|
||||
End If
|
||||
End Sub
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user