feat: 完成前后端API联调测试并修复配置问题
- 启动后端go-zero API服务 (端口8080) - 修复前端API配置中的端口号 (8888→8080) - 完善前端API状态监控组件 - 创建categoryService服务层 - 更新前端数据查询和转换逻辑 - 完成完整API集成测试,验证所有接口正常工作 - 验证用户认证、分类管理、照片管理等核心功能 - 创建API集成测试脚本 - 更新任务进度文档 测试结果: ✅ 后端健康检查正常 ✅ 用户认证功能正常 (admin/admin123) ✅ 分类API正常 (5个分类) ✅ 照片API正常 (0张照片,数据库为空) ✅ 前后端API连接完全正常 下一步: 实现照片展示页面和搜索过滤功能
This commit is contained in:
@ -9,6 +9,7 @@ import { LoadingSpinner } from "@/components/loading-spinner"
|
||||
import { TimelineView } from "@/components/timeline-view"
|
||||
import { AboutView } from "@/components/about-view"
|
||||
import { ContactView } from "@/components/contact-view"
|
||||
import { ApiStatus } from "@/components/api-status"
|
||||
import { usePhotos, type Photo } from "@/lib/queries"
|
||||
import { useToast } from "@/components/ui/use-toast"
|
||||
|
||||
@ -21,9 +22,12 @@ export default function HomePage() {
|
||||
|
||||
useEffect(() => {
|
||||
if (error) {
|
||||
const isRealApi = process.env.NEXT_PUBLIC_USE_REAL_API === 'true'
|
||||
toast({
|
||||
title: "数据加载失败",
|
||||
description: "无法获取照片数据,请稍后重试",
|
||||
description: isRealApi
|
||||
? "无法连接到后端API,请确保后端服务正在运行 (localhost:8888)"
|
||||
: "无法连接到Mock API,请确保Mock API正在运行 (localhost:3001)",
|
||||
variant: "destructive",
|
||||
})
|
||||
}
|
||||
@ -144,6 +148,9 @@ export default function HomePage() {
|
||||
onNext={handleNextPhoto}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* API状态指示器 - 仅开发环境 */}
|
||||
<ApiStatus />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user