From 3df70a5feb1337b4b5c2950cdc08a823ddc66a6e Mon Sep 17 00:00:00 2001 From: qhy040404 Date: Tue, 19 Dec 2023 23:31:05 +0800 Subject: [PATCH] impl #1112 (part 2) setting --- .../Model/Entity/SettingEntry.Constant.cs | 2 ++ .../Snap.Hutao/Resource/Localization/SH.resx | 6 ++++++ src/Snap.Hutao/Snap.Hutao/Service/AppOptions.cs | 10 ++++++++++ .../Snap.Hutao/View/Page/SettingPage.xaml | 11 +++++++++++ .../ViewModel/Setting/SettingViewModel.cs | 14 ++++++++++++++ .../Snap.Hutao/Web/Hoyolab/RegionType.cs | 15 +++++++++++++++ 6 files changed, 58 insertions(+) create mode 100644 src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/RegionType.cs diff --git a/src/Snap.Hutao/Snap.Hutao/Model/Entity/SettingEntry.Constant.cs b/src/Snap.Hutao/Snap.Hutao/Model/Entity/SettingEntry.Constant.cs index b18f0ef8..76338c22 100644 --- a/src/Snap.Hutao/Snap.Hutao/Model/Entity/SettingEntry.Constant.cs +++ b/src/Snap.Hutao/Snap.Hutao/Model/Entity/SettingEntry.Constant.cs @@ -127,4 +127,6 @@ internal sealed partial class SettingEntry /// 自定义极验接口 /// public const string GeetestCustomCompositeUrl = "GeetestCustomCompositeUrl"; + + public const string RegionType = "RegionType"; } diff --git a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx index 4a0d4ea4..3962d02a 100644 --- a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx +++ b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx @@ -2306,6 +2306,12 @@ 无感验证 + + 选择想要获取公告的游戏服务器 + + + 公告所属服务器 + 管理主页仪表板中的卡片 diff --git a/src/Snap.Hutao/Snap.Hutao/Service/AppOptions.cs b/src/Snap.Hutao/Snap.Hutao/Service/AppOptions.cs index aeb46ccc..6c9c7965 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/AppOptions.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/AppOptions.cs @@ -6,6 +6,7 @@ using Snap.Hutao.Core.Windowing; using Snap.Hutao.Model; using Snap.Hutao.Model.Entity; using Snap.Hutao.Service.Abstraction; +using Snap.Hutao.Web.Hoyolab; using System.Globalization; using System.IO; @@ -19,6 +20,7 @@ internal sealed partial class AppOptions : DbStoreOptions private bool? isEmptyHistoryWishVisible; private BackdropType? backdropType; private CultureInfo? currentCulture; + private RegionType? regionType; private string? geetestCustomCompositeUrl; public string PowerShellPath @@ -72,6 +74,14 @@ internal sealed partial class AppOptions : DbStoreOptions set => SetOption(ref currentCulture, SettingEntry.Culture, value, value => value.Name); } + public List> RegionTypes { get; } = CollectionsNameValue.FromEnum(); + + public RegionType RegionType + { + get => GetOption(ref regionType, SettingEntry.RegionType, v => Enum.Parse(v), RegionType.CN_GF01).Value; + set => SetOption(ref regionType, SettingEntry.RegionType, value, value => value.ToStringOrEmpty()); + } + public string GeetestCustomCompositeUrl { get => GetOption(ref geetestCustomCompositeUrl, SettingEntry.GeetestCustomCompositeUrl); diff --git a/src/Snap.Hutao/Snap.Hutao/View/Page/SettingPage.xaml b/src/Snap.Hutao/Snap.Hutao/View/Page/SettingPage.xaml index 090bf170..d35822a4 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Page/SettingPage.xaml +++ b/src/Snap.Hutao/Snap.Hutao/View/Page/SettingPage.xaml @@ -305,6 +305,17 @@ + + + + + ? selectedBackdropType; private NameValue? selectedCulture; + private NameValue? selectedRegionType; private IPInformation? ipInformation; private FolderViewModel? cacheFolderView; private FolderViewModel? dataFolderView; @@ -104,6 +106,18 @@ internal sealed partial class SettingViewModel : Abstraction.ViewModel } } + public NameValue? SelectedRegionType + { + get => selectedRegionType ??= AppOptions.RegionTypes.Single(t => t.Value == AppOptions.RegionType); + set + { + if (SetProperty(ref selectedRegionType, value) && value is not null) + { + AppOptions.RegionType = value.Value; + } + } + } + public FolderViewModel? CacheFolderView { get => cacheFolderView; set => SetProperty(ref cacheFolderView, value); } public FolderViewModel? DataFolderView { get => dataFolderView; set => SetProperty(ref dataFolderView, value); } diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/RegionType.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/RegionType.cs new file mode 100644 index 00000000..565aa9c3 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/RegionType.cs @@ -0,0 +1,15 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +namespace Snap.Hutao.Web.Hoyolab; + +[HighQuality] +internal enum RegionType +{ + CN_GF01 = 1, + CN_QD01 = 5, + OS_USA = 6, + OS_EURO = 7, + OS_ASIA = 8, + OS_CHT = 9, +}