修正观影室管理面板设置

This commit is contained in:
mtvpls
2025-12-08 10:03:25 +08:00
parent 857f7ce73e
commit b99a495a8a
7 changed files with 322 additions and 68 deletions
+53 -15
View File
@@ -7,6 +7,8 @@ import Link from 'next/link';
import { usePathname, useSearchParams } from 'next/navigation';
import { useEffect, useState } from 'react';
import { useWatchRoomContextSafe } from './WatchRoomProvider';
interface MobileBottomNavProps {
/**
* 主动指定当前激活的路径。当未提供时,自动使用 usePathname() 获取的路径。
@@ -17,6 +19,7 @@ interface MobileBottomNavProps {
const MobileBottomNav = ({ activePath }: MobileBottomNavProps) => {
const pathname = usePathname();
const searchParams = useSearchParams();
const watchRoomContext = useWatchRoomContextSafe();
// 直接使用当前路由状态,确保立即响应路由变化
const getCurrentFullPath = () => {
@@ -52,26 +55,61 @@ const MobileBottomNav = ({ activePath }: MobileBottomNavProps) => {
label: '直播',
href: '/live',
},
{
icon: Users,
label: '观影室',
href: '/watch-room',
},
]);
useEffect(() => {
const runtimeConfig = (window as any).RUNTIME_CONFIG;
if (runtimeConfig?.CUSTOM_CATEGORIES?.length > 0) {
setNavItems((prevItems) => [
...prevItems,
{
icon: Star,
label: '自定义',
href: '/douban?type=custom',
},
]);
// 基础导航项(不包括观影室)
let items = [
{ icon: Home, label: '首页', href: '/' },
{
icon: Film,
label: '电影',
href: '/douban?type=movie',
},
{
icon: Tv,
label: '剧集',
href: '/douban?type=tv',
},
{
icon: Cat,
label: '动漫',
href: '/douban?type=anime',
},
{
icon: Clover,
label: '综艺',
href: '/douban?type=show',
},
{
icon: Radio,
label: '直播',
href: '/live',
},
];
// 如果启用观影室,添加观影室入口
if (watchRoomContext?.isEnabled) {
items.push({
icon: Users,
label: '观影室',
href: '/watch-room',
});
}
}, []);
// 添加自定义分类(如果有)
if (runtimeConfig?.CUSTOM_CATEGORIES?.length > 0) {
items.push({
icon: Star,
label: '自定义',
href: '/douban?type=custom',
});
}
setNavItems(items);
}, [watchRoomContext?.isEnabled]);
const isActive = (href: string) => {
const typeMatch = href.match(/type=([^&]+)/)?.[1];