From 523b496daa149c8bc4dfdbff2de7b3d02a64d1f4 Mon Sep 17 00:00:00 2001 From: MistEO Date: Tue, 9 Sep 2025 00:12:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20wpf=20gui=20?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=20resource=20path=20=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/14044 --- src/MaaWpfGui/Helper/DataHelper.cs | 6 +++--- .../Settings/VersionUpdateSettingsUserControlModel.cs | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/MaaWpfGui/Helper/DataHelper.cs b/src/MaaWpfGui/Helper/DataHelper.cs index 1a60f542aa..be118b1cff 100644 --- a/src/MaaWpfGui/Helper/DataHelper.cs +++ b/src/MaaWpfGui/Helper/DataHelper.cs @@ -78,13 +78,13 @@ namespace MaaWpfGui.Helper private static void LoadBattleData() { - const string FilePath = "resource/battle_data.json"; - if (!File.Exists(FilePath)) + string filePath = Path.Combine(AsstProxy.MainResourcePath(), "resource/battle_data.json"); + if (!File.Exists(filePath)) { return; } - string jsonText = File.ReadAllText(FilePath); + string jsonText = File.ReadAllText(filePath); var characterData = JsonConvert.DeserializeObject>(JObject.Parse(jsonText)["chars"]?.ToString() ?? string.Empty) ?? []; var characterNamesLangAdd = GetCharacterNamesAddAction(ConfigurationHelper.GetGlobalValue(ConfigurationKeys.Localization, LocalizationHelper.DefaultLanguage)); diff --git a/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs index bb898240a1..459c877cfe 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs @@ -24,6 +24,7 @@ using JetBrains.Annotations; using MaaWpfGui.Constants; using MaaWpfGui.Extensions; using MaaWpfGui.Helper; +using MaaWpfGui.Main; using MaaWpfGui.Models; using MaaWpfGui.Properties; using MaaWpfGui.Services; @@ -157,13 +158,13 @@ public class VersionUpdateSettingsUserControlModel : PropertyChangedBase { bool isDefaultClient = new HashSet { string.Empty, "Official", "Bilibili" }.Contains(clientType); - const string DefaultJsonPath = "resource/version.json"; + string defaultJsonPath = Path.Combine(AsstProxy.MainResourcePath(), "resource/version.json"); var jsonPath = isDefaultClient - ? DefaultJsonPath + ? defaultJsonPath : $"resource/global/{clientType}/resource/version.json"; string versionName; - if (!File.Exists(DefaultJsonPath) || (!isDefaultClient && !File.Exists(jsonPath))) + if (!File.Exists(defaultJsonPath) || (!isDefaultClient && !File.Exists(jsonPath))) { return (DateTime.MinValue, string.Empty); } @@ -174,7 +175,7 @@ public class VersionUpdateSettingsUserControlModel : PropertyChangedBase var activityTime = (ulong?)versionJson?["activity"]?["time"]; // 活动的开始时间 var lastUpdated = isDefaultClient ? (string?)versionJson?["last_updated"] - : (string?)LoadJson(DefaultJsonPath)?["last_updated"]; + : (string?)LoadJson(defaultJsonPath)?["last_updated"]; var dateTime = lastUpdated == null ? DateTime.MinValue