feat 页面页尾

This commit is contained in:
Ironsp
2026-10-01 14:23:58 +08:00
parent b99b2a0a88
commit 0d2389e49a
11 changed files with 166 additions and 35 deletions

View File

@@ -3,6 +3,8 @@ import { computed, ref } from 'vue'
import type { BusinessType } from '@/types/api'
import type { Case } from '@/types/business/cases'
import type {
Banner,
BannerVo,
BusinessLine,
HomeStats,
ProjectStatusCount,
@@ -14,6 +16,7 @@ import type {
} from '@/types/business/home'
import type { PortalEntryGroup, PortalEntryVo } from '@/types/business/home'
import {
getCarouselList,
getPortalEntryList,
getProjectStatusCount,
getServiceTypeDetail,
@@ -52,6 +55,17 @@ function stripHtml(html: string): string {
.trim()
}
/** 后端轮播 VO → 页面 Banner(仅启用项,按 sort 升序) */
function toBanners(list: BannerVo[]): Banner[] {
return list
.filter((item) => item.enabled !== false && Boolean(item.imageUrl))
.sort((a, b) => (a.sort ?? 0) - (b.sort ?? 0))
.map((item) => ({
id: item.id ?? 0,
imageUrl: item.imageUrl ?? '',
}))
}
/** 后端「项目提报」→ 业务线卡片 / 业务详情 */
function toBusinessLine(vo: ProjectSubmissionVo): BusinessLine {
const serviceTypes: ServiceType[] = (vo.serviceTypes ?? []).map((item) => ({
@@ -130,6 +144,7 @@ export const useHomeStore = defineStore('home', () => {
const casesStore = useCasesStore()
const stats = ref<HomeStats>({ pending: 0, inProgress: 0, total: 0 })
const banners = ref<Banner[]>([])
const businessLines = ref<BusinessLine[]>([])
const featuredCases = ref<Case[]>([])
const currentBusiness = ref<BusinessLine | null>(null)
@@ -185,10 +200,11 @@ export const useHomeStore = defineStore('home', () => {
/** 首页初始化:看板 + 轮播图 + 业务服务线 + 案例精选 */
async function fetchHomeData(): Promise<void> {
const [statusCount, submissionList, cases] = await Promise.all([
const [statusCount, submissionList, cases, carouselList] = await Promise.all([
getProjectStatusCount(),
getServiceTypeList(),
getFeaturedCasesApi(),
getCarouselList().catch(() => [] as BannerVo[]),
// 案例标签需要「提报 id → 类型名」字典,与首页其余数据并行取(幂等,已加载则不发请求)
casesStore.ensureCategories(),
])
@@ -201,6 +217,7 @@ export const useHomeStore = defineStore('home', () => {
submissions.value = submissionList
businessLines.value = submissionList.map(toBusinessLine)
featuredCases.value = cases.map((vo) => toCase(vo, casesStore.typeNameById))
banners.value = toBanners(carouselList ?? [])
// 入口个性化接口失败已被内部吞掉,不会影响上面的首页数据
await fetchPortalEntries()
}
@@ -240,6 +257,7 @@ export const useHomeStore = defineStore('home', () => {
return {
stats,
banners,
businessLines,
featuredCases,
currentBusiness,