From b8d13cc1b2ba53b06ce6307c99dc3e720b62e6a0 Mon Sep 17 00:00:00 2001 From: fadeaway Date: Wed, 27 Mar 2024 02:04:33 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9C=9F=E5=88=8A=E9=A1=B5=E9=9D=A2s?= =?UTF-8?q?sg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/journal/page.tsx | 62 ++--------------- src/components/JournalComment/index.tsx | 2 +- src/components/JournalContent/index.tsx | 92 +++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 59 deletions(-) create mode 100644 src/components/JournalContent/index.tsx 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} +

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