parent
c2270f9b4d
commit
936593553c
After Width: | Height: | Size: 429 B |
@ -0,0 +1,14 @@
|
||||
.tab-active {
|
||||
transition-property: color;
|
||||
transition-duration: 300;
|
||||
color: rgba(0, 0, 0, 0.95);
|
||||
}
|
||||
|
||||
.tab-active::after {
|
||||
content: '';
|
||||
display: block;
|
||||
width: 60px;
|
||||
height: 3px;
|
||||
margin: 12px auto 0;
|
||||
background-color: rgba(0, 0, 0, 0.95);
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
/** 期刊列表 */
|
||||
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { useShallow } from 'zustand/react/shallow';
|
||||
|
||||
import styles from './index.module.css';
|
||||
|
||||
import { SongCardList } from '@/components';
|
||||
import { apiGetSongCollect } from '@/services';
|
||||
import useUserStore from '@/store/user';
|
||||
|
||||
export default function Journal({ params }: { params: { category?: string; page?: number } }) {
|
||||
const { userInfo, userLogout } = useUserStore(
|
||||
useShallow((state) => ({
|
||||
userInfo: state.userInfo,
|
||||
userLogout: state.userLogout,
|
||||
})),
|
||||
);
|
||||
|
||||
const [type, setType] = useState<'single' | 'journal'>('single'); // 收藏类型
|
||||
const [pageNum, setPageNum] = useState<number>(1);
|
||||
const [pageSize] = useState<number>(6);
|
||||
const [list, setList] = useState<SongInfo[]>([]); // 列表
|
||||
|
||||
const handleChangeType = (type: 'single' | 'journal') => {
|
||||
setList([]);
|
||||
setType(type);
|
||||
setPageNum(1);
|
||||
};
|
||||
|
||||
const getList = async () => {
|
||||
// const fn = {
|
||||
// single: apiGetSongCollect,
|
||||
// journal: apiGetSongCollect,
|
||||
// };
|
||||
const result = await apiGetSongCollect({ userId: userInfo?.id, pageNum, pageSize });
|
||||
if (result.code === 200) setList(result.data.rows);
|
||||
};
|
||||
|
||||
const nav: Array<{ label: string; value: 'single' | 'journal' }> = [
|
||||
{
|
||||
label: '收藏的单曲',
|
||||
value: 'single',
|
||||
},
|
||||
{
|
||||
label: '收藏的期刊',
|
||||
value: 'journal',
|
||||
},
|
||||
];
|
||||
|
||||
useEffect(() => {
|
||||
getList();
|
||||
}, [type, pageNum]);
|
||||
|
||||
return (
|
||||
<main className="w-[1200px] mx-auto items-left pt-[80px] pb-[104px] ">
|
||||
<div className="w-[712px]">
|
||||
{/* Nav */}
|
||||
<ul className="mt-[22px] h-[24px]">
|
||||
{nav.map((item) => (
|
||||
<li
|
||||
key={item.value}
|
||||
className={`relative float-left w-[85px] mr-[37px] text-[rgba(0,0,0,0.4)] text-[17px] leading-[24px] hover:text-base cursor-pointer ${type === item.value ? styles['tab-active'] : ''} `}
|
||||
onClick={() => handleChangeType(item.value)}
|
||||
>
|
||||
{item.label}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div className="w-[105px] h-[36px] mt-[50px] pl-[45px] text-base text-[15px] leading-[36px] bg-[url(/img/icon/play-ellipse.svg)] bg-no-repeat bg-left hover:text-theme cursor-pointer">
|
||||
播放全部
|
||||
</div>
|
||||
{/* List */}
|
||||
<SongCardList className="w-full mt-11px mb-[56px] " songList={list} />
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
Loading…
Reference in new issue