添加博客头图

This commit is contained in:
2026-04-05 20:59:31 +08:00
parent 5e53a213e6
commit 9c019351a3
2 changed files with 73 additions and 6 deletions

View File

@ -24,6 +24,10 @@ export type ListBlogItemType = {
}
}
export type BlogContentType = ListBlogItemType & {
content: string
}
export const listBlogs = async ({
page = 1,
limit = 20,
@ -58,17 +62,30 @@ export const listBlogs = async ({
export const getBlog: (
blog_id: number,
) => Promise<null | { title: string; content: string }> = async (
blog_id: number,
) => {
) => Promise<null | BlogContentType> = async (blog_id: number) => {
const resp = await legacyClient.get(`/v1/blog/${blog_id}`, {
validateStatus: (status) => status == 200 || status == 404,
})
if (resp.status == 404) {
return null
}
return resp.data as {
title: string
content: string
let _blog = resp.data
if (_blog.featured_image) {
_blog = {
..._blog,
featured_image: {
image_url:
'https://legacy.passthem.top' + _blog.featured_image.image_url,
},
}
}
_blog.author.avatar = {
image_url: 'https://legacy.passthem.top' + _blog.author.avatar.image_url,
}
_blog.created_at = new Date(_blog.created_at)
_blog.updated_at = new Date(_blog.updated_at)
return _blog
}