2.12.8.1
This commit is contained in:
@@ -149,7 +149,7 @@
|
||||
RunInThread(
|
||||
Sub()
|
||||
Try
|
||||
Hint("正在刷新头像……")
|
||||
Hint("正在刷新皮肤……")
|
||||
'清空缓存
|
||||
Logger.Info("正在清空皮肤缓存")
|
||||
If DirectoryUtils.Exists(PathTemp & "Cache\Skin") Then DirectoryUtils.Delete(PathTemp & "Cache\Skin")
|
||||
@@ -162,7 +162,7 @@
|
||||
For Each SkinLoader In If(sender IsNot Nothing, {sender}, {PageLaunchLeft.SkinLegacy, PageLaunchLeft.SkinMs})
|
||||
SkinLoader.WaitForExit(IsForceRestart:=True)
|
||||
Next
|
||||
Hint("已刷新头像!", HintType.Green)
|
||||
Hint("已刷新皮肤!", HintType.Green)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, "刷新皮肤缓存失败", LogBehavior.Alert)
|
||||
End Try
|
||||
@@ -216,13 +216,13 @@
|
||||
Hint("登录失败,无法更改披风!", HintType.Red)
|
||||
Return
|
||||
End If
|
||||
Hint("正在获取披风列表,请稍候……")
|
||||
If McLoginMsLoader.State <> LoadState.Finished Then Hint("正在获取披风列表,请稍候……")
|
||||
IsChanging = True
|
||||
'开始实际获取
|
||||
RunInNewThread(
|
||||
Sub()
|
||||
Try
|
||||
Retry:
|
||||
Try
|
||||
'获取登录信息
|
||||
If McLoginMsLoader.State <> LoadState.Finished Then McLoginMsLoader.WaitForExit(PageLoginMsSkin.GetLoginData())
|
||||
If McLoginMsLoader.State <> LoadState.Finished Then
|
||||
@@ -256,7 +256,7 @@ Retry:
|
||||
Next
|
||||
SelectedIndex = MyMsgBoxSelect(SelectionControl, "选择披风", "确定", "取消")
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, "获取玩家披风列表失败")
|
||||
Logger.Error(ex, "获取玩家皮肤列表失败")
|
||||
End Try
|
||||
End Sub)
|
||||
If SelectedIndex Is Nothing Then Return
|
||||
@@ -279,7 +279,29 @@ Retry:
|
||||
McLoginMsLoader.Output.ProfileJson = SkinData.ToString()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, "更改披风失败", LogBehavior.Toast)
|
||||
If TypeOf ex Is HttpRequestCodeException Then
|
||||
Dim requestException As HttpRequestCodeException = CType(ex, HttpRequestCodeException)
|
||||
Select Case requestException.StatusCode
|
||||
Case HttpStatusCode.BadRequest
|
||||
Logger.Warn(ex, "更改披风时遭遇 400 错误")
|
||||
If requestException.Response?.Contains("""error""") Then
|
||||
Hint("更改披风失败:" & GetJson(requestException.Response)("error").ToString, HintType.Red)
|
||||
Return
|
||||
ElseIf requestException.Response?.Contains("""errorMessage""") Then
|
||||
Hint("更改披风失败:" & GetJson(requestException.Response)("errorMessage").ToString, HintType.Red)
|
||||
Return
|
||||
End If
|
||||
Case HttpStatusCode.Unauthorized
|
||||
Logger.Warn(ex, "更改披风时遭遇 401 错误")
|
||||
Hint("正在重新登录,将在登录后自动更改披风……")
|
||||
McLoginMsLoader.Start(PageLoginMsSkin.GetLoginData(), IsForceRestart:=True)
|
||||
GoTo Retry
|
||||
End Select
|
||||
ElseIf ex.IsBadNetwork Then
|
||||
Hint("更改披风失败:连接 Mojang 服务器超时,请稍后再试,或使用 VPN 改善网络环境", HintType.Red)
|
||||
Else
|
||||
Logger.Error(ex, "更改披风失败", LogBehavior.Toast)
|
||||
End If
|
||||
Finally
|
||||
IsChanging = False
|
||||
End Try
|
||||
|
||||
@@ -170,7 +170,7 @@ Public Class PageLaunchRight
|
||||
Settings.Set("CacheSavedPageVersion", Version)
|
||||
FileUtils.Write(PathTemp & "Cache\Custom.xaml", FileContent)
|
||||
'若内容变更则要求刷新
|
||||
If LoadedContentHash <> FileContent.GetHashCode() AndAlso ShouldRefresh Then Refresh()
|
||||
If LoadedContentHash <> FileContent.GetStableHashCode() AndAlso ShouldRefresh Then Refresh()
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, $"下载主页失败({Address})", If(ModeDebug, LogBehavior.Alert, LogBehavior.Toast))
|
||||
End Try
|
||||
@@ -196,7 +196,7 @@ Public Class PageLaunchRight
|
||||
''' 清空主页缓存信息。
|
||||
''' </summary>
|
||||
Private Sub ClearCache()
|
||||
LoadedContentHash = -1
|
||||
LoadedContentHash = Nothing
|
||||
OnlineLoader.Input = ("", True)
|
||||
Settings.Set("CacheSavedPageUrl", "")
|
||||
Settings.Set("CacheSavedPageVersion", "")
|
||||
@@ -211,7 +211,7 @@ Public Class PageLaunchRight
|
||||
Try
|
||||
SyncLock LoadContentLock
|
||||
'如果加载目标内容一致则不加载
|
||||
Dim Hash = If(Content, "").GetHashCode()
|
||||
Dim Hash = If(Content, "").GetStableHashCode()
|
||||
If Hash = LoadedContentHash Then Return
|
||||
LoadedContentHash = Hash
|
||||
'实际加载内容
|
||||
@@ -261,7 +261,7 @@ Public Class PageLaunchRight
|
||||
OnLoadContentFailed(e.Exception)
|
||||
End Sub
|
||||
|
||||
Private LoadedContentHash As Integer = -1
|
||||
Private LoadedContentHash As ULong? = Nothing
|
||||
Private LoadContentLock As New Object
|
||||
|
||||
#End Region
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
<local:MyIconButton.ContextMenu>
|
||||
<ContextMenu Closed="HidePanel" HorizontalOffset="10" VerticalOffset="18">
|
||||
<local:MyMenuItem Click="BtnSkinEdit_Click" Header="修改皮肤"/>
|
||||
<local:MyMenuItem Click="BtnSkinRefresh_Click" Header="刷新皮肤"/>
|
||||
<local:MyMenuItem Click="BtnSkinSave_Click" Header="保存皮肤文件"/>
|
||||
<Separator />
|
||||
<local:MyMenuItem Click="BtnSkinCape_Click" Header="修改披风"/>
|
||||
<Separator />
|
||||
<local:MyMenuItem Click="BtnSkinRefresh_Click" Header="刷新"/>
|
||||
<local:MyMenuItem Click="BtnSkinCapeRefresh_Click" Header="刷新披风列表"/>
|
||||
</ContextMenu>
|
||||
</local:MyIconButton.ContextMenu>
|
||||
</local:MyIconButton>
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
''' <summary>
|
||||
''' 获取当前页面的登录信息。
|
||||
''' </summary>
|
||||
Public Shared Function GetLoginData(Optional IgnoreState As Boolean = False) As McLoginMs
|
||||
If IgnoreState OrElse McLoginMsLoader.State = LoadState.Finished Then
|
||||
Public Shared Function GetLoginData() As McLoginMs
|
||||
If McLoginMsLoader.State = LoadState.Finished Then
|
||||
Return New McLoginMs With {.OAuthRefreshToken = Settings.Get(Of String)("CacheMsV2OAuthRefresh"), .UserName = Settings.Get(Of String)("CacheMsV2Name"), .AccessToken = Settings.Get(Of String)("CacheMsV2Access"), .Uuid = Settings.Get(Of String)("CacheMsV2Uuid"), .ProfileJson = Settings.Get(Of String)("CacheMsV2ProfileJson")}
|
||||
Else
|
||||
Return New McLoginMs With {.OAuthRefreshToken = Settings.Get(Of String)("CacheMsV2OAuthRefresh"), .UserName = Settings.Get(Of String)("CacheMsV2Name")}
|
||||
@@ -105,9 +105,6 @@ Retry:
|
||||
Hint("正在重新登录,将在登录后自动更改皮肤……")
|
||||
McLoginMsLoader.Start(GetLoginData(), IsForceRestart:=True)
|
||||
GoTo Retry
|
||||
ElseIf Result.Contains("""error""") Then
|
||||
Hint("更改皮肤失败:" & GetJson(Result)("error").ToString, HintType.Red)
|
||||
Return
|
||||
End If
|
||||
'获取新皮肤地址
|
||||
Logger.Info($"皮肤修改返回值:{vbCrLf}{Result}")
|
||||
@@ -121,13 +118,26 @@ Retry:
|
||||
Next
|
||||
Throw New Exception("未知错误(" & Result & ")")
|
||||
Catch ex As Exception
|
||||
If ex.IsBadNetwork Then
|
||||
Hint("更改皮肤失败:连接皮肤服务器超时,请稍后再试,或使用 VPN 改善网络环境", HintType.Red)
|
||||
ElseIf TypeOf ex Is HttpRequestCodeException AndAlso CType(ex, HttpRequestCodeException).StatusCode = HttpStatusCode.Unauthorized Then
|
||||
Logger.Warn(ex, "更改皮肤时遭遇 401 错误")
|
||||
Hint("正在重新登录,将在登录后自动更改皮肤……")
|
||||
McLoginMsLoader.Start(GetLoginData(), IsForceRestart:=True)
|
||||
GoTo Retry
|
||||
If TypeOf ex Is HttpRequestCodeException Then
|
||||
Dim requestException As HttpRequestCodeException = CType(ex, HttpRequestCodeException)
|
||||
Select Case requestException.StatusCode
|
||||
Case HttpStatusCode.BadRequest
|
||||
Logger.Warn(ex, "更改皮肤时遭遇 400 错误")
|
||||
If requestException.Response?.Contains("""error""") Then
|
||||
Hint("更改皮肤失败:" & GetJson(requestException.Response)("error").ToString, HintType.Red)
|
||||
Return
|
||||
ElseIf requestException.Response?.Contains("""errorMessage""") Then
|
||||
Hint("更改皮肤失败:" & GetJson(requestException.Response)("errorMessage").ToString, HintType.Red)
|
||||
Return
|
||||
End If
|
||||
Case HttpStatusCode.Unauthorized
|
||||
Logger.Warn(ex, "更改皮肤时遭遇 401 错误")
|
||||
Hint("正在重新登录,将在登录后自动更改皮肤……")
|
||||
McLoginMsLoader.Start(GetLoginData(), IsForceRestart:=True)
|
||||
GoTo Retry
|
||||
End Select
|
||||
ElseIf ex.IsBadNetwork Then
|
||||
Hint("更改皮肤失败:连接 Mojang 服务器超时,请稍后再试,或使用 VPN 改善网络环境", HintType.Red)
|
||||
Else
|
||||
Logger.Error(ex, "更改皮肤失败", LogBehavior.Toast)
|
||||
End If
|
||||
@@ -151,6 +161,24 @@ Retry:
|
||||
Skin.BtnSkinCape_Click()
|
||||
End Sub
|
||||
|
||||
'刷新披风
|
||||
Public Sub BtnSkinCapeRefresh_Click(sender As Object, e As RoutedEventArgs)
|
||||
RunInThread(
|
||||
Sub()
|
||||
Try
|
||||
Hint("正在刷新披风列表……")
|
||||
If McLaunchLoader.State = LoadState.Loading Then
|
||||
McLoginMsLoader.WaitForExit()
|
||||
Else
|
||||
McLoginMsLoader.WaitForExit(GetLoginData(), IsForceRestart:=True)
|
||||
End If
|
||||
Hint("已刷新披风列表!", HintType.Green)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, "刷新披风列表失败", LogBehavior.Toast)
|
||||
End Try
|
||||
End Sub)
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user