Files
cz-web/src/views/home/index.vue
2026-10-01 16:58:22 +08:00

83 lines
2.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- 页面:首页(Home) -->
<script setup lang="ts">
import { computed, onMounted } from 'vue'
import { storeToRefs } from 'pinia'
// 页面容器:只做组件引入、props 分发、事件中转,数据只经 store
import { useHomeStore } from '@/stores/modules/home'
import type { BusinessType } from '@/types/api'
import HomeBanner from './cpns/HomeBanner.vue'
import HomeWelcome from './cpns/HomeWelcome.vue'
import HomeStats from './cpns/HomeStats.vue'
import HomeQuickEntries from './cpns/HomeQuickEntries.vue'
import HomeBusinessCards from './cpns/HomeBusinessCards.vue'
import HomeCaseShowcase from './cpns/HomeCaseShowcase.vue'
const homeStore = useHomeStore()
const { banners, stats, businessLines, featuredCases } = storeToRefs(homeStore)
const todaySummary = computed(() => `今天有${stats.value.inProgress}个项目正在进行`)
function onCategoryChange(category: BusinessType | 'all'): void {
void homeStore.fetchFeaturedCases(category)
}
onMounted(() => {
void homeStore.fetchHomeData()
})
</script>
<template>
<div class="home">
<!-- 设计稿头图为通栏(0..1920),文案层固定叠在轮播图之上 -->
<HomeBanner :banners="banners" />
<!-- 首页设计稿单独基准:内容区 1680 / 留白 120,故用 container--home -->
<div class="container container--home home__dashboard">
<section class="home__dashboard-main">
<HomeWelcome :summary="todaySummary" />
<HomeStats :stats="stats" />
</section>
<HomeQuickEntries />
</div>
<div class="container container--home">
<HomeBusinessCards :lines="businessLines" />
</div>
<div class="container container--home">
<HomeCaseShowcase
:cases="featuredCases"
@category-change="onCategoryChange"
/>
</div>
</div>
</template>
<style lang="less" scoped>
.home {
.flex(column, flex-start);
// 设计稿区块间距 ≈ 20px(内容区 1680,区块卡紧邻)
gap: 20px;
padding-top: 0;
padding-bottom: @spacing-xxl;
&__dashboard {
.flex(row, space-between, stretch);
// 设计稿左右卡间距 36px(左卡宽 922 / 右卡宽 722,内容区 1680)
gap: 36px;
}
&__dashboard-main {
.flex(row, space-between, center);
flex: 1;
min-width: 0; // 允许收缩,右侧快捷卡才能在窄视口让位
gap: @spacing-lg;
// 设计稿欢迎卡(120,754,922,245):白底 + 浅灰描边
padding: 0 73px 0 106px;
border: 1px solid @home-card-border;
border-radius: @radius-lg;
background: @white;
}
}
</style>