"use client"; import { faSearch } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import clsx from "clsx"; import { useMemo, useState } from "react"; import Logo from "./Logo"; export type SearchTypeItem = { name: string; key: string; includes: string[]; priority: number; } export type SearchWayItemType = { label: string; value: string; fullName: string; key: string; } export const SearchTypeList: SearchTypeItem[] = [ { name: '常用', key: 'custom', includes: ['inside', 'bing'], priority: 0 }, { name: '搜索', key: 'search', includes: ['101'], priority: 0 }, { name: '社区', key: 'community', includes: ['101'], priority: 0 }, { name: '图片', key: 'picture', includes: ['101'], priority: 0 }, { name: '生活', key: 'life', includes: ['101'], priority: 0 } ] export const SearchWayItem: SearchWayItemType[] = [ { label: '站内', value: '', fullName: '站内资源', key: 'inside', }, { label: 'Bing', fullName: '站内资源', value: 'https://bing.com', key: 'bing' } ] export default function Search() { const [selectKey, setSelectKey] = useState(SearchTypeList[0].key) const nowSelectConfig = useMemo(() => { const idx = SearchTypeList.findIndex(val => val.key === selectKey) if (idx !== -1) return SearchTypeList[idx] else return null }, [selectKey]) const [activeSearchKey, setActiveSearchKey] = useState(nowSelectConfig?.includes[0]) const activeSearch = useMemo(() => { const idx = SearchWayItem.findIndex(val => val.key === activeSearchKey) if (idx !== -1) { return SearchWayItem[idx] } else { return null } }, [activeSearchKey]) return (