feat(global) compatibility milestone

This commit is contained in:
lumither committed 2025-06-03 03:19:49 +08:00
1 parent 06a4ab8cf7
commit 45010f030c
19 files changed
+347 -119

No files matched your search

+29 -9
View File
@@ -1,6 +1,7 @@
import PostList from '@/app/(pages)/blog/PostList';
import Pagination from '@/app/(pages)/blog/Pagination';
import { fetchNocturneApi } from '@/app/(pages)/blog/api';
import { fetchPostListPagination } from '@/src/api/blog/post';
async function Blog({
searchParams
@@ -10,15 +11,34 @@ async function Blog({
const parsePage = Number((await searchParams)?.page);
const currPage = parsePage > 0 ? parsePage : 1;
const ret = await fetchNocturneApi(`/blog/get_page_count`);
const pageCount = (await ret.json() as any)['res'] as number;
return (
<div className={ 'w-full min-w-full space-y-4' }>
<PostList page={ currPage } />
<Pagination total={ pageCount } />
</div>
);
try {
const pagination = await fetchPostListPagination();
const pageCount = pagination.data.page_count;
return (
<div className={ 'w-full min-w-full space-y-4' }>
<PostList page={ currPage } />
<Pagination total={ pageCount } />
</div>
);
} catch (e: any) {
return (
<div className={ `flex h-full min-h-dvh w-full justify-center items-center` }>
<div className={ `flex-row` }>
<p className={ `text-xl font-bold` }>
{ 'Unexpected Error [loading pagination]:' }
</p>
<p className={ `font-bold` }>
{ e.message }
</p>
</div>
</div>
);
}
}
export default Blog;