119 lines
2.7 KiB
Vue
119 lines
2.7 KiB
Vue
<template>
|
||
<view class="sections">
|
||
<view v-for="section in sections" :key="section.key" class="section">
|
||
<view v-if="section.title" class="section__head">
|
||
<view class="section__bar"></view>
|
||
<text class="section__title">{{ section.title }}</text>
|
||
</view>
|
||
<view class="grid">
|
||
<view
|
||
v-for="item in section.leaves"
|
||
:key="item.key"
|
||
class="grid__item"
|
||
hover-class="grid__item--active"
|
||
:hover-stay-time="80"
|
||
@click="emit('select', item)"
|
||
>
|
||
<view class="grid__icon">
|
||
<up-icon :name="item.icon || 'grid'" color="#2979ff" size="26"></up-icon>
|
||
</view>
|
||
<text class="grid__text">{{ item.title }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
/**
|
||
* 入口区展示组件:**段标题 + 子项九宫格**(多段)
|
||
*
|
||
* 只做展示与事件上抛,**不做任何取数 / 登录判断**:
|
||
* - 数据由 `useEntrySections()` 提供(首页与「我的」页共用同一份口径)
|
||
* - 点击后「要不要登录、跳哪个 API」由父页面的 `onEntry` 决定
|
||
*
|
||
* 用法:
|
||
* ```vue
|
||
* <entry-sections :sections="sections" @select="onEntry" />
|
||
* ```
|
||
*/
|
||
|
||
import type { EntryLeaf, EntrySection } from '@/router/entries'
|
||
|
||
defineProps<{
|
||
/** 由 `toSections()` 产出(已按分类分段) */
|
||
sections: EntrySection[]
|
||
}>()
|
||
|
||
const emit = defineEmits<{ (e: 'select', leaf: EntryLeaf): void }>()
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.sections {
|
||
padding: 4rpx 0 8rpx;
|
||
}
|
||
|
||
.section {
|
||
&__head {
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 28rpx 32rpx 4rpx;
|
||
}
|
||
|
||
/* 标题前的渐变小竖条:给每段一个视觉锚点,替代纯文字标题 */
|
||
&__bar {
|
||
width: 6rpx;
|
||
height: 26rpx;
|
||
margin-right: 14rpx;
|
||
border-radius: 4rpx;
|
||
background: linear-gradient(180deg, #2979ff 0%, #6aa8ff 100%);
|
||
}
|
||
|
||
&__title {
|
||
font-size: 28rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
}
|
||
}
|
||
|
||
.grid {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
padding: 8rpx 12rpx 24rpx;
|
||
|
||
&__item {
|
||
width: 33.333%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
padding: 20rpx 6rpx;
|
||
border-radius: 16rpx;
|
||
}
|
||
|
||
/* 点按反馈(hover-class 指向本类) */
|
||
&__item--active {
|
||
background-color: #f2f6ff;
|
||
}
|
||
|
||
&__icon {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 92rpx;
|
||
height: 92rpx;
|
||
border-radius: 26rpx;
|
||
background: linear-gradient(180deg, #eef4ff 0%, #e2ecff 100%);
|
||
}
|
||
|
||
&__text {
|
||
max-width: 100%;
|
||
margin-top: 14rpx;
|
||
font-size: 25rpx;
|
||
color: #4b5563;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
}
|
||
</style>
|