mirror of
https://github.com/LiuYuYang01/ThriveX-Blog.git
synced 2026-06-05 04:09:28 +08:00
记录文章浏览量功能
This commit is contained in:
@@ -19,4 +19,9 @@ export const getRandomArticleListAPI = async () => {
|
||||
// 获取推荐文章列表
|
||||
export const getRecommendedArticleListAPI = async () => {
|
||||
return await Request<Article[]>("GET", "/article/hot");
|
||||
}
|
||||
|
||||
// 递增浏览量
|
||||
export const recordViewAPI = async (id: number) => {
|
||||
return await Request<void>("GET", `/article/view/${id}`);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getArticleDataAPI } from '@/api/article'
|
||||
import { getArticleDataAPI, recordViewAPI } from '@/api/article'
|
||||
|
||||
import Starry from "@/components/Starry"
|
||||
import Swiper from "@/components/Swiper"
|
||||
@@ -25,6 +25,9 @@ export default async ({ params }: Props) => {
|
||||
const id = params.id
|
||||
const { data } = await getArticleDataAPI(id)
|
||||
|
||||
// 记录文章访问量
|
||||
await recordViewAPI(id)
|
||||
|
||||
// 图标样式
|
||||
const iconSty = "flex justify-center items-center w-5 h-5 rounded-full text-xs mr-1"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// const url = "http://localhost:9999/api"
|
||||
const url = "http://api.liuyuyang.net/api"
|
||||
const url = "http://localhost:9003/api"
|
||||
// const url = "http://api.liuyuyang.net/api"
|
||||
|
||||
export default async <T>(method: string, api: string, data?: any, caching = true) => {
|
||||
const res = await fetch(`${url}${api}`, {
|
||||
|
||||
Reference in New Issue
Block a user