diff --git a/packages/napcat-webui-frontend/src/components/onebot/api/debug.tsx b/packages/napcat-webui-frontend/src/components/onebot/api/debug.tsx index aa5b416f..19ecbed9 100644 --- a/packages/napcat-webui-frontend/src/components/onebot/api/debug.tsx +++ b/packages/napcat-webui-frontend/src/components/onebot/api/debug.tsx @@ -320,7 +320,7 @@ const OneBotApiDebug = forwardRef((props )} - diff --git a/packages/napcat-webui-frontend/src/components/onebot/api/nav_list.tsx b/packages/napcat-webui-frontend/src/components/onebot/api/nav_list.tsx deleted file mode 100644 index 7cce84c4..00000000 --- a/packages/napcat-webui-frontend/src/components/onebot/api/nav_list.tsx +++ /dev/null @@ -1,182 +0,0 @@ -import { Input } from '@heroui/input'; -import { useLocalStorage } from '@uidotdev/usehooks'; -import clsx from 'clsx'; -import { AnimatePresence, motion } from 'motion/react'; -import { useMemo, useState } from 'react'; -import { TbChevronRight, TbFolder, TbSearch } from 'react-icons/tb'; - -import key from '@/const/key'; -import oneBotHttpApiGroup from '@/const/ob_api/group'; -import oneBotHttpApiMessage from '@/const/ob_api/message'; -import oneBotHttpApiSystem from '@/const/ob_api/system'; -import oneBotHttpApiUser from '@/const/ob_api/user'; -import type { OneBotHttpApi, OneBotHttpApiPath } from '@/const/ob_api'; - -export interface OneBotApiNavListProps { - data: OneBotHttpApi; - selectedApi: OneBotHttpApiPath; - onSelect: (apiName: OneBotHttpApiPath) => void; - openSideBar: boolean; - onToggle?: (isOpen: boolean) => void; -} - -const OneBotApiNavList: React.FC = (props) => { - const { data, selectedApi, onSelect, openSideBar, onToggle } = props; - const [searchValue, setSearchValue] = useState(''); - const [expandedGroups, setExpandedGroups] = useState([]); - const [backgroundImage] = useLocalStorage(key.backgroundImage, ''); - const hasBackground = !!backgroundImage; - - const groups = useMemo(() => { - const rawGroups = [ - { id: 'user', label: '账号相关', keys: Object.keys(oneBotHttpApiUser) }, - { id: 'message', label: '消息相关', keys: Object.keys(oneBotHttpApiMessage) }, - { id: 'group', label: '群聊相关', keys: Object.keys(oneBotHttpApiGroup) }, - { id: 'system', label: '系统操作', keys: Object.keys(oneBotHttpApiSystem) }, - ]; - - return rawGroups.map(g => { - const apis = g.keys - .filter(k => k in data) - .map(k => ({ path: k as OneBotHttpApiPath, ...data[k as OneBotHttpApiPath] })) - .filter(api => - api.path.toLowerCase().includes(searchValue.toLowerCase()) || - api.description?.toLowerCase().includes(searchValue.toLowerCase()) - ); - return { ...g, apis }; - }).filter(g => g.apis.length > 0); - }, [data, searchValue]); - - const toggleGroup = (id: string) => { - setExpandedGroups(prev => - prev.includes(id) ? prev.filter(i => i !== id) : [...prev, id] - ); - }; - - return ( - <> - {/* Mobile backdrop overlay - below header (z-40) */} - - {openSideBar && ( - onToggle?.(false)} - /> - )} - - - -
-
- } - value={searchValue} - onChange={(e) => setSearchValue(e.target.value)} - onClear={() => setSearchValue('')} - size="sm" - /> -
- -
- {groups.map((group) => { - const isOpen = expandedGroups.includes(group.id) || searchValue.length > 0; - return ( -
- {/* Group Header */} -
toggleGroup(group.id)} - > - - - {group.label} - ({group.apis.length}) -
- - {/* Group Content */} - - {isOpen && ( - - {group.apis.map((api) => { - const isSelected = api.path === selectedApi; - return ( -
onSelect(api.path)} - className={clsx( - 'flex flex-col gap-0.5 px-3 py-2 rounded-lg cursor-pointer transition-all border select-none', - isSelected - ? (hasBackground - ? 'bg-white/10 border-white/20' - : 'bg-primary/10 border-primary/20 shadow-sm') - : 'border-transparent hover:bg-white/10 dark:hover:bg-white/5' - )} - > - - {api.description} - - - {api.path} - -
- ); - })} -
- )} -
-
- ); - })} -
-
-
- - ); -}; - -export default OneBotApiNavList;