mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
code style
This commit is contained in:
@@ -6,6 +6,7 @@ using Snap.Hutao.Factory.ContentDialog;
|
||||
using Snap.Hutao.Service.Hutao;
|
||||
using Snap.Hutao.Service.Notification;
|
||||
using Snap.Hutao.View.Dialog;
|
||||
using Snap.Hutao.Web;
|
||||
using Snap.Hutao.Web.Hutao;
|
||||
using Snap.Hutao.Web.Response;
|
||||
using Windows.System;
|
||||
@@ -28,7 +29,7 @@ internal sealed partial class HutaoPassportViewModel : Abstraction.ViewModel
|
||||
[Command("OpenRedeemWebsiteCommand")]
|
||||
private static async Task OpenRedeemWebsiteAsync()
|
||||
{
|
||||
await Launcher.LaunchUriAsync("https://homa.snapgenshin.com/redeem.html".ToUri());
|
||||
await Launcher.LaunchUriAsync(HutaoEndpoints.Website("redeem.html").ToUri());
|
||||
}
|
||||
|
||||
[Command("RegisterCommand")]
|
||||
@@ -50,7 +51,7 @@ internal sealed partial class HutaoPassportViewModel : Abstraction.ViewModel
|
||||
|
||||
if (response.IsOk())
|
||||
{
|
||||
infoBarService.Information(response.GetLocalizationMessageOrDefault()!);
|
||||
infoBarService.Information(response.GetLocalizationMessageOrMessage());
|
||||
await hutaoUserOptions.PostLoginSucceedAsync(homaPassportClient, taskContext, username, password, response.Data).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -75,7 +76,7 @@ internal sealed partial class HutaoPassportViewModel : Abstraction.ViewModel
|
||||
|
||||
if (response.IsOk())
|
||||
{
|
||||
infoBarService.Information(response.GetLocalizationMessageOrDefault()!);
|
||||
infoBarService.Information(response.GetLocalizationMessageOrMessage());
|
||||
|
||||
await taskContext.SwitchToMainThreadAsync();
|
||||
hutaoUserOptions.LogoutOrUnregister();
|
||||
@@ -102,7 +103,7 @@ internal sealed partial class HutaoPassportViewModel : Abstraction.ViewModel
|
||||
|
||||
if (response.IsOk())
|
||||
{
|
||||
infoBarService.Information(response.GetLocalizationMessageOrDefault()!);
|
||||
infoBarService.Information(response.GetLocalizationMessageOrMessage());
|
||||
await hutaoUserOptions.PostLoginSucceedAsync(homaPassportClient, taskContext, username, password, response.Data).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -112,8 +113,6 @@ internal sealed partial class HutaoPassportViewModel : Abstraction.ViewModel
|
||||
private void LogoutAsync()
|
||||
{
|
||||
hutaoUserOptions.LogoutOrUnregister();
|
||||
LocalSetting.Set(SettingKeys.PassportUserName, string.Empty);
|
||||
LocalSetting.Set(SettingKeys.PassportPassword, string.Empty);
|
||||
}
|
||||
|
||||
[Command("ResetPasswordCommand")]
|
||||
@@ -135,7 +134,7 @@ internal sealed partial class HutaoPassportViewModel : Abstraction.ViewModel
|
||||
|
||||
if (response.IsOk())
|
||||
{
|
||||
infoBarService.Information(response.GetLocalizationMessageOrDefault()!);
|
||||
infoBarService.Information(response.GetLocalizationMessageOrMessage());
|
||||
await hutaoUserOptions.PostLoginSucceedAsync(homaPassportClient, taskContext, username, password, response.Data).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,12 @@ internal static class LocalizableResponseExtension
|
||||
return SH.ResourceManager.GetString(key, CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
public static string GetLocalizationMessageOrMessage<TResponse>(this TResponse localizableResponse)
|
||||
where TResponse : Response.Response, ILocalizableResponse
|
||||
{
|
||||
return localizableResponse.GetLocalizationMessageOrDefault() ?? localizableResponse.Message;
|
||||
}
|
||||
|
||||
public static string GetLocalizationMessage(this ILocalizableResponse localizableResponse)
|
||||
{
|
||||
string? key = localizableResponse.LocalizationKey;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Web.Hutao.GachaLog;
|
||||
using System.Data.SqlTypes;
|
||||
|
||||
namespace Snap.Hutao.Web;
|
||||
|
||||
@@ -269,6 +270,11 @@ internal static class HutaoEndpoints
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static string Website(string path)
|
||||
{
|
||||
return $"{HomaSnapGenshinApi}/{path}";
|
||||
}
|
||||
|
||||
private const string HomaSnapGenshinApi = "https://homa.snapgenshin.com";
|
||||
private const string HutaoMetadataSnapGenshinApi = "https://hutao-metadata.snapgenshin.com";
|
||||
private const string HutaoMetadata2SnapGenshinApi = "https://hutao-metadata2.snapgenshin.com";
|
||||
|
||||
Reference in New Issue
Block a user