修正观影室管理面板设置
This commit is contained in:
+51
-15
@@ -15,6 +15,7 @@ import {
|
||||
} from 'react';
|
||||
|
||||
import { useSite } from './SiteProvider';
|
||||
import { useWatchRoomContextSafe } from './WatchRoomProvider';
|
||||
|
||||
interface SidebarContextType {
|
||||
isCollapsed: boolean;
|
||||
@@ -59,6 +60,7 @@ declare global {
|
||||
const Sidebar = ({ onToggle, activePath = '/' }: SidebarProps) => {
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
const watchRoomContext = useWatchRoomContextSafe();
|
||||
// 若同一次 SPA 会话中已经读取过折叠状态,则直接复用,避免闪烁
|
||||
const [isCollapsed, setIsCollapsed] = useState<boolean>(() => {
|
||||
if (
|
||||
@@ -143,26 +145,60 @@ const Sidebar = ({ onToggle, activePath = '/' }: SidebarProps) => {
|
||||
label: '直播',
|
||||
href: '/live',
|
||||
},
|
||||
{
|
||||
icon: Users,
|
||||
label: '观影室',
|
||||
href: '/watch-room',
|
||||
},
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
const runtimeConfig = (window as any).RUNTIME_CONFIG;
|
||||
if (runtimeConfig?.CUSTOM_CATEGORIES?.length > 0) {
|
||||
setMenuItems((prevItems) => [
|
||||
...prevItems,
|
||||
{
|
||||
icon: Star,
|
||||
label: '自定义',
|
||||
href: '/douban?type=custom',
|
||||
},
|
||||
]);
|
||||
|
||||
// 基础菜单项(不包括观影室)
|
||||
let items = [
|
||||
{
|
||||
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',
|
||||
});
|
||||
}
|
||||
|
||||
setMenuItems(items);
|
||||
}, [watchRoomContext?.isEnabled]);
|
||||
|
||||
return (
|
||||
<SidebarContext.Provider value={contextValue}>
|
||||
|
||||
Reference in New Issue
Block a user