diff --git a/Pixiview/App.cs b/Pixiview/App.cs index b944ea3..461bbb3 100644 --- a/Pixiview/App.cs +++ b/Pixiview/App.cs @@ -26,6 +26,7 @@ namespace Pixiview private void InitPreferences() { + Configs.IsOnR18 = Preferences.Get(Configs.IsOnR18Key, false); var isProxied = Preferences.Get(Configs.IsProxiedKey, false); if (isProxied) { diff --git a/Pixiview/Illust/FavoritesPage.xaml.cs b/Pixiview/Illust/FavoritesPage.xaml.cs index c1a48a6..e3673a4 100644 --- a/Pixiview/Illust/FavoritesPage.xaml.cs +++ b/Pixiview/Illust/FavoritesPage.xaml.cs @@ -17,10 +17,6 @@ namespace Pixiview.Illust protected override bool IsFavoriteVisible => false; - public override void OnUnload() - { - } - protected override void OnAppearing() { //base.OnAppearing(); diff --git a/Pixiview/Illust/IllustCollectionPage.cs b/Pixiview/Illust/IllustCollectionPage.cs index 8fd8bab..e1bf2cd 100644 --- a/Pixiview/Illust/IllustCollectionPage.cs +++ b/Pixiview/Illust/IllustCollectionPage.cs @@ -443,7 +443,8 @@ namespace Pixiview.Illust lastUpdated = now; } - var data = DoGetIllustList(illustData).Where(i => i != null); + var r18 = Configs.IsOnR18; + var data = DoGetIllustList(illustData).Where(i => i != null && (r18 || !i.IsRestrict)); var collection = new IllustCollection(data); if (IsFavoriteVisible) diff --git a/Pixiview/Illust/RecommendsPage.xaml b/Pixiview/Illust/RecommendsPage.xaml index ecf6382..e9d8789 100644 --- a/Pixiview/Illust/RecommendsPage.xaml +++ b/Pixiview/Illust/RecommendsPage.xaml @@ -14,7 +14,7 @@ - diff --git a/Pixiview/Illust/RecommendsPage.xaml.cs b/Pixiview/Illust/RecommendsPage.xaml.cs index 3a9014b..2768da8 100644 --- a/Pixiview/Illust/RecommendsPage.xaml.cs +++ b/Pixiview/Illust/RecommendsPage.xaml.cs @@ -15,6 +15,8 @@ namespace Pixiview.Illust nameof(Users), typeof(List), typeof(RecommendsPage)); public static readonly BindableProperty UserColumnsProperty = BindableProperty.Create( nameof(UserColumns), typeof(int), typeof(RecommendsPage), 1); + public static readonly BindableProperty UserRecommendsVisibleProperty = BindableProperty.Create( + nameof(UserRecommendsVisible), typeof(bool), typeof(RecommendsPage)); public List Users { @@ -26,6 +28,11 @@ namespace Pixiview.Illust get => (int)GetValue(UserColumnsProperty); set => SetValue(UserColumnsProperty, value); } + public bool UserRecommendsVisible + { + get => (bool)GetValue(UserRecommendsVisibleProperty); + set => SetValue(UserRecommendsVisibleProperty, value); + } private readonly Command commandUserTapped; @@ -200,6 +207,7 @@ namespace Pixiview.Illust private void DoLoadUserRecommendsData(IllustData data) { + var r18 = Configs.IsOnR18; var defaultImage = StyleDefinition.DownloadBackground; var users = data.body.page.recommendUser.Select(u => { @@ -229,6 +237,15 @@ namespace Pixiview.Illust item3 = data.body.thumbnails.illust.FirstOrDefault(l => l.illustId == id)?.ConvertToItem(defaultImage); } } + if (!r18) + { + if (item1?.IsRestrict == true || + item2?.IsRestrict == true || + item3?.IsRestrict == true) + { + return null; + } + } return new IllustUserItem { UserId = usrId, @@ -238,9 +255,10 @@ namespace Pixiview.Illust Image2Item = item2, Image3Item = item3 }; - }); + }).Where(u => u != null); var list = new List(users); + UserRecommendsVisible = list.Count > 0; Users = list; Illusts = IllustCollection; diff --git a/Pixiview/OptionPage.xaml b/Pixiview/OptionPage.xaml index 9baf3ee..67d45df 100644 --- a/Pixiview/OptionPage.xaml +++ b/Pixiview/OptionPage.xaml @@ -8,6 +8,10 @@ + + + diff --git a/Pixiview/OptionPage.xaml.cs b/Pixiview/OptionPage.xaml.cs index fdad41c..770e9d9 100644 --- a/Pixiview/OptionPage.xaml.cs +++ b/Pixiview/OptionPage.xaml.cs @@ -7,6 +7,8 @@ namespace Pixiview { public partial class OptionPage : AdaptedPage { + public static readonly BindableProperty IsOnR18Property = BindableProperty.Create( + nameof(IsOnR18), typeof(bool), typeof(OptionPage)); public static readonly BindableProperty IsProxiedProperty = BindableProperty.Create( nameof(IsProxied), typeof(bool), typeof(OptionPage)); public static readonly BindableProperty HostProperty = BindableProperty.Create( @@ -14,6 +16,11 @@ namespace Pixiview public static readonly BindableProperty PortProperty = BindableProperty.Create( nameof(Port), typeof(string), typeof(OptionPage)); + public bool IsOnR18 + { + get => (bool)GetValue(IsOnR18Property); + set => SetValue(IsOnR18Property, value); + } public bool IsProxied { get => (bool)GetValue(IsProxiedProperty); @@ -40,6 +47,7 @@ namespace Pixiview { base.OnAppearing(); + IsOnR18 = Preferences.Get(Configs.IsOnR18Key, false); IsProxied = Preferences.Get(Configs.IsProxiedKey, false); Host = Preferences.Get(Configs.HostKey, string.Empty); int pt = Preferences.Get(Configs.PortKey, 0); @@ -53,9 +61,14 @@ namespace Pixiview { base.OnDisappearing(); + var r18 = IsOnR18; var proxied = IsProxied; var h = Host?.Trim(); + Preferences.Set(Configs.IsOnR18Key, r18); + Configs.IsOnR18 = r18; + App.DebugPrint($"r-18 filter: {r18}"); + Preferences.Set(Configs.IsProxiedKey, proxied); Preferences.Set(Configs.HostKey, h); var p = Port; diff --git a/Pixiview/Resources/Languages/zh-CN.xml b/Pixiview/Resources/Languages/zh-CN.xml index 6864f02..f3b3e2d 100644 --- a/Pixiview/Resources/Languages/zh-CN.xml +++ b/Pixiview/Resources/Languages/zh-CN.xml @@ -5,6 +5,7 @@ 取消 + 插画 代理 详细 启用 diff --git a/Pixiview/Utils/Stores.cs b/Pixiview/Utils/Stores.cs index 20159ac..f741b87 100644 --- a/Pixiview/Utils/Stores.cs +++ b/Pixiview/Utils/Stores.cs @@ -442,7 +442,8 @@ namespace Pixiview.Utils public static class Configs { - public const string IsProxiedKey = "isProxied"; + public const string IsOnR18Key = "is_on_r18"; + public const string IsProxiedKey = "is_proxied"; public const string HostKey = "host"; public const string PortKey = "port"; public const string QueryModeKey = "query_mode"; @@ -455,6 +456,7 @@ namespace Pixiview.Utils public const string RefererIllustRanking = "https://www.pixiv.net/ranking.php?{0}"; public const string RefererIllustUser = "https://www.pixiv.net/users/{0}/illustrations"; + public static bool IsOnR18; public static WebProxy Proxy; private static string Prefix => Proxy == null ? "https://hk.tsanie.us/reverse/" :