Updated UI. Fixed circle search performance.
All checks were successful
ci / build-test (push) Successful in 1m43s
ci / publish-image (push) Has been skipped

This commit is contained in:
2025-11-10 18:55:46 -05:00
parent 840bec72d2
commit 9cd9230cec
43 changed files with 1105 additions and 164 deletions

View File

@@ -0,0 +1,78 @@
namespace JSMR.UI.Blazor.Services;
public static class ImageUrlProvider
{
public static string GetImageURL(string? productId, bool hasImage, DateTime? salesDate, string size)
{
string folder = "modpub";
string imageSize = "main";
string imageWorkType = productId != null ? productId.StartsWith("RJ") ? "doujin" : "professional" : "doujin";
switch (size)
{
case "small":
imageSize = "sam";
folder = "modpub";
break;
case "300x300":
imageSize = hasImage ? "main_300x300" : "main";
folder = "resize";
break;
case "240x":
//imageSize = hasImage ? imageWorkType == "doujin" ? "main_240x240" : "sam_170x" : "main";
imageSize = hasImage ? imageWorkType == "doujin" ? "main_240x240" : "main_240x240" : "main";
folder = "resize";
break;
case "main":
default:
imageSize = "main";
folder = "modpub";
break;
}
if (hasImage == false || productId == null)
{
string noImageUrlTemplate = "/images/web/home/no_img_[imageSize].gif";
string noImageUrl = noImageUrlTemplate.Replace("[imageSize]", imageSize);
return noImageUrl;
}
var imageUrlTemplate = "//img.dlsite.jp/[folder]/images2/[imageType1]/[imageWorkType]/[fullRoundedProductId]/[productId][imageType2]_img_[imageSize].jpg";
var productIdWithoutPrefixString = productId.Substring(2);
int productIdWithoutPrefix = Convert.ToInt32(productId.Substring(2));
string productIdPrefix = productId.Substring(0, 2);
double something = (double)((productIdWithoutPrefix / 1000) * 1000);
int roundedProductId = (int)Math.Round(Math.Ceiling((double)productIdWithoutPrefix / 1000) * 1000);
//string actualRoundedProductId = ("000000" + roundedProductId.ToString()).Substring(roundedProductId.ToString().Length);
//string fullRoundedProductId = productIdPrefix + actualRoundedProductId;
var productIdWithPrefixStringLength = productIdWithoutPrefixString.Length;
var zeroPadLength = productIdWithPrefixStringLength - roundedProductId.ToString().Length;
var fullRoundedProductId = productIdPrefix.PadRight(productIdPrefix.Length + zeroPadLength, '0') + roundedProductId;
bool hasSalesDate = salesDate.HasValue;
string imageType1 = hasSalesDate ? "work" : "ana";
string imageType2 = hasSalesDate ? "" : "_ana";
string productLinkPage = salesDate.HasValue ? "work" : "announce";
string imageUrl = imageUrlTemplate
.Replace("[folder]", folder)
.Replace("[imageType1]", imageType1)
.Replace("[imageWorkType]", imageWorkType)
.Replace("[fullRoundedProductId]", fullRoundedProductId)
.Replace("[productId]", productId)
.Replace("[imageType2]", imageType2)
.Replace("[imageSize]", imageSize);
return imageUrl;
}
}