|
1 | 1 | <template>
|
2 |
| - <div class="px-6 lg:px-10"></div> |
| 2 | + <div class="px-6 lg:px-10"> |
| 3 | + <VCollectionHeader |
| 4 | + v-if="collectionParams && collectionParams.collection" |
| 5 | + :title="collectionTitle" |
| 6 | + results-label="Lots of results" |
| 7 | + :collection="collectionParams.collection" |
| 8 | + /> |
| 9 | + <h1>{{ strategy }}</h1> |
| 10 | + <pre>{{ collectionParams }}</pre> |
| 11 | + <pre>{{ results }}</pre> |
| 12 | + </div> |
3 | 13 | </template>
|
4 | 14 |
|
5 | 15 | <script lang="ts">
|
6 |
| -import { defineComponent } from "@nuxtjs/composition-api" |
| 16 | +import { computed, ref } from "vue" |
| 17 | +import { defineComponent, useFetch } from "@nuxtjs/composition-api" |
7 | 18 |
|
8 | 19 | import { useProviderStore } from "~/stores/provider"
|
9 | 20 | import { useSearchStore } from "~/stores/search"
|
10 | 21 | import { isSupportedMediaType, SupportedMediaType } from "~/constants/media"
|
11 | 22 | import type { Collection, CollectionParams } from "~/types/search"
|
12 | 23 | import { useFeatureFlagStore } from "~/stores/feature-flag"
|
13 | 24 | import { warn } from "~/utils/console"
|
| 25 | +import { useMediaStore } from "~/stores/media" |
| 26 | +import { Media } from "~/types/media" |
14 | 27 |
|
15 | 28 | export default defineComponent({
|
16 | 29 | name: "VCollectionPage",
|
@@ -84,7 +97,46 @@ export default defineComponent({
|
84 | 97 | const searchStore = useSearchStore($pinia)
|
85 | 98 | searchStore.setStrategy(collection, collectionParams)
|
86 | 99 | searchStore.setSearchType(mediaType)
|
| 100 | +
|
87 | 101 | return true
|
88 | 102 | },
|
| 103 | + setup() { |
| 104 | + const mediaStore = useMediaStore() |
| 105 | + const searchStore = useSearchStore() |
| 106 | +
|
| 107 | + const strategy = computed(() => searchStore.strategy) |
| 108 | + const collectionParams = computed(() => searchStore.collectionParams) |
| 109 | +
|
| 110 | + const collectionTitle = computed(() => { |
| 111 | + if (!collectionParams.value) return "" |
| 112 | + const collection = collectionParams.value.collection |
| 113 | + if (collection === "tag") { |
| 114 | + return collectionParams.value.tag |
| 115 | + } else if (collection === "source") { |
| 116 | + return collectionParams.value.source |
| 117 | + } else if (collection === "creator") { |
| 118 | + return collectionParams.value.creator |
| 119 | + } else { |
| 120 | + return "" |
| 121 | + } |
| 122 | + }) |
| 123 | +
|
| 124 | + const results = ref<Media[]>([]) |
| 125 | +
|
| 126 | + useFetch(async () => { |
| 127 | + if (isSupportedMediaType(mediaStore._searchType)) { |
| 128 | + await mediaStore.fetchMedia() |
| 129 | + results.value = mediaStore.resultItems[mediaStore._searchType] |
| 130 | + } |
| 131 | + }) |
| 132 | +
|
| 133 | + return { |
| 134 | + strategy, |
| 135 | + collectionParams, |
| 136 | + collectionTitle, |
| 137 | +
|
| 138 | + results, |
| 139 | + } |
| 140 | + }, |
89 | 141 | })
|
90 | 142 | </script>
|
0 commit comments