File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,13 +34,11 @@ async function fetchPost(slug: string): Promise<Post | null> {
3434 withToken : false ,
3535 } ) ;
3636
37- // 检查响应格式
3837 if ( response && response . id ) {
39- // 处理特殊字符
4038 return {
4139 ...response ,
4240 featured_image : response . featured_image
43- ? response . data . featured_image . replace ( / ` / g, "" ) . trim ( )
41+ ? response . featured_image . replace ( / ` / g, "" ) . trim ( )
4442 : null ,
4543 } ;
4644 } else {
@@ -53,13 +51,15 @@ async function fetchPost(slug: string): Promise<Post | null> {
5351 }
5452}
5553
54+
5655interface BlogPostProps {
5756 slug : string ;
5857}
5958
6059export default function BlogPost ( props : BlogPostProps ) {
6160 // 使用SolidJS的资源加载功能获取文章
6261 const [ post ] = createResource < Post | null > ( ( ) => fetchPost ( props . slug ) ) ;
62+ console . log ( post ( ) ) ;
6363
6464 return (
6565 < div class = "container mx-auto px-4 py-8" >
@@ -98,7 +98,7 @@ export default function BlogPost(props: BlogPostProps) {
9898 < article class = "prose prose-lg max-w-none dark:prose-invert" >
9999 { post ( ) ! . featured_image && (
100100 < img
101- src = { post ( ) ! . featured_image }
101+ src = { post ( ) ! . featured_image ?? '' }
102102 alt = { post ( ) ! . title }
103103 class = "w-full h-64 md:h-96 object-cover rounded-lg shadow-md mb-8"
104104 />
Original file line number Diff line number Diff line change @@ -10,11 +10,7 @@ interface RequestConfig extends AxiosRequestConfig {
1010}
1111
1212// 定义响应数据的通用接口
13- interface ApiResponse < T = any > {
14- code : number ;
15- data : T ;
16- message : string ;
17- }
13+ type ApiResponse < T = any > = T ;
1814
1915/**
2016 * HTTP请求类,封装axios实例
You can’t perform that action at this time.
0 commit comments