diff --git a/src/routers/layout/nav/index.tsx b/src/routers/layout/nav/index.tsx index f079a57..43e3dbe 100644 --- a/src/routers/layout/nav/index.tsx +++ b/src/routers/layout/nav/index.tsx @@ -45,7 +45,7 @@ import { selectVideoActiveTags, } from "@store/tags/index"; -function useSelectList() { +export function useTagSelectList() { const { pathname } = useLocation(), flag = pathname === "/photo", storageSelect = flag ? PhotoNavStorage : VideoNavStorage; @@ -61,7 +61,7 @@ type HeaderNavType = { export default function Header_Nav(props: HeaderNavType) { const { shouldShow = false } = props; - const { navLists, setLists, storageSelect } = useSelectList(); + const { navLists, setLists, storageSelect } = useTagSelectList(); //tag区是否展开 const showed = useAppSelector(selectNavMoreShowed); //拖拽事件绑定 @@ -223,10 +223,11 @@ const NavTagChipItem: FC = memo( const color = nameToColor[props.query] || "info"; return ( ); return ( diff --git a/src/routers/layout/rightSide/index.tsx b/src/routers/layout/rightSide/index.tsx deleted file mode 100644 index aeec436..0000000 --- a/src/routers/layout/rightSide/index.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { Avatar } from "@mui/material"; - -export default function RightSide() { - return App; -} diff --git a/src/store/tags/index.ts b/src/store/tags/index.ts index 803ef06..293211f 100644 --- a/src/store/tags/index.ts +++ b/src/store/tags/index.ts @@ -8,6 +8,7 @@ import { PhotoQueryNavList, } from "@routers/layout/nav/photoTools"; import type { RootState } from ".."; +import { useAppDispatch, useAppSelector } from "@store/hooks"; const Photo_Topic_id_all = PhotoQueryNavList.find( (item) => item.queryString === 0 @@ -23,12 +24,16 @@ interface TagStates { /** * @description video页面点击tags */ - VideoActiveTags: VideoNavQueryItemType[]; + VideoActiveTags: VideoTagsType; /** * @description photo page active tags */ - PhotoActivetags: PhotoNavQueryItemType[]; + PhotoActivetags: photoTagsType; } + +type VideoTagsType = VideoNavQueryItemType[]; +type photoTagsType = PhotoNavQueryItemType[]; + const initialState: TagStates = { VideoActiveTags: [Video_default_show], PhotoActivetags: [Photo_Topic_id_all, Photo_type_default], @@ -122,3 +127,37 @@ export const selectVideoActiveTags = (state: RootState) => selectPhotoActiveTags = (state: RootState) => state.ActiveTags.PhotoActivetags; export default ActiveTagsSlice.reducer; + +export const useSelectVideoActiveTags = () => + useAppSelector(selectVideoActiveTags), + useSelectPhotoActiveTags = () => useAppSelector(selectPhotoActiveTags); +export const useStoreVideoTags = () => { + const activeTags = useSelectVideoActiveTags(); + const dispath = useAppDispatch(), + handerChangeActiveTags = ( + type: "add" | "delete", + data: VideoNavQueryItemType + ) => { + if (type === "add") { + dispath(handerVideoAddTag(data)); + } else { + dispath(handerVideoDeleteTag(data)); + } + }; + return [activeTags, handerChangeActiveTags]; + }, + useStorePhotoTags = () => { + const activeTags = useSelectPhotoActiveTags(); + const dispath = useAppDispatch(), + handerChangeActiveTags = ( + type: "add" | "delete", + data: PhotoNavQueryItemType + ) => { + if (type === "add") { + dispath(handerPhotoAddTag(data)); + } else { + dispath(handerPhotoDeleteTag(data)); + } + }; + return [activeTags, handerChangeActiveTags]; + };