Files
cz-web/src/views/home/index.vue
2026-09-30 15:55:36 +08:00

84 lines
2.4 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.
<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 { stats, banners, 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),故不包 .container -->
<HomeBanner :banners="banners" />
<div class="container home__dashboard">
<section class="home__dashboard-main">
<HomeWelcome :summary="todaySummary" />
<HomeStats :stats="stats" />
</section>
<HomeQuickEntries />
</div>
<div class="container">
<HomeBusinessCards :lines="businessLines" />
</div>
<div class="container">
<HomeCaseShowcase
:cases="featuredCases"
@category-change="onCategoryChange"
/>
</div>
</div>
</template>
<style lang="less" scoped>
.home {
.flex(column, flex-start);
// 设计稿区块间距 19~20 设计px ≈ 16 CSS;头图紧贴顶栏
gap: @spacing-base;
padding-top: 0;
padding-bottom: @spacing-xxl;
&__dashboard {
.flex(row, space-between, stretch);
// 设计稿左右卡间距 36 设计px ≈ 28 CSS
gap: 28px;
// 设计稿区块行 1680 设计px 宽(内容区内左右各缩 50 设计px)≈ 1294 CSS
max-width: 1326px;
margin-right: auto;
margin-left: auto;
}
&__dashboard-main {
.flex(row, space-between, center);
flex: 1;
gap: @spacing-lg;
// 设计稿欢迎卡(120,754,922,245):白底 + 浅灰描边,内边距 61/106/66/73 设计px
padding: 46px 56px 46px 82px;
border: 1px solid @home-card-border;
border-radius: @radius-lg;
background: @white;
}
}
</style>