238 lines
6.0 KiB
Vue
238 lines
6.0 KiB
Vue
<template>
|
|
<a-layout class="bottom-nav">
|
|
<a-layout-content class="nav-content">
|
|
<button class="nav-item" :class="{ active: currentRoute === 'home' }" type="button" @click="handleNavClick('home')">
|
|
<a-badge :count="0" :offset="[0, 0]">
|
|
<div class="nav-icon">
|
|
<HomeOutlined :style="{ fontSize: '25px' }" />
|
|
</div>
|
|
</a-badge>
|
|
<span class="nav-label">首页</span>
|
|
</button>
|
|
|
|
<button class="nav-item" :class="{ active: currentRoute === 'products' }" type="button" @click="handleNavClick('products')">
|
|
<a-badge :count="0" :offset="[0, 0]">
|
|
<div class="nav-icon">
|
|
<ShoppingOutlined :style="{ fontSize: '25px' }" />
|
|
</div>
|
|
</a-badge>
|
|
<span class="nav-label">作品集</span>
|
|
</button>
|
|
|
|
<button class="nav-item" :class="{ active: currentRoute === 'profile' }" type="button" @click="handleNavClick('profile')">
|
|
<a-badge :dot="hasNotification" :offset="[0, 0]">
|
|
<div class="nav-icon">
|
|
<UserOutlined :style="{ fontSize: '25px' }" />
|
|
</div>
|
|
</a-badge>
|
|
<span class="nav-label">我的</span>
|
|
</button>
|
|
</a-layout-content>
|
|
</a-layout>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
/**
|
|
* BottomNav page script.
|
|
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
|
*/
|
|
import { computed } from 'vue'
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
import { HomeOutlined, ShoppingOutlined, UserOutlined } from '@ant-design/icons-vue'
|
|
|
|
/**
|
|
* Purpose: router supports BottomNav.vue by holding or executing the router page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const router = useRouter()
|
|
/**
|
|
* Purpose: route supports BottomNav.vue by holding or executing the route page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const route = useRoute()
|
|
|
|
// 是否有未读通知
|
|
/** hasNotification is a reactive state variable used by the template and event handlers. */
|
|
const hasNotification = computed(() => true)
|
|
|
|
// 根据当前路由判断激活的导航项
|
|
/** currentRoute is a reactive state variable used by the template and event handlers. */
|
|
const currentRoute = computed(() => {
|
|
if (!route || !route.path) return 'home'
|
|
const path = route.path
|
|
if (path === '/') return 'home'
|
|
if (path === '/products') return 'products'
|
|
if (path === '/product') return 'products'
|
|
if (path === '/profile') return 'profile'
|
|
return 'home'
|
|
})
|
|
|
|
// 处理导航点击事件
|
|
/** handleNavClick is a local helper used by this page script. */
|
|
const handleNavClick = (tab: string) => {
|
|
if (tab === 'home') {
|
|
router.push('/home')
|
|
} else if (tab === 'products') {
|
|
router.push('/products')
|
|
} else if (tab === 'profile') {
|
|
router.push('/profile')
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.bottom-nav {
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
width: 100%;
|
|
height: 64px;
|
|
background: color-mix(in srgb, var(--theme-card-bg) 96%, transparent);
|
|
border-top: 1px solid var(--theme-border);
|
|
box-shadow: 0 -14px 34px color-mix(in srgb, var(--theme-neutral) 10%, transparent);
|
|
z-index: 1000;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
overflow: hidden;
|
|
backdrop-filter: blur(18px);
|
|
backface-visibility: hidden;
|
|
will-change: transform;
|
|
transform: translateZ(0);
|
|
transition: none !important;
|
|
}
|
|
|
|
.nav-content {
|
|
display: flex;
|
|
justify-content: space-around;
|
|
align-items: center;
|
|
height: 100%;
|
|
width: 100%;
|
|
max-width: none;
|
|
margin: 0 auto;
|
|
padding: 0 12px calc(env(safe-area-inset-bottom, 0px) / 2);
|
|
transition: none !important;
|
|
}
|
|
|
|
.nav-item {
|
|
appearance: none;
|
|
border: 0;
|
|
background: transparent;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 3px;
|
|
min-width: 58px;
|
|
min-height: 54px;
|
|
padding: 6px 8px;
|
|
cursor: pointer;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.nav-item:hover {
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.nav-item.active {
|
|
color: var(--theme-primary-action);
|
|
}
|
|
|
|
.nav-item.active .nav-icon {
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.nav-icon {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 40px;
|
|
height: 34px;
|
|
margin-bottom: 0;
|
|
border-radius: 18px 18px 16px 16px;
|
|
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
color: var(--text-secondary);
|
|
opacity: 1;
|
|
}
|
|
|
|
.nav-item.active .nav-icon {
|
|
color: var(--theme-primary-action);
|
|
background: color-mix(in srgb, var(--theme-primary) 34%, var(--theme-card-bg));
|
|
}
|
|
|
|
.nav-label {
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
color: var(--text-secondary);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.nav-item.active .nav-label {
|
|
color: var(--theme-primary-action);
|
|
}
|
|
|
|
.nav-item :deep(.ant-badge-count) {
|
|
min-width: 16px;
|
|
height: 16px;
|
|
line-height: 16px;
|
|
background: var(--theme-primary-action);
|
|
box-shadow: 0 0 0 1px var(--theme-card-bg);
|
|
}
|
|
|
|
.nav-item :deep(.ant-badge-dot) {
|
|
background: var(--theme-secondary);
|
|
box-shadow: 0 0 0 1px var(--theme-card-bg);
|
|
}
|
|
|
|
@media (max-width: 359px) {
|
|
.bottom-nav {
|
|
height: 56px;
|
|
}
|
|
|
|
.nav-content {
|
|
padding: 0 4px;
|
|
}
|
|
|
|
.nav-item {
|
|
min-width: 0;
|
|
padding: 8px 4px;
|
|
border-radius: 10px;
|
|
}
|
|
|
|
.nav-icon {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.nav-icon :deep(.anticon) {
|
|
font-size: 22px !important;
|
|
}
|
|
|
|
.nav-label {
|
|
display: none;
|
|
}
|
|
}
|
|
|
|
@media (min-width: 768px) {
|
|
.nav-content {
|
|
max-width: var(--frontend-page-max-width);
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<style>
|
|
@media (min-width: 768px) {
|
|
.jayucloud-salon-phone-frame > .bottom-nav {
|
|
right: auto;
|
|
bottom: 0;
|
|
left: 50%;
|
|
width: var(--frontend-page-max-width);
|
|
max-width: calc(100vw - 48px);
|
|
border-bottom-right-radius: 32px;
|
|
border-bottom-left-radius: 32px;
|
|
transform: translateX(-50%) translateZ(0);
|
|
}
|
|
}
|
|
</style>
|