diff --git a/src/lib/api.ts b/src/lib/api.ts index 92ccb03..091f6e9 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -156,6 +156,7 @@ export function toCloudType(row: BackendCloudType): CloudType { id: row.id, name: row.name, genus: row.genus || '', + icon_id: row.icon_id, // Compatibility value for the excluded legacy admin view. Migrated pages // display rarity_value directly because API.md defines no semantic mapping. rarity: 'common', diff --git a/src/types/database.ts b/src/types/database.ts index 610144a..012df05 100644 --- a/src/types/database.ts +++ b/src/types/database.ts @@ -2,6 +2,7 @@ export interface CloudType { id: number name: string genus: string + icon_id: string | null rarity: 'common' | 'uncommon' | 'rare' rarity_value: number description: string | null diff --git a/src/views/encyclopedia/CloudTypeView.vue b/src/views/encyclopedia/CloudTypeView.vue index af9fa3a..907f76f 100644 --- a/src/views/encyclopedia/CloudTypeView.vue +++ b/src/views/encyclopedia/CloudTypeView.vue @@ -4,7 +4,7 @@ import { NAlert, NButton, NEmpty, NSkeleton } from 'naive-ui' import { RouterLink, useRoute } from 'vue-router' import ImageDetailModal from '@/components/cloud/ImageDetailModal.vue' import MiniLocationMap from '@/components/cloud/MiniLocationMap.vue' -import { apiRequest, toApiCloud } from '@/lib/api' +import { apiRequest, imageUrl, toApiCloud } from '@/lib/api' import { useEncyclopediaStore } from '@/stores/encyclopedia' import type { ApiCloud, BackendCloudInfo } from '@/types/api' @@ -20,7 +20,7 @@ const hasNextPage = ref(false) const cloudTypeId = computed(() => Number(route.params.id)) const cloudType = computed(() => encyclopediaStore.cloudTypes.find(item => item.id === cloudTypeId.value) ?? null) -const heroImage = computed(() => gallery.value[0]?.image_url || null) +const heroImage = computed(() => cloudType.value?.icon_id ? imageUrl(cloudType.value.icon_id, 'original') : null) function formatDateTime(iso: string | null) { if (!iso) return '未记录拍摄时间' @@ -86,11 +86,15 @@ watch(() => route.params.id, () => loadPage())
-
-
- 稀有度 {{ cloudType.rarity_value }} +
无图片
+
+
+ 稀有度 {{ cloudType.rarity_value }}

{{ cloudType.name }}

-

{{ cloudType.genus || '未提供云属名称' }}

+

{{ cloudType.genus || '未提供云属名称' }}

diff --git a/src/views/encyclopedia/EncyclopediaView.vue b/src/views/encyclopedia/EncyclopediaView.vue index 44d536b..443d36f 100644 --- a/src/views/encyclopedia/EncyclopediaView.vue +++ b/src/views/encyclopedia/EncyclopediaView.vue @@ -2,11 +2,16 @@ import { onMounted } from 'vue' import { NEmpty, NSkeleton } from 'naive-ui' import { useRouter } from 'vue-router' +import { imageUrl } from '@/lib/api' import { useEncyclopediaStore } from '@/stores/encyclopedia' const router = useRouter() const encyclopediaStore = useEncyclopediaStore() +function typeImageUrl(iconId: string | null) { + return iconId ? imageUrl(iconId, 'preview') : '' +} + onMounted(() => encyclopediaStore.fetchCloudTypes()) @@ -24,10 +29,8 @@ onMounted(() => encyclopediaStore.fetchCloudTypes())
-
- - - +
+
@@ -36,25 +39,48 @@ onMounted(() => encyclopediaStore.fetchCloudTypes()) v-for="cloudType in encyclopediaStore.cloudTypes" :key="cloudType.id" type="button" - class="oc-interactive-card oc-panel-card flex h-full flex-col border border-slate-200 bg-white p-5 text-left" + class="oc-interactive-card oc-panel-card relative isolate min-h-80 overflow-hidden border border-slate-200 bg-sky-50 text-left" @click="router.push(`/encyclopedia/${cloudType.id}`)" > -
-
- -

{{ cloudType.name }}

-

- {{ cloudType.genus || '未提供云属名称' }} -

+ +
+
无图片
+ +
+
+
+ +

{{ cloudType.name }}

+

+ {{ cloudType.genus || '未提供云属名称' }} +

+
+ + 稀有度 {{ cloudType.rarity_value }} +
- - 稀有度 {{ cloudType.rarity_value }} - +

+ {{ cloudType.description || '暂未提供识别说明。' }} +

+

查看类型资料与公开云图 →

-

- {{ cloudType.description || '暂未提供识别说明。' }} -

-

查看类型资料与公开云图 →