From 5c8f86e9171c72dbd95de10ac80b35bc0beef12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9B=B0=E5=9B=B0=E9=B1=BC?= <89380218+chengzhongxue@users.noreply.github.com> Date: Fri, 9 May 2025 11:11:47 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9Asupport=20sorting=20tags=20by=20po?= =?UTF-8?q?st=20count=20(#7414)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind feature #### What this PR does / why we need it: 标签支持根据文章量排序 #### Does this PR introduce a user-facing change? ```release-note 标签支持根据文章量排序 ``` --- .../src/main/java/run/halo/app/infra/SchemeInitializer.java | 5 +++++ ui/console-src/modules/contents/posts/tags/TagList.vue | 4 ++++ ui/src/locales/_missing_translations_es.yaml | 1 + ui/src/locales/en.yaml | 1 + ui/src/locales/zh-CN.yaml | 1 + ui/src/locales/zh-TW.yaml | 1 + 6 files changed, 13 insertions(+) diff --git a/application/src/main/java/run/halo/app/infra/SchemeInitializer.java b/application/src/main/java/run/halo/app/infra/SchemeInitializer.java index 2737dde1e..8f4a78a6b 100644 --- a/application/src/main/java/run/halo/app/infra/SchemeInitializer.java +++ b/application/src/main/java/run/halo/app/infra/SchemeInitializer.java @@ -342,6 +342,11 @@ public class SchemeInitializer implements ApplicationListener tag.getSpec().getSlug())) ); + indexSpecs.add(new IndexSpec() + .setName("status.postCount") + .setIndexFunc(simpleAttribute(Tag.class, + tag -> defaultIfNull(tag.getStatus().getPostCount(), 0).toString())) + ); indexSpecs.add(new IndexSpec() .setName(Tag.REQUIRE_SYNC_ON_STARTUP_INDEX_NAME) .setIndexFunc(simpleAttribute(Tag.class, tag -> { diff --git a/ui/console-src/modules/contents/posts/tags/TagList.vue b/ui/console-src/modules/contents/posts/tags/TagList.vue index 528bcaac7..6de8d3e07 100644 --- a/ui/console-src/modules/contents/posts/tags/TagList.vue +++ b/ui/console-src/modules/contents/posts/tags/TagList.vue @@ -238,6 +238,10 @@ watch(selectedTagNames, (newVal) => { ), value: 'spec.displayName,asc', }, + { + label: t('core.post.tag.filters.sort.items.post_desc'), + value: 'status.postCount,desc', + }, ]" />
diff --git a/ui/src/locales/_missing_translations_es.yaml b/ui/src/locales/_missing_translations_es.yaml index 7d99577de..d6fa9121d 100644 --- a/ui/src/locales/_missing_translations_es.yaml +++ b/ui/src/locales/_missing_translations_es.yaml @@ -68,6 +68,7 @@ core: create_time_asc: Earliest Created display_name_desc: Descending order by tag name display_name_asc: Ascending order by tag name + post_desc: Most Posts batch_setting_modal: title: Post batch settings fields: diff --git a/ui/src/locales/en.yaml b/ui/src/locales/en.yaml index baad38d93..768c05320 100644 --- a/ui/src/locales/en.yaml +++ b/ui/src/locales/en.yaml @@ -222,6 +222,7 @@ core: create_time_asc: Earliest Created display_name_desc: Descending order by tag name display_name_asc: Ascending order by tag name + post_desc: Most Posts batch_setting_modal: title: Post batch settings fields: diff --git a/ui/src/locales/zh-CN.yaml b/ui/src/locales/zh-CN.yaml index 23fb73cec..db92f440a 100644 --- a/ui/src/locales/zh-CN.yaml +++ b/ui/src/locales/zh-CN.yaml @@ -210,6 +210,7 @@ core: create_time_asc: 较早创建 display_name_desc: 标签名降序 display_name_asc: 标签名升序 + post_desc: 最多文章量 batch_setting_modal: title: 文章批量设置 fields: diff --git a/ui/src/locales/zh-TW.yaml b/ui/src/locales/zh-TW.yaml index 2307e140d..c1d54b54c 100644 --- a/ui/src/locales/zh-TW.yaml +++ b/ui/src/locales/zh-TW.yaml @@ -231,6 +231,7 @@ core: create_time_asc: 較早建立 display_name_desc: 標籤名稱降序 display_name_asc: 標籤名稱升序 + post_desc: 最多文章量 deleted_post: title: 文章回收站 empty: