|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
/** 期刊详情 */
|
|
|
|
|
import Link from 'next/link';
|
|
|
|
|
import { notFound, redirect, RedirectType } from 'next/navigation';
|
|
|
|
|
|
|
|
|
|
import { SongCardList, JournalRecommendList, Comment, CollectButton, VolDetailCoverCard } from '@/components';
|
|
|
|
|
import { apiGetJournalInfoById, apiGetSongsByJournalNo, apiGetJournalRecommendById } from '@/services';
|
|
|
|
|
import { apiGetJournalInfoById, apiGetSongsByJournalNo, apiGetJournalRecommendById, apiGetTags } from '@/services';
|
|
|
|
|
|
|
|
|
|
export async function generateMetadata({ params: { journalId } }: { params: { journalId: string } }) {
|
|
|
|
|
const res = await apiGetJournalInfoById({ id: journalId });
|
|
|
|
@ -11,13 +12,19 @@ export async function generateMetadata({ params: { journalId } }: { params: { jo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getData = async (journalId: string) => {
|
|
|
|
|
const [journalInfoRes, songListRes, recommendList] = await Promise.all([
|
|
|
|
|
const [journalInfoRes, songListRes, recommendList, tagList] = await Promise.all([
|
|
|
|
|
apiGetJournalInfoById({ id: journalId }),
|
|
|
|
|
apiGetSongsByJournalNo({ id: journalId }),
|
|
|
|
|
apiGetJournalRecommendById({ id: journalId, limit: 8 }),
|
|
|
|
|
apiGetTags(),
|
|
|
|
|
]);
|
|
|
|
|
if (!(journalInfoRes.code === 200 && songListRes.code === 200)) return notFound();
|
|
|
|
|
return { journalInfo: journalInfoRes.data, songList: songListRes.data, recommendList: recommendList.data };
|
|
|
|
|
return {
|
|
|
|
|
journalInfo: journalInfoRes.data,
|
|
|
|
|
songList: songListRes.data,
|
|
|
|
|
recommendList: recommendList.data,
|
|
|
|
|
tagList: tagList.data,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default async function JournalDetail({
|
|
|
|
@ -27,7 +34,7 @@ export default async function JournalDetail({
|
|
|
|
|
params: { journalId: string };
|
|
|
|
|
searchParams: { mobile: string };
|
|
|
|
|
}) {
|
|
|
|
|
const { journalInfo, songList, recommendList } = await getData(journalId);
|
|
|
|
|
const { journalInfo, songList, recommendList, tagList } = await getData(journalId);
|
|
|
|
|
|
|
|
|
|
if (mobile) {
|
|
|
|
|
redirect(`${process.env.NEXT_PUBLIC_MOBILE_HOST}/journal.html?id=${journalInfo.id}`, RedirectType.replace);
|
|
|
|
@ -42,14 +49,15 @@ export default async function JournalDetail({
|
|
|
|
|
{/* 期刊号 & 标签 */}
|
|
|
|
|
<div className="flex flex-row items-center gap-[9px]">
|
|
|
|
|
<div className="text-[rgba(0,0,0,0.7)] text-14px leading-20px">{`VOL.${journalInfo?.journalNo.toString().padStart(4, '0')}`}</div>
|
|
|
|
|
{journalInfo?.tags.length > 0 &&
|
|
|
|
|
journalInfo.tags.map((tag: string) => (
|
|
|
|
|
<span
|
|
|
|
|
key={tag}
|
|
|
|
|
{journalInfo?.tagInfos.length > 0 &&
|
|
|
|
|
journalInfo.tagInfos.map((tag: TagInfo) => (
|
|
|
|
|
<Link
|
|
|
|
|
href={`/music/${tagList.find((item) => item.name === tag.name)?.engName.replace(/ /g, '')}`}
|
|
|
|
|
key={tag.id}
|
|
|
|
|
className="block w-fit py-[3px] px-[10px] rounded-[15px] bg-[rgba(0,0,0,0.05)] text-[rgba(0,0,0,0.7)] text-[12px] leading-[12px]"
|
|
|
|
|
>
|
|
|
|
|
{tag}
|
|
|
|
|
</span>
|
|
|
|
|
{tag.name}
|
|
|
|
|
</Link>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|