feat: 样式调整
This commit is contained in:
@@ -1,34 +1,40 @@
|
||||
---
|
||||
import Layout from "@/layouts/Layout.astro";
|
||||
import type {CategoriesStats, Post} from "@/types/post";
|
||||
import {createHttp} from "@/lib/request";
|
||||
import {metadata} from "@/consts.ts";
|
||||
import type { CategoriesStats, Post } from "@/types/post";
|
||||
import { createHttp } from "@/lib/request";
|
||||
import { metadata } from "@/consts.ts";
|
||||
import IndexView from "@/components/IndexView.astro";
|
||||
|
||||
const {page} = Astro.params
|
||||
const { page } = Astro.params;
|
||||
|
||||
if (isNaN(Number(page))) {
|
||||
return Astro.redirect('/')
|
||||
return Astro.redirect("/");
|
||||
}
|
||||
|
||||
const http = createHttp(Astro.request.headers)
|
||||
const http = createHttp(Astro.request.headers);
|
||||
|
||||
const {list, total} = await http.get<ApiPageResponse<Post>>("post", {
|
||||
const { list, total } = await http.get<ApiPageResponse<Post>>("post", {
|
||||
searchParams: {
|
||||
page,
|
||||
page_size: metadata.postPageSize
|
||||
}
|
||||
page_size: metadata.postPageSize,
|
||||
},
|
||||
});
|
||||
|
||||
const totalPage = Math.ceil(total / metadata.postPageSize)
|
||||
const totalPage = Math.ceil(total / metadata.postPageSize);
|
||||
|
||||
if (totalPage < Number(page)) {
|
||||
return Astro.redirect('/404')
|
||||
return Astro.redirect("/404");
|
||||
}
|
||||
|
||||
const {data: categories} = await http.get<ApiResponse<CategoriesStats[]>>("category/stats");
|
||||
const { data: categories } =
|
||||
await http.get<ApiResponse<CategoriesStats[]>>("category/stats");
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<IndexView categories={categories} posts={list} page={Number(page)} totalPage={totalPage}/>
|
||||
<IndexView
|
||||
categories={categories}
|
||||
posts={list}
|
||||
page={Number(page)}
|
||||
totalPage={totalPage}
|
||||
/>
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user