From 550a3cc02fcf9189b50f3ac6993276259f481623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E5=AE=87=E5=AE=81?= Date: Tue, 22 Sep 2026 15:20:09 +0700 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4tab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/global.ts | 22 ++++++++++++++++--- src/views/lldhome/index.vue | 7 ++++-- src/views/shortVideo/index.vue | 12 +++------- .../shortVideo/short-drama/HotDramaList.vue | 16 +++++++++++++- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/stores/global.ts b/src/stores/global.ts index c214ff3..f3e78a5 100644 --- a/src/stores/global.ts +++ b/src/stores/global.ts @@ -1,6 +1,20 @@ import { defineStore } from 'pinia'; 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({ id: 'global', state: () => { @@ -327,10 +341,12 @@ export const useGlobalStore = defineStore({ sortedArr.push(item); } }); - this.homePageList = sortedArr; + this.homePageList = pinHotDrama(sortedArr); } else { - this.homePageList = homePage; + this.homePageList = pinHotDrama(homePage); } + // 默认选中「热门短剧」 + this.activeIndex = this.homePageList.findIndex((item) => item.id === HOT_DRAMA_TAB_ID); } if (deepWeb) { const ids = (localStorage.getItem('darkNetPageIds') || '').split(','); @@ -431,7 +447,7 @@ export const useGlobalStore = defineStore({ switch (elType) { case 'home': - this.homePageList = arr; + this.homePageList = pinHotDrama(arr); break; case 'darkNet': this.darkNetPageList = arr; diff --git a/src/views/lldhome/index.vue b/src/views/lldhome/index.vue index fea74a6..3f40624 100644 --- a/src/views/lldhome/index.vue +++ b/src/views/lldhome/index.vue @@ -23,6 +23,8 @@ + + @@ -65,11 +67,12 @@ export default {