From 4a8cefbd7809a9faaa39537c214586a5922534c3 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Thu, 18 Jan 2024 11:26:07 +0800 Subject: [PATCH] feat: add tags filter feature (#53) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 应用市场筛选项支持通过标签筛选。 图片 图片 [plugin-app-store-1.0.0-SNAPSHOT.jar.zip](https://github.com/halo-dev/plugin-app-store/files/13971569/plugin-app-store-1.0.0-SNAPSHOT.jar.zip) /kind feature ```release-note 支持通过标签筛选应用 ``` --- build.gradle | 2 +- console/src/components/AppStoreTab.vue | 35 +++++++++++- console/src/components/AppTag.vue | 24 +++++++++ .../src/components/detail/DetailSidebar.vue | 45 +++++++++++++++- console/src/views/AppStore.vue | 53 ++++++++++++++++++- 5 files changed, 152 insertions(+), 7 deletions(-) create mode 100644 console/src/components/AppTag.vue diff --git a/build.gradle b/build.gradle index 6e21027..914ee93 100644 --- a/build.gradle +++ b/build.gradle @@ -41,6 +41,6 @@ build { } halo { - version = '2.10.2' + version = '2.11' debug = true } \ No newline at end of file diff --git a/console/src/components/AppStoreTab.vue b/console/src/components/AppStoreTab.vue index f3088a7..ae502d8 100644 --- a/console/src/components/AppStoreTab.vue +++ b/console/src/components/AppStoreTab.vue @@ -17,7 +17,7 @@ import AppCard from "./AppCard.vue"; import { useLocalStorage } from "@vueuse/core"; import AppDetailModal from "./AppDetailModal.vue"; import { nextTick } from "vue"; -import type { ApplicationSearchResult, ListResponse } from "@/types"; +import type { ApplicationSearchResult, ApplicationTag, ListResponse } from "@/types"; import storeApiClient from "@/utils/store-api-client"; import AgreementsModal from "./AgreementsModal.vue"; @@ -48,9 +48,26 @@ const page = ref(1); const size = ref(20); const selectedSort = ref("latestReleaseTimestamp,desc"); const selectedPriceMode = ref(); +const selectedTag = ref(); + +const { data: tags } = useQuery({ + queryKey: ["app-tags"], + queryFn: async () => { + const { data } = await storeApiClient.get>("/apis/store.halo.run/v1alpha1/tags"); + + if (data?.items.length) { + // sort by privileged + return data.items.sort((a: ApplicationTag, b: ApplicationTag) => { + return +b.spec.privileged - +a.spec.privileged; + }); + } + + return []; + }, +}); const { data, isFetching, isLoading, refetch } = useQuery>({ - queryKey: ["store-apps", keyword, selectedSort, page, size, selectedPriceMode, props.type], + queryKey: ["store-apps", keyword, selectedSort, page, size, selectedPriceMode, props.type, selectedTag], queryFn: async () => { const { data } = await storeApiClient.get>( `/apis/api.store.halo.run/v1alpha1/applications`, @@ -62,6 +79,7 @@ const { data, isFetching, isLoading, refetch } = useQuery { }, ]" /> + +withDefaults( + defineProps<{ + selected: boolean; + }>(), + { + selected: false, + } +); + + + + + diff --git a/console/src/components/detail/DetailSidebar.vue b/console/src/components/detail/DetailSidebar.vue index e64fdf0..34f8901 100644 --- a/console/src/components/detail/DetailSidebar.vue +++ b/console/src/components/detail/DetailSidebar.vue @@ -1,7 +1,11 @@