feat(home): 替换首页轮播图实现为广告系统驱动

- 移除原有的硬编码轮播图组件和相关样式
- 新增 getAdByCode 方法用于获取广告数据
- 实现解析广告数据的工具函数 parseSlides 和 parsePx
- 集成 useAsyncData 获取 flash 广告数据
- 添加备用图片以确保加载失败时的显示
- 更新页面样式适配新的轮播组件结构
This commit is contained in:
2026-01-29 14:31:40 +08:00
parent aaef9e0dba
commit 6070a8b9cd
2 changed files with 97 additions and 6 deletions

View File

@@ -30,10 +30,10 @@
</div>
</div>
<a-affix :offset-top="0">
<a-affix :offset-top="0" @change="onAffixChange">
<div class="navbar">
<div class="mx-auto flex max-w-screen-xl items-center justify-between gap-3 px-4">
<NuxtLink to="/" class="navbar-brand">
<div class="mx-auto flex max-w-screen-xl items-center justify-between gap-20 px-">
<NuxtLink v-if="isAffixed" to="/" class="navbar-brand" :class="{ 'navbar-brand-hidden': !isAffixed }">
<img class="navbar-logo" :src="logoUrl" :alt="siteName" />
<span class="navbar-brand-name">
{{ siteName }}
@@ -119,6 +119,7 @@ import { COMPANY } from '@/config/company'
const route = useRoute()
const open = ref(false)
const isAffixed = ref(false)
type HeaderNavItem = {
key: string
@@ -281,6 +282,10 @@ const todayText = computed(() => {
const pad = (n: number) => String(n).padStart(2, '0')
return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}日 星期${week}`
})
function onAffixChange(affixed: boolean) {
isAffixed.value = affixed
}
</script>
<style scoped>
@@ -362,11 +367,19 @@ const todayText = computed(() => {
.navbar-brand {
display: inline-flex;
align-items: center;
gap: 10px;
gap: 20px;
height: 48px;
text-decoration: none;
color: rgba(255, 255, 255, 0.95);
font-weight: 700;
transition: opacity 0.18s ease, transform 0.18s ease;
}
.navbar-brand-hidden {
opacity: 0;
visibility: hidden;
pointer-events: none;
transform: translateY(-4px);
}
.navbar-logo {
@@ -392,7 +405,7 @@ const todayText = computed(() => {
.nav {
display: flex;
gap: 2px;
gap: 10px;
}
.nav-link {