diff --git a/src/app/journal/page.tsx b/src/app/journal/page.tsx index 90d1bd7..038770c 100644 --- a/src/app/journal/page.tsx +++ b/src/app/journal/page.tsx @@ -1,72 +1,18 @@ /** * 期刊页面 */ -import Image from 'next/image'; - -import ArticalWrap from '@/components/ArticalWrap'; import JournalBanner from '@/components/JournalBanner'; -import JournalComment from '@/components/JournalComment'; -import SongList from '@/components/SongList'; +import JournalContent from '@/components/JournalContent'; import type { Metadata } from 'next'; export const metadata: Metadata = { title: '雀乐期刊' }; -// 获取期刊信息 -async function getJournalInfo(journalId: string) { - const res = await fetch(`http://api.indie.cn:9012/luoo-music/journal/${journalId}`); - return res.json(); -} - -// 获取期刊歌曲列表 -async function getSongList(journalId: string) { - const res = await fetch(`http://api.indie.cn:9012/luoo-music/song/journalId/${journalId}`); - return res.json(); -} - -async function getInfo(journalId: string) { - return await Promise.all([getJournalInfo(journalId), getSongList(journalId)]); -} - -export default async function Journal({ searchParams: { id } }: any) { - const [res0, res1] = await getInfo(id); - const journalInfo = res0?.data; - const songList = res1?.data; +export default function Journal() { return ( -
+
- - {/* 期刊封面图 */} -
- journal-cover -
- -
-
-
VOL·{journalInfo?.journalNo}
-
- {journalInfo?.tags?.map((tag: string, index: number) => ( -
- {tag} -
- ))} -
-
-
{journalInfo?.title}
-

- {journalInfo?.editor} - {journalInfo?.date} -

- - - - -
- - +
); } diff --git a/src/components/JournalComment/index.tsx b/src/components/JournalComment/index.tsx index 673f7e0..88d725f 100644 --- a/src/components/JournalComment/index.tsx +++ b/src/components/JournalComment/index.tsx @@ -9,7 +9,7 @@ export default function JournalComment({ journalInfo }: { journalInfo: any }) { router.push('/download'); }; return ( -
+
(); + const [songList, setSongList] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const { searchParams } = new URL(window.location.href); + setLoading(true); + getInfo((searchParams as any)?.get('id')) + .then(([res0, res1]) => { + setJournalInfo(res0?.data); + setSongList(res1?.data); + }) + .finally(() => { + setLoading(false); + }); + }, []); + + return ( + <> + {loading && ( +
加载中 ...
+ )} +
+ {/* 期刊封面图 */} +
+ journal-cover +
+ +
+
+
VOL·{journalInfo?.journalNo}
+
+ {journalInfo?.tags?.map((tag: string, index: number) => ( +
+ {tag} +
+ ))} +
+
+
{journalInfo?.title}
+

+ {journalInfo?.editor} + {journalInfo?.date} +

+ + + + +
+ + +
+ + ); +}