Added voice work image fallback. Added tag/creator/circle chip components. Updated voice work search response to include favorite/blacklisted flags for tags/creators/circles.
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
using JSMR.Application.VoiceWorks.Queries.Search;
|
||||
using JSMR.UI.Blazor.Enums;
|
||||
|
||||
namespace JSMR.UI.Blazor.Services;
|
||||
|
||||
public static class ImageUrlProvider
|
||||
{
|
||||
public static string GetImageUrl(VoiceWorkSearchResult voiceWork, string size)
|
||||
public static string GetImageUrl(VoiceWorkSearchResult voiceWork, string size, string extension = "jpg")
|
||||
{
|
||||
return GetImageURL(voiceWork.OriginalProductId ?? voiceWork.ProductId, voiceWork.HasImage, voiceWork.SalesDate, size);
|
||||
return GetImageURL(voiceWork.OriginalProductId ?? voiceWork.ProductId, voiceWork.HasImage, voiceWork.SalesDate, size, extension);
|
||||
}
|
||||
|
||||
public static string GetImageURL(string? productId, bool hasImage, DateTime? salesDate, string size)
|
||||
public static string GetImageUrl(VoiceWorkSearchResult voiceWork, ImageSize imageSize, ImageExtension imageExtension)
|
||||
{
|
||||
return GetImageUrl(voiceWork.OriginalProductId ?? voiceWork.ProductId, voiceWork.HasImage, voiceWork.SalesDate.HasValue, imageSize, imageExtension);
|
||||
}
|
||||
|
||||
public static string GetImageURL(string? productId, bool hasImage, DateTime? salesDate, string size, string extension = "jpg")
|
||||
{
|
||||
string folder = "modpub";
|
||||
string imageSize = "main";
|
||||
@@ -46,7 +52,7 @@ public static class ImageUrlProvider
|
||||
return noImageUrl;
|
||||
}
|
||||
|
||||
var imageUrlTemplate = "//img.dlsite.jp/[folder]/images2/[imageType1]/[imageWorkType]/[fullRoundedProductId]/[productId][imageType2]_img_[imageSize].jpg";
|
||||
var imageUrlTemplate = $"//img.dlsite.jp/[folder]/images2/[imageType1]/[imageWorkType]/[fullRoundedProductId]/[productId][imageType2]_img_[imageSize].{extension}";
|
||||
|
||||
string productIdWithoutPrefixString = productId.Substring(2);
|
||||
int productIdWithoutPrefix = Convert.ToInt32(productId.Substring(2));
|
||||
@@ -78,4 +84,43 @@ public static class ImageUrlProvider
|
||||
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public static string GetImageUrl(string? productId, bool hasImage, bool isOnSale, ImageSize size, ImageExtension extension)
|
||||
{
|
||||
string imageWorkType = productId != null ? productId.StartsWith("RJ") ? "doujin" : "professional" : "doujin";
|
||||
(string imageSize, string folder) = GetImageSizeAndFolder(size, hasImage);
|
||||
|
||||
if (hasImage == false || productId == null)
|
||||
{
|
||||
return $"/images/web/home/no_img_{imageSize}.gif";
|
||||
}
|
||||
|
||||
string productIdWithoutPrefixString = productId.Substring(2);
|
||||
int productIdWithoutPrefix = Convert.ToInt32(productId.Substring(2));
|
||||
|
||||
string productIdPrefix = productId[..2];
|
||||
|
||||
int roundedProductId = (int)Math.Round(Math.Ceiling((double)productIdWithoutPrefix / 1000) * 1000);
|
||||
|
||||
int productIdWithPrefixStringLength = productIdWithoutPrefixString.Length;
|
||||
int zeroPadLength = productIdWithPrefixStringLength - roundedProductId.ToString().Length;
|
||||
|
||||
var fullRoundedProductId = productIdPrefix.PadRight(productIdPrefix.Length + zeroPadLength, '0') + roundedProductId;
|
||||
|
||||
string imageType1 = isOnSale ? "work" : "ana";
|
||||
string imageType2 = isOnSale ? "" : "_ana";
|
||||
|
||||
return $"//img.dlsite.jp/{folder}/images2/{imageType1}/{imageWorkType}/{fullRoundedProductId}/{productId}{imageType2}_img_{imageSize}.{extension}";
|
||||
}
|
||||
|
||||
private static (string, string) GetImageSizeAndFolder(ImageSize imageSize, bool hasImage)
|
||||
{
|
||||
return imageSize switch
|
||||
{
|
||||
ImageSize.Thumb100 => ("sam", "modpub"),
|
||||
ImageSize.Square240 => (hasImage ? "main_240x240" : "main", "resize"),
|
||||
ImageSize.Square300 => (hasImage ? "main_300x300" : "main", "resize"),
|
||||
_ => ("main", "modpub"),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user