diff --git a/src/pages/news/components/search-panel.tsx b/src/pages/news/components/search-panel.tsx index 14871b7..86b3cf9 100644 --- a/src/pages/news/components/search-panel.tsx +++ b/src/pages/news/components/search-panel.tsx @@ -1,13 +1,13 @@ import {Input} from "antd"; -import {useBoolean, useLocalStorageState, useSetState} from "ahooks"; -import {useMemo, useState} from "react"; +import {useBoolean, useLocalStorageState, useSetState,useClickAway} from "ahooks"; +import {useCallback, useMemo, useRef, useState} from "react"; +import {clsx} from "clsx"; import useArticleTags from "@/hooks/useArticleTags.ts"; -import {CloseOutlined, MenuOutlined, SearchOutlined} from "@ant-design/icons"; +import {UpOutlined, MenuOutlined, SearchOutlined} from "@ant-design/icons"; import TimeSelect from "@/components/form/time-select.tsx"; import styles from './style.module.scss' -import {clsx} from "clsx"; import {IconPin} from "@/components/icons"; type SearchPanelProps = { @@ -23,7 +23,7 @@ const DEFAULT_STATE = { } export default function SearchPanel({onSearch}: SearchPanelProps) { const tags = useArticleTags(); - const [panelVisible, {setTrue, setFalse}] = useBoolean(false) + const [panelVisible, {set}] = useBoolean(false) const [params, setParams] = useSetState({ pagination, time_flag:1 @@ -89,6 +89,29 @@ export default function SearchPanel({onSearch}: SearchPanelProps) { } return [] as OptionItem[]; }, [pinnedTag, tags]) + const pinnedManagePanel = useRef(null) + + const togglePinnedManagePanel = useCallback((visible: boolean) => { + if(!pinnedManagePanel.current){ + return; + } + const _target = pinnedManagePanel.current!; + if(visible){ + _target.style.height = 'auto' + const {height} = _target.getBoundingClientRect() + _target.style.height = '38px' + requestAnimationFrame(()=>{ + _target.style.height = `${height}px` + }) + }else{ + requestAnimationFrame(()=>{ + _target.style.height = '0' + }) + } + },[pinnedManagePanel]) + const setTrue = ()=> togglePinnedManagePanel(true) + const setFalse = ()=>togglePinnedManagePanel(false) + useClickAway(() => setFalse(), pinnedManagePanel) return (
@@ -109,18 +132,17 @@ export default function SearchPanel({onSearch}: SearchPanelProps) { />
-
+
-
-
{ - handleFilter({tag_level_1_id: -1, tag_level_2_id: -1}) - setSubOptions([]) - }}>全部 -
- -
+
+
+
{ + handleFilter({tag_level_1_id: -1, tag_level_2_id: -1}) + setSubOptions([]) + }}>全部 +
{pinnedList.filter(s => (Number(s.value) !== 999999)).map(it => ( {it.label}) )}
-
- +
+ { + e.stopPropagation(); + e.preventDefault(); + setTrue(); + }}>
+ +
{/* 固定新闻来源 */} -
+
新闻来源
- +
+ +
{ @@ -166,6 +195,7 @@ export default function SearchPanel({onSearch}: SearchPanelProps) { }
+
{/* 二级目录 */} {state.tag_level_1_id != -1 && subOptions.length > 0 &&