implement yande.re source

This commit is contained in:
2021-08-06 17:18:18 +08:00
parent 600d81a3f1
commit 9d316cba77
18 changed files with 486 additions and 2 deletions

View File

@@ -4,6 +4,8 @@ using Xamarin.Essentials;
using Gallery.Resources;
using Gallery.Util;
using Gallery.Resources.Theme;
using System.Collections.Generic;
using Gallery.Util.Interface;
namespace Gallery
{
@@ -12,8 +14,19 @@ namespace Gallery
public static AppTheme CurrentTheme { get; private set; }
public static PlatformCulture CurrentCulture { get; private set; }
public static List<IGallerySource> GallerySources { get; } = new()
{
new Yandere.GallerySource(), // https://yande.re
new Danbooru.GallerySource(), // https://danbooru.donmai.us
new Gelbooru.GallerySource() // https://gelbooru.com
};
public App()
{
Preferences.Set(Config.IsProxiedKey, true);
Preferences.Set(Config.ProxyHostKey, "192.168.25.9");
Preferences.Set(Config.ProxyPortKey, 1081);
DependencyService.Register<MockDataStore>();
}
@@ -25,7 +38,33 @@ namespace Gallery
private void InitPreference()
{
Config.Proxy = null;
var isProxied = Preferences.Get(Config.IsProxiedKey, false);
if (isProxied)
{
var host = Preferences.Get(Config.ProxyHostKey, null);
var port = Preferences.Get(Config.ProxyPortKey, 0);
if (!string.IsNullOrEmpty(host) && port > 0)
{
try
{
if (host.IndexOf(':') >= 0)
{
host = $"[{host}]";
}
var uri = new System.Uri($"http://{host}:{port}");
Config.Proxy = new System.Net.WebProxy(uri, true);
#if DEBUG
Log.Print($"load proxy: {uri}");
#endif
}
catch (System.Exception ex)
{
Log.Error("preferences.init", $"failed to parse proxy: {host}:{port}, error: {ex.Message}");
}
}
}
}
private void InitLanguage()