parent
26e60cd197
commit
b20e608853
@ -1,43 +0,0 @@
|
||||
import Link from 'next/link';
|
||||
|
||||
import HotJournalCard from './HotJournalCard';
|
||||
|
||||
import { apiJournalRecommend } from '@/services/server/journal';
|
||||
|
||||
interface HotProp {
|
||||
type: 'hot';
|
||||
}
|
||||
|
||||
interface JournalProp {
|
||||
type: 'journal';
|
||||
journalId: string;
|
||||
}
|
||||
|
||||
const getData = async (id: string) => {
|
||||
const res = await apiJournalRecommend({ id });
|
||||
return res.code === 200 ? res.data : [];
|
||||
};
|
||||
|
||||
const RecommondJournal = async (prop: HotProp | JournalProp) => {
|
||||
let journalList: JournalInfo[] = [];
|
||||
if (prop.type === 'hot') journalList = [];
|
||||
if (prop.type === 'journal') journalList = await getData(prop.journalId);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
{/* 分类 & 电台 */}
|
||||
<div className="text-[17px] leading-[23.8px]">热门推荐</div>
|
||||
{/* 期刊 list */}
|
||||
<div className="flex flex-col gap-[30px] mt-[17px]">
|
||||
{!!journalList?.length &&
|
||||
journalList.map((item: JournalInfo) => (
|
||||
<Link key={item.id} href={`/vol/${item.journalNo}`}>
|
||||
<HotJournalCard key={item.id} {...item} />
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default RecommondJournal;
|
@ -0,0 +1,27 @@
|
||||
import Link from 'next/link';
|
||||
|
||||
import JournalRecommendCard from './JournalRecommendCard';
|
||||
|
||||
interface Props {
|
||||
list: JournalInfo[];
|
||||
}
|
||||
|
||||
const JournalRecommendList = async ({ list }: Props) => {
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
{/* 分类 & 电台 */}
|
||||
<div className="text-[17px] leading-[23.8px]">热门推荐</div>
|
||||
{/* 期刊 list */}
|
||||
<div className="flex flex-col gap-[30px] mt-[17px]">
|
||||
{!!list?.length &&
|
||||
list.map((item: JournalInfo) => (
|
||||
<Link key={item.id} href={`/vol/${item.journalNo}`}>
|
||||
<JournalRecommendCard key={item.id} {...item} />
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default JournalRecommendList;
|
Loading…
Reference in new issue