feat: 去除访问统计信息

This commit is contained in:
2026-07-22 17:27:36 +08:00
parent aa4f3389a3
commit c9d6ce3464
7 changed files with 43 additions and 32 deletions

BIN
src/assets/icon/client.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@@ -1,23 +1,25 @@
---
import Folder from "@/assets/icon/folder.png?url";
import type { CategoriesStats } from "@/types";
import { createHttp } from "@/lib/request";
const http = createHttp(Astro.request.headers);
interface Props {
categories: CategoriesStats[]
}
const {categories} = Astro.props
const { data: categories } =
await http.get<ApiResponse<CategoriesStats[]>>("category/stats");
---
<aside class="sidebar">
<div class="widget">
<h3 class="widget-title">
<img src={Folder} alt="Folder">
<img src={Folder} alt="Folder" />
文章分类
</h3>
<ul class="category-list">
{
categories.map((category) => (
<li>
<a>{category.name}</a><span class="count">{category.post_count}</span>
<a>{category.name}</a>
<span class="count">{category.post_count}</span>
</li>
))
}
@@ -29,6 +31,9 @@ const {categories} = Astro.props
.sidebar {
width: 300px;
height: 100%;
display: flex;
flex-direction: column;
gap: 20px;
}
.widget {
@@ -82,7 +87,12 @@ const {categories} = Astro.props
@media (max-width: 860px) {
.sidebar {
width: 100%;
display: none;
}
}
@media (max-width: 860px) {
.sidebar {
gap: 16px;
}
}
</style>

View File

@@ -1,25 +1,24 @@
---
import type {Post, CategoriesStats} from "@/types/post";
import type { Post } from "@/types/post";
import IndexSidebar from "@/components/IndexSidebar.astro";
import PostList from '@/components/PostList.astro'
import PostList from "@/components/PostList.astro";
interface Props {
posts: Post[]
page: number
totalPage: number
categories: CategoriesStats[]
posts: Post[];
page: number;
totalPage: number;
}
const {posts, page, totalPage, categories} = Astro.props
const { posts, page, totalPage } = Astro.props;
---
<div class="page-content">
<div class="container">
<PostList posts={posts} page={page} totalPage={totalPage} />
<IndexSidebar categories={categories}/>
<IndexSidebar />
</div>
</div>
<style>
.container {
width: 100%;
@@ -27,4 +26,9 @@ const {posts, page, totalPage, categories} = Astro.props
gap: 28px;
}
@media (max-width: 860px) {
.container {
flex-direction: column;
}
}
</style>

View File

@@ -8,6 +8,11 @@ import BackTop from "@/components/BackTop.astro";
import { metadata } from "@/consts.ts";
const { siteTitle } = metadata;
interface Props {
title?: string;
description?: string;
}
const { title, description } = Astro.props;
const pageTitle = title ? `${title} - ${siteTitle}` : siteTitle;
---
@@ -23,8 +28,8 @@ const pageTitle = title ? `${title} - ${siteTitle}` : siteTitle;
<link rel="icon" type="image/svg+xml" href="/favicon.png" />
<meta name="generator" content={Astro.generator} />
<title>{pageTitle}</title>
<meta name="description" content={description}>
<meta name="theme-color" content="#ffffff">
<meta name="description" content={description} />
<meta name="theme-color" content="#ffffff" />
</head>
<body>
<BaseHeader />

View File

@@ -1,7 +1,7 @@
---
import Layout from "@/layouts/Layout.astro";
import IndexView from "@/components/IndexView.astro";
import type { Post, CategoriesStats } from "@/types/post";
import type { Post } from "@/types/post";
import { createHttp } from "@/lib/request";
import { metadata } from "@/consts.ts";
@@ -14,14 +14,10 @@ const { list, total } = await http.get<ApiPageResponse<Post>>("post", {
},
});
const totalPage = Math.ceil(total / metadata.postPageSize);
const { data: categories } =
await http.get<ApiResponse<CategoriesStats[]>>("category/stats");
---
<Layout>
<IndexView
categories={categories}
posts={list}
page={1}
totalPage={totalPage}

View File

@@ -1,6 +1,6 @@
---
import Layout from "@/layouts/Layout.astro";
import type { CategoriesStats, Post } from "@/types/post";
import type { Post } from "@/types/post";
import { createHttp } from "@/lib/request";
import { metadata } from "@/consts.ts";
import IndexView from "@/components/IndexView.astro";
@@ -25,14 +25,10 @@ const totalPage = Math.ceil(total / metadata.postPageSize);
if (totalPage < Number(page)) {
return Astro.redirect("/404");
}
const { data: categories } =
await http.get<ApiResponse<CategoriesStats[]>>("category/stats");
---
<Layout>
<IndexView
categories={categories}
posts={list}
page={Number(page)}
totalPage={totalPage}

0
src/types/client.ts Normal file
View File