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

@@ -7,8 +7,6 @@ import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { useEffect, useState } from 'react';
import { getCustomCategories } from '@/lib/config.client';
interface MobileBottomNavProps {
/**
* 主动指定当前激活的路径。当未提供时,自动使用 usePathname() 获取的路径。
@@ -48,18 +46,17 @@ const MobileBottomNav = ({ activePath }: MobileBottomNavProps) => {
]);
useEffect(() => {
getCustomCategories().then((categories) => {
if (categories.length > 0) {
setNavItems((prevItems) => [
...prevItems,
{
icon: Star,
label: '自定义',
href: '/douban?type=custom',
},
]);
}
});
const runtimeConfig = (window as any).RUNTIME_CONFIG;
if (runtimeConfig?.CUSTOM_CATEGORIES?.length > 0) {
setNavItems((prevItems) => [
...prevItems,
{
icon: Star,
label: '自定义',
href: '/douban?type=custom',
},
]);
}
}, []);
const isActive = (href: string) => {
@@ -101,8 +98,8 @@ const MobileBottomNav = ({ activePath }: MobileBottomNavProps) => {
>
<item.icon
className={`h-6 w-6 ${active
? 'text-green-600 dark:text-green-400'
: 'text-gray-500 dark:text-gray-400'
? 'text-green-600 dark:text-green-400'
: 'text-gray-500 dark:text-gray-400'
}`}
/>
<span