调整tab

This commit is contained in:
谢宇宁
2026-09-22 15:20:09 +07:00
parent fd59966d8f
commit 550a3cc02f
4 changed files with 42 additions and 15 deletions
+19 -3
View File
@@ -1,6 +1,20 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import HomeApi from '@/service/home'; import HomeApi from '@/service/home';
/** 主页固定注入的「热门短剧」tab(从短剧频道挪过来),不走后端模块 */
export const HOT_DRAMA_TAB_ID = '-120';
/** 「热门短剧」固定排第二个:没有就插入,本地排序/抽屉拖动挪走了就统一挪回来 */
const pinHotDrama = (list: Types.Home.HomeTabItem[]) => {
const result = list.filter((item) => item.id !== HOT_DRAMA_TAB_ID);
const hotDrama = list.find((item) => item.id === HOT_DRAMA_TAB_ID) || {
id: HOT_DRAMA_TAB_ID,
moduleName: '热门短剧',
};
result.splice(Math.min(1, result.length), 0, hotDrama as Types.Home.HomeTabItem);
return result;
};
export const useGlobalStore = defineStore({ export const useGlobalStore = defineStore({
id: 'global', id: 'global',
state: () => { state: () => {
@@ -327,10 +341,12 @@ export const useGlobalStore = defineStore({
sortedArr.push(item); sortedArr.push(item);
} }
}); });
this.homePageList = sortedArr; this.homePageList = pinHotDrama(sortedArr);
} else { } else {
this.homePageList = homePage; this.homePageList = pinHotDrama(homePage);
} }
// 默认选中「热门短剧」
this.activeIndex = this.homePageList.findIndex((item) => item.id === HOT_DRAMA_TAB_ID);
} }
if (deepWeb) { if (deepWeb) {
const ids = (localStorage.getItem('darkNetPageIds') || '').split(','); const ids = (localStorage.getItem('darkNetPageIds') || '').split(',');
@@ -431,7 +447,7 @@ export const useGlobalStore = defineStore({
switch (elType) { switch (elType) {
case 'home': case 'home':
this.homePageList = arr; this.homePageList = pinHotDrama(arr);
break; break;
case 'darkNet': case 'darkNet':
this.darkNetPageList = arr; this.darkNetPageList = arr;
+5 -2
View File
@@ -23,6 +23,8 @@
<i v-if="showTabUpdateDot(item, index)" class="home-tab-red-dot" /> <i v-if="showTabUpdateDot(item, index)" class="home-tab-red-dot" />
</span> </span>
</template> </template>
<!-- 热门短剧:从短剧频道挪过来的固定 tab -->
<HotDramaList v-if="item.id === HOT_DRAMA_TAB_ID" embedded />
<!-- 模块普通海角系样式 : 1 --> <!-- 模块普通海角系样式 : 1 -->
<HomeItem <HomeItem
:moduleId="item.id" :moduleId="item.id"
@@ -30,7 +32,7 @@
:showType="item.showType" :showType="item.showType"
:type="item.type" :type="item.type"
:haiJiaoStyle="item.haiJiaoStyle" :haiJiaoStyle="item.haiJiaoStyle"
v-if="[1].includes(item.showType)" v-else-if="[1].includes(item.showType)"
:pureVersion="item.pureVersion" :pureVersion="item.pureVersion"
/> />
<!-- 最新 --> <!-- 最新 -->
@@ -65,11 +67,12 @@ export default {
</script> </script>
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, computed, onActivated, onDeactivated, nextTick, watch, onUnmounted, ref } from 'vue'; import { reactive, computed, onActivated, onDeactivated, nextTick, watch, onUnmounted, ref } from 'vue';
import { useGlobalStore } from '@/stores/global'; import { useGlobalStore, HOT_DRAMA_TAB_ID } from '@/stores/global';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { setShowBackTopBtn } from '@/utils/homeCombinedFunc'; import { setShowBackTopBtn } from '@/utils/homeCombinedFunc';
import HomeItem from './components/HomeItem.vue'; import HomeItem from './components/HomeItem.vue';
import Newest from './components/Newest.vue'; import Newest from './components/Newest.vue';
import HotDramaList from '@/views/shortVideo/short-drama/HotDramaList.vue';
import PaymentGuidePopup from '@/components/PaymentGuidePopup/index.vue'; import PaymentGuidePopup from '@/components/PaymentGuidePopup/index.vue';
import { shouldShowHomeTabUpdateDot, markHomeTabViewed } from '@/utils/contentUpdateMarkers'; import { shouldShowHomeTabUpdateDot, markHomeTabViewed } from '@/utils/contentUpdateMarkers';
import { usePaymentGuide } from '@/hooks/usePaymentGuide'; import { usePaymentGuide } from '@/hooks/usePaymentGuide';
+3 -9
View File
@@ -21,7 +21,6 @@
<!-- 抖音 = 原推荐流,逻辑保持不变 --> <!-- 抖音 = 原推荐流,逻辑保持不变 -->
<RecommendItem :isActive="state.tabActive == 3" v-if="state.tabActive == 3" /> <RecommendItem :isActive="state.tabActive == 3" v-if="state.tabActive == 3" />
<AiDramaFeed :isActive="state.tabActive == 4" v-else-if="state.tabActive == 4" /> <AiDramaFeed :isActive="state.tabActive == 4" v-else-if="state.tabActive == 4" />
<HotDramaList :isActive="state.tabActive == 5" v-else-if="state.tabActive == 5" />
<!-- 评论弹窗:抖音 objType=video;短剧 objType=drama --> <!-- 评论弹窗:抖音 objType=video;短剧 objType=drama -->
<CommentBox <CommentBox
ref="commentRef" ref="commentRef"
@@ -42,7 +41,6 @@ export default {
import { ref, reactive, nextTick, provide, computed } from 'vue'; import { ref, reactive, nextTick, provide, computed } from 'vue';
import RecommendItem from './recommendItem.vue'; import RecommendItem from './recommendItem.vue';
import AiDramaFeed from './short-drama/AiDramaFeed.vue'; import AiDramaFeed from './short-drama/AiDramaFeed.vue';
import HotDramaList from './short-drama/HotDramaList.vue';
import liveItem from '@/views/lldlive/tabPage.vue'; import liveItem from '@/views/lldlive/tabPage.vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useAppStore } from '@/stores/app'; import { useAppStore } from '@/stores/app';
@@ -53,8 +51,8 @@ const route = useRoute();
const resolveTabActive = () => { const resolveTabActive = () => {
const type = route.query.type ? Number(route.query.type) : 4; const type = route.query.type ? Number(route.query.type) : 4;
// 原「最新」tab(value=2) 已下线,兜底到 AI短剧 // 原「最新」tab(value=2) 已下线、「热门短剧」(value=5) 已挪到主页,兜底到 AI短剧
if (type === 2) return 4; if (type === 2 || type === 5) return 4;
return type; return type;
}; };
@@ -77,10 +75,6 @@ const state = reactive({
label: 'AI短剧', label: 'AI短剧',
value: 4, value: 4,
}, },
{
label: '热门短剧',
value: 5,
},
], ],
isCommentPopup: false, isCommentPopup: false,
commentObjType: 'video', commentObjType: 'video',
@@ -151,7 +145,7 @@ provide('openCommentPopup', openCommentPopup);
} }
.van-tab { .van-tab {
font-size: 14px; font-size: 14px;
padding: 0 12px; padding: 0 20px;
flex: none; flex: none;
} }
.van-tab--active { .van-tab--active {
@@ -1,5 +1,5 @@
<template> <template>
<div class="hot-drama-list"> <div class="hot-drama-list" :class="{ embedded }">
<div class="list-header"> <div class="list-header">
<div class="sort-bar"> <div class="sort-bar">
<template v-for="(item, index) in sortOptions" :key="item.value"> <template v-for="(item, index) in sortOptions" :key="item.value">
@@ -38,6 +38,8 @@ import { useHotDramaList } from './hooks/useHotDramaList';
defineProps<{ defineProps<{
isActive?: boolean; isActive?: boolean;
/** 嵌在主页 tab 里:跟随主页子页高度与背景,不再给短剧频道顶部菜单让位 */
embedded?: boolean;
}>(); }>();
const router = useRouter(); const router = useRouter();
@@ -129,5 +131,17 @@ onMounted(() => {
flex-wrap: wrap; flex-wrap: wrap;
gap: 12px 7px; gap: 12px 7px;
} }
&.embedded {
position: relative;
inset: auto;
height: calc(100vh - 44px * 2 - 55px);
padding-top: 0;
background: transparent;
.list-header {
background: transparent;
}
}
} }
</style> </style>