feat: 顶部栏添加3D翻转滚动广告
All checks were successful
continuous-integration/drone/push Build is passing

- header-left与header-right之间新增header-center
- 胶囊容器+Phosphor喇叭图标+彩色标签+文字
- 3D rotateX上翻动画(4秒自动切换)
- 悬停暂停+移开恢复
- 毛玻璃渐变背景+hover加深
- tag-blue/green/orange/red/purple五色标签
This commit is contained in:
yiqiu
2026-03-20 22:48:38 +08:00
parent a9435b88af
commit d00386b38c
2 changed files with 149 additions and 0 deletions

View File

@@ -88,6 +88,28 @@ const topMenu = {
</template>
</el-autocomplete>
</div>
<!-- 翻转滚动广告 -->
<div class="header-center" v-if="announcements.length > 0">
<div class="announce-ticker">
<i class="ph ph-megaphone-simple announce-icon"></i>
<div class="announce-flipper">
<transition :name="announceTransition" mode="out-in">
<a :key="announceIndex"
class="announce-item"
:href="announcements[announceIndex].url || 'javascript:void(0)'"
:target="announcements[announceIndex].url ? '_blank' : '_self'"
@mouseenter="pauseAnnounce"
@mouseleave="resumeAnnounce">
<span class="announce-tag" v-if="announcements[announceIndex].tag"
:class="'tag-' + (announcements[announceIndex].tagColor || 'blue')">
{{announcements[announceIndex].tag}}
</span>
<span class="announce-text">{{announcements[announceIndex].text}}</span>
</a>
</transition>
</div>
</div>
</div>
<div class="header-right">
<div class="header-right-item">
<div class="right-item home-btn" @click="goIndex">
@@ -237,6 +259,14 @@ const topMenu = {
host: lang.finance_info,
finance: lang.finance_text123,
},
announcements: [
{ text: '欢迎使用黑果云服务器管理面板', tag: '欢迎', tagColor: 'blue' },
{ text: '新用户注册即赠Ⅵ100体验金', tag: '活动', tagColor: 'green', url: '/finance.htm' },
{ text: '香港 CN2 GIA 高速节点放量中', tag: '上新', tagColor: 'orange', url: '/productList.htm' },
],
announceIndex: 0,
announceTimer: null,
announceTransition: 'announce-flip',
predefineColors: [
"#ff4500",
"#ff8c00",
@@ -302,6 +332,7 @@ const topMenu = {
this.doGetMenu();
this.getCartList();
this.getCommonSetting();
this.startAnnounceTicker();
},
mounted () {
// 不生效
@@ -438,6 +469,23 @@ const topMenu = {
}
}
},
// 公告翻转定时器
startAnnounceTicker () {
if (this.announcements.length > 1) {
this.announceTimer = setInterval(() => {
this.nextAnnounce();
}, 4000);
}
},
nextAnnounce () {
this.announceIndex = (this.announceIndex + 1) % this.announcements.length;
},
pauseAnnounce () {
clearInterval(this.announceTimer);
},
resumeAnnounce () {
this.startAnnounceTicker();
},
async changeLangHandle (e) {
try {
const res = await changeLanguage({