删除不再使用的文件,包括.gitignore、多个启动和配置指南文档,以及小程序相关的脚本和文档,简化项目结构以提高可维护性。
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
"use client"
|
||||
|
||||
import { useState, useEffect } from "react"
|
||||
import Link from "next/link"
|
||||
import { usePathname } from "next/navigation"
|
||||
import { Home, List, User, Users } from "lucide-react"
|
||||
|
||||
export function BottomNav() {
|
||||
const pathname = usePathname()
|
||||
const [matchEnabled, setMatchEnabled] = useState(false) // 默认隐藏,等配置加载后再显示
|
||||
const [configLoaded, setConfigLoaded] = useState(false) // 配置是否已加载
|
||||
|
||||
// 在文档页面、管理后台、阅读页面和关于页面不显示底部导航
|
||||
if (
|
||||
@@ -16,11 +19,32 @@ export function BottomNav() {
|
||||
) {
|
||||
return null
|
||||
}
|
||||
|
||||
// 加载功能配置
|
||||
useEffect(() => {
|
||||
const loadConfig = async () => {
|
||||
try {
|
||||
const res = await fetch('/api/db/config')
|
||||
const data = await res.json()
|
||||
if (data.features) {
|
||||
// 根据配置设置是否显示找伙伴按钮
|
||||
setMatchEnabled(data.features.matchEnabled === true)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Load feature config error:', e)
|
||||
// 加载失败时,默认不显示找伙伴按钮
|
||||
setMatchEnabled(false)
|
||||
} finally {
|
||||
setConfigLoaded(true)
|
||||
}
|
||||
}
|
||||
loadConfig()
|
||||
}, [])
|
||||
|
||||
const navItems = [
|
||||
{ href: "/", icon: Home, label: "首页" },
|
||||
{ href: "/chapters", icon: List, label: "目录" },
|
||||
{ href: "/match", icon: Users, label: "找伙伴", isCenter: true },
|
||||
...(matchEnabled ? [{ href: "/match", icon: Users, label: "找伙伴", isCenter: true }] : []),
|
||||
{ href: "/my", icon: User, label: "我的" },
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user