在资源包下载页面中隐藏不必要的标签 (#5180)

This commit is contained in:
Glavo
2026-01-10 20:39:15 +08:00
committed by GitHub
parent 682d88df02
commit a3d9e29350
2 changed files with 12 additions and 6 deletions

View File

@@ -208,6 +208,10 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP
: i18n("curse.category." + category); : i18n("curse.category." + category);
} }
protected boolean shouldDisplayCategory(String category) {
return !"minecraft".equals(category);
}
private String getLocalizedCategoryIndent(ModDownloadListPageSkin.CategoryIndented category) { private String getLocalizedCategoryIndent(ModDownloadListPageSkin.CategoryIndented category) {
return StringUtils.repeats(' ', category.indent * 4) + return StringUtils.repeats(' ', category.indent * 4) +
(category.getCategory() == null (category.getCategory() == null
@@ -556,9 +560,10 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP
content.setTitle(mod != null && I18n.isUseChinese() ? mod.getDisplayName() : dataItem.getTitle()); content.setTitle(mod != null && I18n.isUseChinese() ? mod.getDisplayName() : dataItem.getTitle());
content.setSubtitle(dataItem.getDescription()); content.setSubtitle(dataItem.getDescription());
content.getTags().clear(); content.getTags().clear();
dataItem.getCategories().stream() for (String category : dataItem.getCategories()) {
.map(category -> getSkinnable().getLocalizedCategory(category)) if (getSkinnable().shouldDisplayCategory(category))
.forEach(content::addTag); content.addTag(getSkinnable().getLocalizedCategory(category));
}
loadIcon(dataItem); loadIcon(dataItem);
} }

View File

@@ -357,9 +357,10 @@ public class DownloadPage extends Control implements DecoratorPage {
ModTranslations.Mod mod = ModTranslations.getTranslationsByRepositoryType(page.repository.getType()).getModByCurseForgeId(addon.getSlug()); ModTranslations.Mod mod = ModTranslations.getTranslationsByRepositoryType(page.repository.getType()).getModByCurseForgeId(addon.getSlug());
content.setTitle(mod != null && I18n.isUseChinese() ? mod.getDisplayName() : addon.getTitle()); content.setTitle(mod != null && I18n.isUseChinese() ? mod.getDisplayName() : addon.getTitle());
content.setSubtitle(addon.getDescription()); content.setSubtitle(addon.getDescription());
addon.getCategories().stream() for (String category : addon.getCategories()) {
.map(page::getLocalizedCategory) if (page.shouldDisplayCategory(category))
.forEach(content::addTag); content.addTag(page.getLocalizedCategory(category));
}
if (StringUtils.isNotBlank(addon.getIconUrl())) { if (StringUtils.isNotBlank(addon.getIconUrl())) {
imageView.imageProperty().bind(FXUtils.newRemoteImage(addon.getIconUrl(), 80, 80, true, true)); imageView.imageProperty().bind(FXUtils.newRemoteImage(addon.getIconUrl(), 80, 80, true, true));
} }