From 065b894e5674d0ce59f732e27f2b447c0bd0d366 Mon Sep 17 00:00:00 2001 From: mackt <1033530438@qq.com> Date: Tue, 9 Apr 2024 15:31:58 +0800 Subject: [PATCH] fix(/my/collect): Fix request error. --- src/app/{mylist => my/collect}/page.tsx | 20 +++++++--------- src/app/{mylist => my}/index.module.css | 0 src/app/vol/[journalId]/page.tsx | 4 ++-- .../vol/list/[category]/[[...page]]/page.tsx | 8 +++---- src/components/Header/UserCard.tsx | 24 ++++++++----------- src/services/client/audio.ts | 2 +- 6 files changed, 26 insertions(+), 32 deletions(-) rename src/app/{mylist => my/collect}/page.tsx (86%) rename src/app/{mylist => my}/index.module.css (100%) diff --git a/src/app/mylist/page.tsx b/src/app/my/collect/page.tsx similarity index 86% rename from src/app/mylist/page.tsx rename to src/app/my/collect/page.tsx index 3124219..b992ecf 100644 --- a/src/app/mylist/page.tsx +++ b/src/app/my/collect/page.tsx @@ -6,7 +6,7 @@ import { useEffect, useState } from 'react'; import { useShallow } from 'zustand/react/shallow'; -import styles from './index.module.css'; +import styles from '../index.module.css'; import { SongCardList } from '@/components'; import { apiGetSongCollect } from '@/services'; @@ -26,21 +26,16 @@ export default function Journal() { const handleChangeType = (type: 'single' | 'journal') => { setList([]); - setType(type); setPageNum(1); + setType(type); }; const getList = async () => { - // const fn = { - // single: apiGetSongCollect, - // journal: apiGetSongCollect, - // }; const result = await apiGetSongCollect({ userId: userInfo?.id, pageNum, pageSize }); - // console.log(result); - if (result.code === 200) setList(result.data.rows); + if (result.code === 200) setList(result.data?.rows || []); }; - const nav: Array<{ label: string; value: 'single' | 'journal' }> = [ + const tabList: Array<{ label: string; value: 'single' | 'journal' }> = [ { label: '收藏的单曲', value: 'single', @@ -52,16 +47,19 @@ export default function Journal() { ]; useEffect(() => { - document.title = '我的收藏 - 雀乐'; getList(); }, [type, pageNum]); + useEffect(() => { + document.title = '我的收藏 - 雀乐'; + }, []); + return (
{/* Nav */}
); diff --git a/src/app/vol/list/[category]/[[...page]]/page.tsx b/src/app/vol/list/[category]/[[...page]]/page.tsx index 4967e7e..0dbd644 100644 --- a/src/app/vol/list/[category]/[[...page]]/page.tsx +++ b/src/app/vol/list/[category]/[[...page]]/page.tsx @@ -11,17 +11,17 @@ export const metadata: Metadata = { }; const getData = async () => { - const [categoryList, recomendList] = await Promise.all([ + const [categoryList, recommendList] = await Promise.all([ apiSearchCategoryList(), apiGetJournalRecommendWithCollect(), ]); if (categoryList.code !== 200) return notFound(); - return { categoryList: categoryList.data, recomendList: recomendList.data }; + return { categoryList: categoryList.data, recommendList: recommendList.data }; }; export default async function Journal({ params }: { params: { category?: string; page?: number } }) { const { category = 'all', page = 1 } = params; - const { categoryList, recomendList } = await getData(); + const { categoryList, recommendList } = await getData(); const categoryInfo: Category | undefined = categoryList.find((item: Category) => item.nameEn === category); return ( @@ -37,7 +37,7 @@ export default async function Journal({ params }: { params: { category?: string; {/* 右侧 */}
{/* 热门推荐 */} - + {!!recommendList?.length ? :
}
); diff --git a/src/components/Header/UserCard.tsx b/src/components/Header/UserCard.tsx index c7d7ffc..ad2bcb5 100644 --- a/src/components/Header/UserCard.tsx +++ b/src/components/Header/UserCard.tsx @@ -14,9 +14,10 @@ interface Props { className?: string; } -interface TDataList { +interface UserData { label: string; value: number; + url: string; } export default function UserCard({ onClose, className }: Props) { @@ -27,24 +28,19 @@ export default function UserCard({ onClose, className }: Props) { })), ); - const [userDataList, setUserDataList] = useState([ - { label: '关注', value: userInfo.followCount }, - { label: '粉丝', value: userInfo.fansCount }, - { label: '评论', value: userInfo.commentReplyCount }, - { label: '获赞', value: userInfo.thumbUpCount }, - ]); + const [userDataList, setUserDataList] = useState([]); - const handleGoMyList = () => { - router.push('/myList'); + const handleGoMyCollect = () => { + router.push('/my/collect'); onClose(); }; useEffect(() => { setUserDataList([ - { label: '关注', value: userInfo.followCount }, - { label: '粉丝', value: userInfo.fansCount }, - { label: '评论', value: userInfo.commentReplyCount }, - { label: '获赞', value: userInfo.thumbUpCount }, + { label: '关注', value: userInfo.followCount, url: '' }, + { label: '粉丝', value: userInfo.fansCount, url: '' }, + { label: '评论', value: userInfo.commentReplyCount, url: '' }, + { label: '获赞', value: userInfo.thumbUpCount, url: '' }, ]); }, [userInfo]); @@ -75,7 +71,7 @@ export default function UserCard({ onClose, className }: Props) {
  • 我的收藏 我的收藏 diff --git a/src/services/client/audio.ts b/src/services/client/audio.ts index b727f81..0bca160 100644 --- a/src/services/client/audio.ts +++ b/src/services/client/audio.ts @@ -19,7 +19,7 @@ export const apiGetSongCollect = async ({ userId: string; }) => { const result: FetchResponse> = await clientHttp.get( - `queyueapi/music/song/collect?userId=${userId}&pageNum=${pageNum}&pageSize=${pageSize}`, + `/queyueapi/music/song/collect?userId=${userId}&pageNum=${pageNum}&pageSize=${pageSize}`, ); return result; };