mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
replace hutao endpoints
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Control;
|
||||
|
||||
internal interface IScopedPageScopeReferenceTracker
|
||||
{
|
||||
IServiceScope CreateScope();
|
||||
}
|
||||
@@ -28,7 +28,7 @@ internal class ScopedPage : Page
|
||||
{
|
||||
unloadEventHandler = OnUnloaded;
|
||||
Unloaded += unloadEventHandler;
|
||||
currentScope = Ioc.Default.GetRequiredService<ScopedPageScopeReferenceTracker>().CreateScope();
|
||||
currentScope = Ioc.Default.GetRequiredService<IScopedPageScopeReferenceTracker>().CreateScope();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace Snap.Hutao.Control;
|
||||
/// IServiceProvider disposes all injected services when it is disposed.
|
||||
/// </summary>
|
||||
[ConstructorGenerated]
|
||||
[Injection(InjectAs.Singleton)]
|
||||
internal sealed partial class ScopedPageScopeReferenceTracker : IDisposable
|
||||
[Injection(InjectAs.Singleton, typeof(IScopedPageScopeReferenceTracker))]
|
||||
internal sealed partial class ScopedPageScopeReferenceTracker : IScopedPageScopeReferenceTracker, IDisposable
|
||||
{
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ internal sealed class ImageCache : IImageCache, IImageCacheFilePathOperation
|
||||
/// <inheritdoc/>
|
||||
public ValueFile GetFileFromCategoryAndName(string category, string fileName)
|
||||
{
|
||||
Uri dummyUri = Web.HutaoEndpoints.StaticFile(category, fileName).ToUri();
|
||||
Uri dummyUri = Web.HutaoEndpoints.StaticRaw(category, fileName).ToUri();
|
||||
return Path.Combine(GetCacheFolder(), GetCacheFileName(dummyUri));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ internal sealed class AchievementIconConverter : ValueConverter<string, Uri>
|
||||
/// <returns>链接</returns>
|
||||
public static Uri IconNameToUri(string name)
|
||||
{
|
||||
return Web.HutaoEndpoints.StaticFile("AchievementIcon", $"{name}.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("AchievementIcon", $"{name}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Snap.Hutao.Model.Metadata.Converter;
|
||||
internal sealed class AvatarCardConverter : ValueConverter<string, Uri>
|
||||
{
|
||||
private const string CostumeCard = "UI_AvatarIcon_Costume_Card.png";
|
||||
private static readonly Uri UIAvatarIconCostumeCard = Web.HutaoEndpoints.StaticFile("AvatarCard", CostumeCard).ToUri();
|
||||
private static readonly Uri UIAvatarIconCostumeCard = Web.HutaoEndpoints.StaticRaw("AvatarCard", CostumeCard).ToUri();
|
||||
|
||||
/// <summary>
|
||||
/// 名称转Uri
|
||||
@@ -23,7 +23,7 @@ internal sealed class AvatarCardConverter : ValueConverter<string, Uri>
|
||||
{
|
||||
return string.IsNullOrEmpty(name)
|
||||
? UIAvatarIconCostumeCard
|
||||
: Web.HutaoEndpoints.StaticFile("AvatarCard", $"{name}_Card.png").ToUri();
|
||||
: Web.HutaoEndpoints.StaticRaw("AvatarCard", $"{name}_Card.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -18,7 +18,7 @@ internal sealed class AvatarIconConverter : ValueConverter<string, Uri>
|
||||
/// <returns>链接</returns>
|
||||
public static Uri IconNameToUri(string name)
|
||||
{
|
||||
return Web.HutaoEndpoints.StaticFile("AvatarIcon", $"{name}.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("AvatarIcon", $"{name}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -24,7 +24,7 @@ internal sealed class AvatarNameCardPicConverter : ValueConverter<Avatar.Avatar?
|
||||
}
|
||||
|
||||
string avatarName = ReplaceSpecialCaseNaming(avatar.Icon["UI_AvatarIcon_".Length..]);
|
||||
return Web.HutaoEndpoints.StaticFile("NameCardPic", $"UI_NameCardPic_{avatarName}_P.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("NameCardPic", $"UI_NameCardPic_{avatarName}_P.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -18,7 +18,7 @@ internal sealed class AvatarSideIconConverter : ValueConverter<string, Uri>
|
||||
/// <returns>链接</returns>
|
||||
public static Uri IconNameToUri(string name)
|
||||
{
|
||||
return Web.HutaoEndpoints.StaticFile("AvatarIcon", $"{name}.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("AvatarIcon", $"{name}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -45,7 +45,7 @@ internal sealed class ElementNameIconConverter : ValueConverter<string, Uri>
|
||||
|
||||
return string.IsNullOrEmpty(element)
|
||||
? Web.HutaoEndpoints.UIIconNone
|
||||
: Web.HutaoEndpoints.StaticFile("IconElement", $"UI_Icon_Element_{element}.png").ToUri();
|
||||
: Web.HutaoEndpoints.StaticRaw("IconElement", $"UI_Icon_Element_{element}.png").ToUri();
|
||||
|
||||
// $"UI_Icon_Element_{element}.png"
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ internal sealed class EmotionIconConverter : ValueConverter<string, Uri>
|
||||
/// <returns>链接</returns>
|
||||
public static Uri IconNameToUri(string name)
|
||||
{
|
||||
return Web.HutaoEndpoints.StaticFile("EmotionIcon", $"{name}.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("EmotionIcon", $"{name}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -18,7 +18,7 @@ internal sealed class EquipIconConverter : ValueConverter<string, Uri>
|
||||
/// <returns>链接</returns>
|
||||
public static Uri IconNameToUri(string name)
|
||||
{
|
||||
return Web.HutaoEndpoints.StaticFile("EquipIcon", $"{name}.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("EquipIcon", $"{name}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -19,7 +19,7 @@ internal sealed class GachaAvatarIconConverter : ValueConverter<string, Uri>
|
||||
public static Uri IconNameToUri(string name)
|
||||
{
|
||||
string icon = name["UI_AvatarIcon_".Length..];
|
||||
return Web.HutaoEndpoints.StaticFile("GachaAvatarIcon", $"UI_Gacha_AvatarIcon_{icon}.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("GachaAvatarIcon", $"UI_Gacha_AvatarIcon_{icon}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -19,7 +19,7 @@ internal sealed class GachaAvatarImgConverter : ValueConverter<string, Uri>
|
||||
public static Uri IconNameToUri(string name)
|
||||
{
|
||||
string icon = name["UI_AvatarIcon_".Length..];
|
||||
return Web.HutaoEndpoints.StaticFile("GachaAvatarImg", $"UI_Gacha_AvatarImg_{icon}.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("GachaAvatarImg", $"UI_Gacha_AvatarImg_{icon}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -19,7 +19,7 @@ internal sealed class GachaEquipIconConverter : ValueConverter<string, Uri>
|
||||
public static Uri IconNameToUri(string name)
|
||||
{
|
||||
string icon = name["UI_".Length..];
|
||||
return new Uri(Web.HutaoEndpoints.StaticFile("GachaEquipIcon", $"UI_Gacha_{icon}.png"));
|
||||
return new Uri(Web.HutaoEndpoints.StaticRaw("GachaEquipIcon", $"UI_Gacha_{icon}.png"));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -25,7 +25,7 @@ internal sealed class ItemIconConverter : ValueConverter<string, Uri>
|
||||
|
||||
return name.StartsWith("UI_RelicIcon_", StringComparison.Ordinal)
|
||||
? RelicIconConverter.IconNameToUri(name)
|
||||
: Web.HutaoEndpoints.StaticFile("ItemIcon", $"{name}.png").ToUri();
|
||||
: Web.HutaoEndpoints.StaticRaw("ItemIcon", $"{name}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -17,7 +17,7 @@ internal sealed class MonsterIconConverter : ValueConverter<string, Uri>
|
||||
/// <returns>链接</returns>
|
||||
public static Uri IconNameToUri(string name)
|
||||
{
|
||||
return Web.HutaoEndpoints.StaticFile("MonsterIcon", $"{name}.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("MonsterIcon", $"{name}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -21,6 +21,6 @@ internal sealed class QualityConverter : ValueConverter<QualityType, Uri>
|
||||
name = "QUALITY_RED";
|
||||
}
|
||||
|
||||
return Web.HutaoEndpoints.StaticFile("Bg", $"UI_{name}.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("Bg", $"UI_{name}.png").ToUri();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ internal sealed class RelicIconConverter : ValueConverter<string, Uri>
|
||||
/// <returns>链接</returns>
|
||||
public static Uri IconNameToUri(string name)
|
||||
{
|
||||
return Web.HutaoEndpoints.StaticFile("RelicIcon", $"{name}.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("RelicIcon", $"{name}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -24,8 +24,8 @@ internal sealed class SkillIconConverter : ValueConverter<string, Uri>
|
||||
}
|
||||
|
||||
return name.StartsWith("UI_Talent_", StringComparison.Ordinal)
|
||||
? Web.HutaoEndpoints.StaticFile("Talent", $"{name}.png").ToUri()
|
||||
: Web.HutaoEndpoints.StaticFile("Skill", $"{name}.png").ToUri();
|
||||
? Web.HutaoEndpoints.StaticRaw("Talent", $"{name}.png").ToUri()
|
||||
: Web.HutaoEndpoints.StaticRaw("Skill", $"{name}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -29,7 +29,7 @@ internal sealed class WeaponTypeIconConverter : ValueConverter<WeaponType, Uri>
|
||||
_ => throw Must.NeverHappen(),
|
||||
};
|
||||
|
||||
return Web.HutaoEndpoints.StaticFile("Skill", $"Skill_A_{weapon}.png").ToUri();
|
||||
return Web.HutaoEndpoints.StaticRaw("Skill", $"Skill_A_{weapon}.png").ToUri();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -137,7 +137,7 @@ internal sealed partial class DailyNoteNotificationOperation
|
||||
{
|
||||
notifyInfos.Add(new(
|
||||
SH.ServiceDailyNoteNotifierResin,
|
||||
Web.HutaoEndpoints.StaticFile("ItemIcon", "UI_ItemIcon_210.png"),
|
||||
Web.HutaoEndpoints.StaticRaw("ItemIcon", "UI_ItemIcon_210.png"),
|
||||
$"{entry.DailyNote.CurrentResin}",
|
||||
SH.FormatServiceDailyNoteNotifierResinCurrent(entry.DailyNote.CurrentResin)));
|
||||
entry.ResinNotifySuppressed = true;
|
||||
@@ -158,7 +158,7 @@ internal sealed partial class DailyNoteNotificationOperation
|
||||
{
|
||||
notifyInfos.Add(new(
|
||||
SH.ServiceDailyNoteNotifierHomeCoin,
|
||||
Web.HutaoEndpoints.StaticFile("ItemIcon", "UI_ItemIcon_204.png"),
|
||||
Web.HutaoEndpoints.StaticRaw("ItemIcon", "UI_ItemIcon_204.png"),
|
||||
$"{entry.DailyNote.CurrentHomeCoin}",
|
||||
SH.FormatServiceDailyNoteNotifierHomeCoinCurrent(entry.DailyNote.CurrentHomeCoin)));
|
||||
entry.HomeCoinNotifySuppressed = true;
|
||||
@@ -178,7 +178,7 @@ internal sealed partial class DailyNoteNotificationOperation
|
||||
{
|
||||
notifyInfos.Add(new(
|
||||
SH.ServiceDailyNoteNotifierDailyTask,
|
||||
Web.HutaoEndpoints.StaticFile("Bg", "UI_MarkQuest_Events_Proce.png"),
|
||||
Web.HutaoEndpoints.StaticRaw("Bg", "UI_MarkQuest_Events_Proce.png"),
|
||||
SH.ServiceDailyNoteNotifierDailyTaskHint,
|
||||
entry.DailyNote.ExtraTaskRewardDescription));
|
||||
entry.DailyTaskNotifySuppressed = true;
|
||||
@@ -198,7 +198,7 @@ internal sealed partial class DailyNoteNotificationOperation
|
||||
{
|
||||
notifyInfos.Add(new(
|
||||
SH.ServiceDailyNoteNotifierTransformer,
|
||||
Web.HutaoEndpoints.StaticFile("ItemIcon", "UI_ItemIcon_220021.png"),
|
||||
Web.HutaoEndpoints.StaticRaw("ItemIcon", "UI_ItemIcon_220021.png"),
|
||||
SH.ServiceDailyNoteNotifierTransformerAdaptiveHint,
|
||||
SH.ServiceDailyNoteNotifierTransformerHint));
|
||||
entry.TransformerNotifySuppressed = true;
|
||||
@@ -219,7 +219,7 @@ internal sealed partial class DailyNoteNotificationOperation
|
||||
{
|
||||
notifyInfos.Add(new(
|
||||
SH.ServiceDailyNoteNotifierExpedition,
|
||||
Web.HutaoEndpoints.StaticFile("Bg", "UI_Icon_Intee_Explore_1.png"),
|
||||
Web.HutaoEndpoints.StaticRaw("Bg", "UI_Icon_Intee_Explore_1.png"),
|
||||
SH.ServiceDailyNoteNotifierExpeditionAdaptiveHint,
|
||||
SH.ServiceDailyNoteNotifierExpeditionHint));
|
||||
entry.ExpeditionNotifySuppressed = true;
|
||||
|
||||
@@ -73,6 +73,7 @@ internal readonly struct ChannelOptions
|
||||
return $"[ChannelType:{Channel}] [SubChannel:{SubChannel}] [IsOversea: {IsOversea}]";
|
||||
}
|
||||
|
||||
// DO NOT DELETE used in HashSet
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(Channel, SubChannel, IsOversea);
|
||||
|
||||
@@ -10,11 +10,13 @@ internal static class IgnoredInvalidChannelOptions
|
||||
{
|
||||
private static readonly ImmutableHashSet<ChannelOptions> InvalidOptions = new HashSet<ChannelOptions>()
|
||||
{
|
||||
new(ChannelType.Bili, SubChannelType.Official, true),
|
||||
new(ChannelType.Bili, SubChannelType.Default, isOversea: true),
|
||||
new(ChannelType.Bili, SubChannelType.Official, isOversea: true),
|
||||
new(ChannelType.Official, SubChannelType.Google, isOversea: false),
|
||||
}.ToImmutableHashSet();
|
||||
|
||||
public static bool Contains(in ChannelOptions options)
|
||||
{
|
||||
return InvalidOptions.Contains(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ internal class LaunchScheme : IEquatable<ChannelOptions>
|
||||
[SuppressMessage("", "SH002")]
|
||||
public bool Equals(ChannelOptions other)
|
||||
{
|
||||
return Channel == other.Channel && SubChannel == other.SubChannel;
|
||||
return Channel == other.Channel && SubChannel == other.SubChannel && IsOversea == other.IsOversea;
|
||||
}
|
||||
|
||||
public bool ExecutableMatches(string gameFileName)
|
||||
|
||||
@@ -137,7 +137,7 @@ internal sealed partial class MetadataOptions : IOptions<MetadataOptions>
|
||||
public string GetLocalizedRemoteFile(string fileNameWithExtension)
|
||||
{
|
||||
#if DEBUG
|
||||
return Web.HutaoEndpoints.HutaoMetadata2File(LocaleName, fileNameWithExtension);
|
||||
return Web.HutaoEndpoints.Metadata(LocaleName, fileNameWithExtension);
|
||||
#else
|
||||
return Web.HutaoEndpoints.HutaoMetadata2File(LocaleName, fileNameWithExtension);
|
||||
#endif
|
||||
|
||||
@@ -19,24 +19,24 @@ internal sealed class AvatarProperty : ObservableObject, INameIcon, IAlternating
|
||||
{
|
||||
private static readonly FrozenDictionary<FightProperty, Uri> PropertyIcons = new Dictionary<FightProperty, Uri>()
|
||||
{
|
||||
[FightProperty.FIGHT_PROP_SKILL_CD_MINUS_RATIO] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_CDReduce.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_ChargeEfficiency.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_CRITICAL] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_Critical.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_CRITICAL_HURT] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_Critical_Hurt.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_CUR_ATTACK] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_CurAttack.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_CUR_DEFENSE] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_CurDefense.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_ELEMENT_MASTERY] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_Element.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_ELEC_ADD_HURT] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_Element_Electric.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_FIRE_ADD_HURT] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_Element_Fire.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_GRASS_ADD_HURT] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_Element_Grass.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_ICE_ADD_HURT] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_Element_Ice.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_ROCK_ADD_HURT] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_Element_Rock.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_WATER_ADD_HURT] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_Element_Water.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_WIND_ADD_HURT] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_Element_Wind.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_HEAL_ADD] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_Heal.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_MAX_HP] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_MaxHp.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_PHYSICAL_ADD_HURT] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_PhysicalAttackUp.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_SHIELD_COST_MINUS_RATIO] = Web.HutaoEndpoints.StaticFile("Property", "UI_Icon_ShieldCostMinus.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_SKILL_CD_MINUS_RATIO] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_CDReduce.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_ChargeEfficiency.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_CRITICAL] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_Critical.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_CRITICAL_HURT] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_Critical_Hurt.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_CUR_ATTACK] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_CurAttack.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_CUR_DEFENSE] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_CurDefense.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_ELEMENT_MASTERY] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_Element.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_ELEC_ADD_HURT] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_Element_Electric.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_FIRE_ADD_HURT] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_Element_Fire.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_GRASS_ADD_HURT] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_Element_Grass.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_ICE_ADD_HURT] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_Element_Ice.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_ROCK_ADD_HURT] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_Element_Rock.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_WATER_ADD_HURT] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_Element_Water.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_WIND_ADD_HURT] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_Element_Wind.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_HEAL_ADD] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_Heal.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_MAX_HP] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_MaxHp.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_PHYSICAL_ADD_HURT] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_PhysicalAttackUp.png").ToUri(),
|
||||
[FightProperty.FIGHT_PROP_SHIELD_COST_MINUS_RATIO] = Web.HutaoEndpoints.StaticRaw("Property", "UI_Icon_ShieldCostMinus.png").ToUri(),
|
||||
}.ToFrozenDictionary();
|
||||
|
||||
private Brush? background;
|
||||
|
||||
@@ -448,6 +448,11 @@ internal class MiHoYoJSBridge
|
||||
|
||||
private async ValueTask<IJsResult?> TryGetJsResultFromJsParamAsync(JsParam param)
|
||||
{
|
||||
if (coreWebView2.IsDisposed())
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return param.Method switch
|
||||
@@ -472,10 +477,10 @@ internal class MiHoYoJSBridge
|
||||
_ => LogUnhandledMessage("Unhandled Message Type: {Method}", param.Method),
|
||||
};
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
// The dialog is already closed.
|
||||
return null;
|
||||
// TODO: handle Json exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace Snap.Hutao.Web.Enka;
|
||||
internal sealed partial class EnkaClient
|
||||
{
|
||||
private const string EnkaAPI = "https://enka.network/api/uid/{0}";
|
||||
private const string EnkaAPIHutaoForward = "https://enka-api.hut.ao/{0}";
|
||||
|
||||
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
|
||||
private readonly JsonSerializerOptions options;
|
||||
@@ -38,7 +37,7 @@ internal sealed partial class EnkaClient
|
||||
/// <returns>Enka API 响应</returns>
|
||||
public ValueTask<EnkaResponse?> GetForwardDataAsync(in PlayerUid playerUid, CancellationToken token = default)
|
||||
{
|
||||
return TryGetEnkaResponseCoreAsync(string.Format(CultureInfo.CurrentCulture, EnkaAPIHutaoForward, playerUid.Value), token);
|
||||
return TryGetEnkaResponseCoreAsync(HutaoEndpoints.Enka(playerUid), token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -49,7 +48,7 @@ internal sealed partial class EnkaClient
|
||||
/// <returns>Enka API 响应</returns>
|
||||
public ValueTask<EnkaResponse?> GetDataAsync(in PlayerUid playerUid, CancellationToken token = default)
|
||||
{
|
||||
return TryGetEnkaResponseCoreAsync(string.Format(CultureInfo.CurrentCulture, EnkaAPI, playerUid.Value), token);
|
||||
return TryGetEnkaResponseCoreAsync(string.Format(CultureInfo.CurrentCulture, EnkaAPI, playerUid), token);
|
||||
}
|
||||
|
||||
private async ValueTask<EnkaResponse?> TryGetEnkaResponseCoreAsync(string url, CancellationToken token = default)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Web.Hoyolab;
|
||||
using Snap.Hutao.Web.Hutao.GachaLog;
|
||||
|
||||
namespace Snap.Hutao.Web;
|
||||
@@ -196,37 +197,15 @@ internal static class HutaoEndpoints
|
||||
|
||||
#region Metadata
|
||||
|
||||
/// <summary>
|
||||
/// 胡桃元数据文件
|
||||
/// </summary>
|
||||
/// <param name="locale">语言</param>
|
||||
/// <param name="fileName">文件名称</param>
|
||||
/// <returns>路径</returns>
|
||||
public static string HutaoMetadataFile(string locale, string fileName)
|
||||
{
|
||||
return $"{HutaoMetadataSnapGenshinApi}/{locale}/{fileName}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 胡桃元数据2文件
|
||||
/// </summary>
|
||||
/// <param name="locale">语言</param>
|
||||
/// <param name="fileName">文件名称</param>
|
||||
/// <returns>路径</returns>
|
||||
public static string HutaoMetadata2File(string locale, string fileName)
|
||||
public static string Metadata(string locale, string fileName)
|
||||
{
|
||||
return $"{HutaoMetadata2SnapGenshinApi}/Genshin/{locale}/{fileName}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Github 元数据文件
|
||||
/// </summary>
|
||||
/// <param name="locale">语言</param>
|
||||
/// <param name="fileName">文件名称</param>
|
||||
/// <returns>路径</returns>
|
||||
public static string RawGithubUserContentMetadataFile(string locale, string fileName)
|
||||
{
|
||||
return $"{RawGithubUserContentSnapMetadataApi}/Genshin/{locale}/{fileName}";
|
||||
return $"{ApiSnapGenshinMetadata}/Genshin/{locale}/{fileName}";
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -235,17 +214,17 @@ internal static class HutaoEndpoints
|
||||
/// <summary>
|
||||
/// UI_Icon_None
|
||||
/// </summary>
|
||||
public static readonly Uri UIIconNone = StaticFile("Bg", "UI_Icon_None.png").ToUri();
|
||||
public static readonly Uri UIIconNone = StaticRaw("Bg", "UI_Icon_None.png").ToUri();
|
||||
|
||||
/// <summary>
|
||||
/// UI_ItemIcon_None
|
||||
/// </summary>
|
||||
public static readonly Uri UIItemIconNone = StaticFile("Bg", "UI_ItemIcon_None.png").ToUri();
|
||||
public static readonly Uri UIItemIconNone = StaticRaw("Bg", "UI_ItemIcon_None.png").ToUri();
|
||||
|
||||
/// <summary>
|
||||
/// UI_AvatarIcon_Side_None
|
||||
/// </summary>
|
||||
public static readonly Uri UIAvatarIconSideNone = StaticFile("AvatarIcon", "UI_AvatarIcon_Side_None.png").ToUri();
|
||||
public static readonly Uri UIAvatarIconSideNone = StaticRaw("AvatarIcon", "UI_AvatarIcon_Side_None.png").ToUri();
|
||||
|
||||
/// <summary>
|
||||
/// 图片资源
|
||||
@@ -253,9 +232,9 @@ internal static class HutaoEndpoints
|
||||
/// <param name="category">分类</param>
|
||||
/// <param name="fileName">文件名称 包括后缀</param>
|
||||
/// <returns>路径</returns>
|
||||
public static string StaticFile(string category, string fileName)
|
||||
public static string StaticRaw(string category, string fileName)
|
||||
{
|
||||
return $"{StaticSnapGenshinApi}/{category}/{fileName}";
|
||||
return $"{ApiSnapGenshinStaticRaw}/{category}/{fileName}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -265,7 +244,7 @@ internal static class HutaoEndpoints
|
||||
/// <returns>路径</returns>
|
||||
public static string StaticZip(string fileName)
|
||||
{
|
||||
return $"{StaticZipSnapGenshinApi}/{fileName}.zip";
|
||||
return $"{ApiSnapGenshinStaticZip}/{fileName}.zip";
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -274,10 +253,15 @@ internal static class HutaoEndpoints
|
||||
return $"{HomaSnapGenshinApi}/{path}";
|
||||
}
|
||||
|
||||
public static string Enka(in PlayerUid uid)
|
||||
{
|
||||
return $"{ApiSnapGenshinEnka}/{uid}";
|
||||
}
|
||||
|
||||
private const string ApiSnapGenshin = "https://api.snapgenshin.com";
|
||||
private const string ApiSnapGenshinMetadata = $"{ApiSnapGenshin}/metadata";
|
||||
private const string ApiSnapGenshinStaticRaw = $"{ApiSnapGenshin}/static/raw";
|
||||
private const string ApiSnapGenshinStaticZip = $"{ApiSnapGenshin}/static/zip";
|
||||
private const string ApiSnapGenshinEnka = $"{ApiSnapGenshin}/enka";
|
||||
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";
|
||||
private const string RawGithubUserContentSnapMetadataApi = "https://raw.githubusercontent.com/DGP-Studio/Snap.Metadata/main";
|
||||
private const string StaticSnapGenshinApi = "https://static.snapgenshin.com";
|
||||
private const string StaticZipSnapGenshinApi = "https://static-zip.snapgenshin.com";
|
||||
}
|
||||
Reference in New Issue
Block a user