feat: admin config subscription

This commit is contained in:
shinya
2025-08-13 22:07:28 +08:00
parent 214aee1cb4
commit 6d4846d0b1
14 changed files with 227 additions and 259 deletions

View File

@@ -14,8 +14,6 @@ import {
useState,
} from 'react';
import { getCustomCategories } from '@/lib/config.client';
import { useSite } from './SiteProvider';
interface SidebarContextType {
@@ -150,18 +148,17 @@ const Sidebar = ({ onToggle, activePath = '/' }: SidebarProps) => {
]);
useEffect(() => {
getCustomCategories().then((categories) => {
if (categories.length > 0) {
setMenuItems((prevItems) => [
...prevItems,
{
icon: Star,
label: '自定义',
href: '/douban?type=custom',
},
]);
}
});
const runtimeConfig = (window as any).RUNTIME_CONFIG;
if (runtimeConfig?.CUSTOM_CATEGORIES?.length > 0) {
setMenuItems((prevItems) => [
...prevItems,
{
icon: Star,
label: '自定义',
href: '/douban?type=custom',
},
]);
}
}, []);
return (