feat: 首页改版
This commit is contained in:
@@ -12,13 +12,12 @@ import Layout from "@/layouts/Layout.astro";
|
||||
<style>
|
||||
.not-found{
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
margin-top: -100px;
|
||||
}
|
||||
|
||||
.back-home{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
import Layout from "@/layouts/Layout.astro";
|
||||
import PostList from "@/components/PostList.astro";
|
||||
import type {Post} from "@/types/post";
|
||||
import IndexView from "@/components/IndexView.astro";
|
||||
import type {Post, CategoriesStats} from "@/types/post";
|
||||
import {createHttp} from "@/lib/request";
|
||||
import {metadata} from "@/consts.ts";
|
||||
|
||||
@@ -13,10 +13,11 @@ const {list, total} = await http.get<ApiPageResponse<Post>>("post", {
|
||||
page_size: metadata.postPageSize
|
||||
}
|
||||
});
|
||||
|
||||
const totalPage = Math.ceil(total / metadata.postPageSize)
|
||||
|
||||
const {data: categories} = await http.get<ApiPageResponse<CategoriesStats>>("category/stats");
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<PostList posts={list} page={1} totalPage={totalPage}/>
|
||||
<IndexView categories={categories} posts={list} page={1} totalPage={totalPage}/>
|
||||
</Layout>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
import Layout from "@/layouts/Layout.astro";
|
||||
import PostList from "@/components/PostList.astro";
|
||||
import type {Post} from "@/types/post";
|
||||
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
|
||||
|
||||
@@ -25,8 +25,10 @@ const totalPage = Math.ceil(total / metadata.postPageSize)
|
||||
if (totalPage < page) {
|
||||
return Astro.redirect('/404')
|
||||
}
|
||||
|
||||
const {data: categories} = await http.get<ApiPageResponse<CategoriesStats>>("category/stats");
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<PostList posts={list} page={Number(page)} totalPage={totalPage}/>
|
||||
<IndexView categories={categories} posts={list} page={Number(page)} totalPage={totalPage}/>
|
||||
</Layout>
|
||||
|
||||
@@ -134,7 +134,7 @@ const published_at = formatDatetime(data.published_at, 'YYYY 年 M 月 D 日')
|
||||
}
|
||||
|
||||
:global(.dark) .post {
|
||||
background: #171717;
|
||||
background: var(--card-bg);
|
||||
box-shadow: none;
|
||||
border: none;
|
||||
}
|
||||
Reference in New Issue
Block a user