feat: 更新评论和帖子模型,添加用户信息和原创标识,优化API请求和组件结构

This commit is contained in:
2025-07-28 06:22:07 +08:00
parent 5c20a310e3
commit d73ed493be
20 changed files with 260 additions and 181 deletions

View File

@ -1,9 +1,9 @@
import axios from 'axios'
import { camelToSnakeObj, snakeToCamelObj } from 'field-conv'
export const BACKEND_URL = process.env.BACKEND_URL || 'http://neo-blog-backend:8888'
export const BACKEND_URL = process.env.BACKEND_URL || (process.env.NODE_ENV == "production" ? 'http://neo-blog-backend:8888' : 'http://localhost:8888')
console.info(`Using backend URL: ${BACKEND_URL}`)
console.info(`Using ${process.env.NODE_ENV} backend URL: ${BACKEND_URL}`)
const isServer = typeof window === 'undefined'

View File

@ -11,9 +11,8 @@ interface ListPostsParams {
}
export async function getPostById(id: string): Promise<Post | null> {
console.log('Fetching post by ID:', id)
try {
const res = await axiosClient.get<BaseResponse<Post>>(`/post/p/19`)
const res = await axiosClient.get<BaseResponse<Post>>(`/post/p/${id}`)
return res.data.data
}
catch (error) {