diff --git a/src/Starward.Core/Gacha/StarRail/StarRailGachaItem.cs b/src/Starward.Core/Gacha/StarRail/StarRailGachaItem.cs index b94bc7a31..b4a18e041 100644 --- a/src/Starward.Core/Gacha/StarRail/StarRailGachaItem.cs +++ b/src/Starward.Core/Gacha/StarRail/StarRailGachaItem.cs @@ -1,12 +1,12 @@ -using System.Text.Json.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; namespace Starward.Core.Gacha.StarRail; public class StarRailGachaItem : GachaLogItem { - [JsonPropertyName("gacha_id")] - [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)] + [JsonIgnore] public int GachaId { get; set; } @@ -15,3 +15,31 @@ public class StarRailGachaItem : GachaLogItem } +public class StarRailGachaItemConverter : JsonConverter +{ + public override StarRailGachaItem Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + var jsonObject = JsonDocument.ParseValue(ref reader).RootElement; + var gachaItem = (JsonSerializer.Deserialize(jsonObject.GetRawText()) ?? new StarRailGachaItem()); + if (jsonObject.TryGetProperty("gacha_id", out var gachaIdProp)) + if (gachaIdProp.ValueKind == JsonValueKind.String && string.IsNullOrEmpty(gachaIdProp.GetString())) + gachaItem.GachaId = gachaItem.GachaType switch + { + 1 => 1001, + 2 => 4001, + 11 => 2003, + 12 => 3003, + _ => 1001, + }; + else + gachaItem.GachaId = gachaIdProp.GetInt32(); + + return gachaItem; + } + + public override void Write(Utf8JsonWriter writer, StarRailGachaItem value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value, options); + } +} + diff --git a/src/Starward.Language/Lang.Designer.cs b/src/Starward.Language/Lang.Designer.cs index e09cbee61..0d1e5ec44 100644 --- a/src/Starward.Language/Lang.Designer.cs +++ b/src/Starward.Language/Lang.Designer.cs @@ -4782,5 +4782,14 @@ public static string UpdateWindow_DisplayUpdateContentAfterRestart { return ResourceManager.GetString("UpdateWindow_DisplayUpdateContentAfterRestart", resourceCulture); } } + + /// + /// 查找类似 Import {0} signal search(es) successfully. 的本地化字符串。 + /// + public static string ZZZGachaService_ImportSignalSearchSuccessfully { + get { + return ResourceManager.GetString("ZZZGachaService_ImportSignalSearchSuccessfully", resourceCulture); + } + } } } diff --git a/src/Starward.Language/Lang.resx b/src/Starward.Language/Lang.resx index 3ab7ae441..d6af92516 100644 --- a/src/Starward.Language/Lang.resx +++ b/src/Starward.Language/Lang.resx @@ -1719,4 +1719,7 @@ Do you accept the risk and continue to use it? Keep RPC service running in the background + + Import {0} signal search(es) successfully. + \ No newline at end of file diff --git a/src/Starward.Language/Lang.zh-CN.resx b/src/Starward.Language/Lang.zh-CN.resx index e79823135..fe4852933 100644 --- a/src/Starward.Language/Lang.zh-CN.resx +++ b/src/Starward.Language/Lang.zh-CN.resx @@ -1716,5 +1716,8 @@ 指定时间段 - + + + 成功导入调频记录 {0} 条 + \ No newline at end of file diff --git a/src/Starward.Language/Lang.zh-TW.resx b/src/Starward.Language/Lang.zh-TW.resx index e1607eb55..29422696e 100644 --- a/src/Starward.Language/Lang.zh-TW.resx +++ b/src/Starward.Language/Lang.zh-TW.resx @@ -1324,7 +1324,7 @@ 驗證失敗 - 目前版本不是最新版本({0})。 + 目前版本不是最新版本({0})。 按下按鈕修復檔案 @@ -1609,4 +1609,7 @@ Other Rewards + + 成功匯入 {0} 條調頻記錄 + \ No newline at end of file diff --git a/src/Starward/Features/Gacha/GachaLogPage.xaml b/src/Starward/Features/Gacha/GachaLogPage.xaml index 4cfa6d634..6c4a1051f 100644 --- a/src/Starward/Features/Gacha/GachaLogPage.xaml +++ b/src/Starward/Features/Gacha/GachaLogPage.xaml @@ -160,6 +160,7 @@ +