From 6070a8b9cdf7ba379427f5666397d6984e46a31a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com>
Date: Thu, 29 Jan 2026 14:31:40 +0800
Subject: [PATCH] =?UTF-8?q?feat(home):=20=E6=9B=BF=E6=8D=A2=E9=A6=96?=
=?UTF-8?q?=E9=A1=B5=E8=BD=AE=E6=92=AD=E5=9B=BE=E5=AE=9E=E7=8E=B0=E4=B8=BA?=
=?UTF-8?q?=E5=B9=BF=E5=91=8A=E7=B3=BB=E7=BB=9F=E9=A9=B1=E5=8A=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 移除原有的硬编码轮播图组件和相关样式
- 新增 getAdByCode 方法用于获取广告数据
- 实现解析广告数据的工具函数 parseSlides 和 parsePx
- 集成 useAsyncData 获取 flash 广告数据
- 添加备用图片以确保加载失败时的显示
- 更新页面样式适配新的轮播组件结构
---
app/components/Carousel.vue | 80 ++++++++++++++++++++++++++++++++++-
app/components/SiteHeader.vue | 23 +++++++---
2 files changed, 97 insertions(+), 6 deletions(-)
diff --git a/app/components/Carousel.vue b/app/components/Carousel.vue
index 631c4fe..7a34254 100644
--- a/app/components/Carousel.vue
+++ b/app/components/Carousel.vue
@@ -3,6 +3,7 @@
-
+
+
+
+
@@ -62,23 +87,41 @@ const props = withDefaults(
}
)
+type AntdCarouselExpose = {
+ next: () => void
+ prev: () => void
+ goTo: (slide: number, dontAnimate?: boolean) => void
+}
+
+const carouselRef = ref(null)
+
const heightCss = computed(() => (typeof props.height === 'number' ? `${props.height}px` : props.height))
const normalizedItems = computed(() => (props.items || []).filter((it) => it && typeof it.src === 'string' && it.src))
const autoplayEnabled = computed(() => normalizedItems.value.length > 1)
const dotsEnabled = computed(() => normalizedItems.value.length > 1)
+const showNav = computed(() => normalizedItems.value.length > 1)
const fallbackSrc = computed(() => normalizedItems.value[0]?.src || '')
function isExternal(href: string) {
return /^https?:\/\//i.test(href)
}
+
+function next() {
+ carouselRef.value?.next()
+}
+
+function prev() {
+ carouselRef.value?.prev()
+}
diff --git a/app/components/SiteHeader.vue b/app/components/SiteHeader.vue
index 411c0df..b9ac94d 100644
--- a/app/components/SiteHeader.vue
+++ b/app/components/SiteHeader.vue
@@ -30,10 +30,10 @@
-
+
-
-
+
+
{{ 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
+}