* Pixiview/UI/CircleUIs.cs:
* Pixiview.iOS/Pixiview.iOS.csproj: * Pixiview.iOS/Renderers/RoundLabelRenderer.cs: * Pixiview.iOS/Renderers/CircleImageRenderer.cs: custom round corner controls * Pixiview/App.xaml: * Pixiview/Utils/Converters.cs: * Pixiview/GlobalSuppressions.cs: * Pixiview/UI/StyleDefinition.cs: * Pixiview/UI/AdaptedPage.cs: * Pixiview.iOS/Renderers/AdaptedPageRenderer.cs: observe orientation * Pixiview/MainPage.xaml: * Pixiview/Utils/Stores.cs: * Pixiview/MainPage.xaml.cs: * Pixiview/Utils/IllustData.cs: data and UI adjust
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Pixiview.Utils
|
||||
{
|
||||
@@ -14,6 +15,7 @@ namespace Pixiview.Utils
|
||||
public static readonly string PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||
//public static readonly string CacheFolder = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
|
||||
private const string imageFolder = "img-master";
|
||||
private const string thumbFolder = "img-thumb";
|
||||
private const string userFolder = "user-profile";
|
||||
private const string illustFile = "illust.json";
|
||||
|
||||
@@ -67,35 +69,46 @@ namespace Pixiview.Utils
|
||||
}
|
||||
}
|
||||
|
||||
public static string LoadIllustImage(string url)
|
||||
public static ImageSource LoadIllustImage(string url)
|
||||
{
|
||||
return LoadImage(url, imageFolder);
|
||||
}
|
||||
|
||||
public static string LoadUserProfileImage(string url)
|
||||
public static ImageSource LoadThumbnailImage(string url)
|
||||
{
|
||||
return LoadImage(url, thumbFolder);
|
||||
}
|
||||
|
||||
public static ImageSource LoadUserProfileImage(string url)
|
||||
{
|
||||
return LoadImage(url, userFolder);
|
||||
}
|
||||
|
||||
public static string LoadImage(string url, string folder)
|
||||
public static ImageSource LoadImage(string url, string folder)
|
||||
{
|
||||
var file = Path.Combine(PersonalFolder, imageFolder, Path.GetFileName(url));
|
||||
if (File.Exists(file))
|
||||
var file = Path.Combine(PersonalFolder, folder, Path.GetFileName(url));
|
||||
if (!File.Exists(file))
|
||||
{
|
||||
return file;
|
||||
file = DownloadImage(url, folder);
|
||||
}
|
||||
else
|
||||
if (file != null)
|
||||
{
|
||||
file = DownloadImage(url, folder).Result;
|
||||
return file;
|
||||
return ImageSource.FromFile(file);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static async Task<string> DownloadImage(string url, string folder)
|
||||
public static string DownloadImage(string url, string folder)
|
||||
{
|
||||
try
|
||||
{
|
||||
var file = Path.Combine(PersonalFolder, folder, Path.GetFileName(url));
|
||||
var directory = Path.Combine(PersonalFolder, folder);
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
var file = Path.Combine(directory, Path.GetFileName(url));
|
||||
App.DebugPrint($"download, url: {url}");
|
||||
var response = Download(url);
|
||||
if (response == null)
|
||||
{
|
||||
@@ -104,11 +117,11 @@ namespace Pixiview.Utils
|
||||
using (response)
|
||||
using (var fs = File.OpenWrite(file))
|
||||
{
|
||||
await response.Content.CopyToAsync(fs);
|
||||
if (response.Headers.Date != null)
|
||||
{
|
||||
File.SetLastWriteTimeUtc(file, response.Headers.Date.Value.UtcDateTime);
|
||||
}
|
||||
response.Content.CopyToAsync(fs).Wait();
|
||||
//if (response.Headers.Date != null)
|
||||
//{
|
||||
// File.SetLastWriteTimeUtc(file, response.Headers.Date.Value.UtcDateTime);
|
||||
//}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
@@ -156,6 +169,7 @@ namespace Pixiview.Utils
|
||||
})
|
||||
{
|
||||
request.Headers.Referrer = referer == null ? Configs.Referer : new Uri(referer);
|
||||
request.Headers.Add("user-agent", Configs.UserAgent);
|
||||
if (headers != null)
|
||||
{
|
||||
foreach (var (header, value) in headers)
|
||||
@@ -173,6 +187,8 @@ namespace Pixiview.Utils
|
||||
public static readonly WebProxy Proxy = new WebProxy("10.0.10.100", 8088);
|
||||
public static readonly Uri Referer = new Uri("https://www.pixiv.net/");
|
||||
|
||||
public const int MaxThreads = 3;
|
||||
public const string UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36";
|
||||
public const string UrlIllust = "https://www.pixiv.net/ajax/top/illust?mode=all&lang=zh";
|
||||
public const string Cookie = "first_visit_datetime_pc=2019-10-29+22%3A05%3A30; p_ab_id=2; p_ab_id_2=6;" +
|
||||
" p_ab_d_id=1155161977; a_type=0; b_type=1; d_type=2; module_orders_mypage=%5B%7B%22name%22%3A%22s" +
|
||||
@@ -188,5 +204,20 @@ namespace Pixiview.Utils
|
||||
"SID=2603358_VHyGPeRaz7LpeoFkRsHvjXIpApCMb56a; __cfduid=d9fa2d4d1ddd30db85ebb519f9855d256158780674" +
|
||||
"7; privacy_policy_agreement=2";
|
||||
public const string UserId = "2603358";
|
||||
|
||||
public static string GetThumbnailUrl(string url)
|
||||
{
|
||||
url = url.Replace("/custom-thumb/", "/img-master/");
|
||||
var index = url.LastIndexOf("_square1200.jpg");
|
||||
if (index < 0)
|
||||
{
|
||||
index = url.LastIndexOf("_custom1200.jpg");
|
||||
}
|
||||
if (index >= 0)
|
||||
{
|
||||
return url.Substring(0, index) + "_master1200.jpg";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user