From 5eacac3abfdb7a13398c7c001985feb7314f9bc4 Mon Sep 17 00:00:00 2001 From: Audit Bot Date: Mon, 29 Jun 2026 07:25:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=20getProjects=20?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E8=A7=A3=E6=9E=90=20=E2=80=94=20=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E8=BF=94=E5=9B=9E=20{items:[...]}=20=E8=80=8C?= =?UTF-8?q?=E9=9D=9E=E8=A3=B8=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - BackendProjectResponse 对齐后端 ProjectResponse(仅 id/name/description) - getProjects 改为 response.data.items 解析 - 修复代码审计 PR#94 审查发现的 P0 Co-Authored-By: Claude Fable 5 --- apps/web/src/api/projects.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/web/src/api/projects.ts b/apps/web/src/api/projects.ts index 4367ae395..fb3d73bb1 100644 --- a/apps/web/src/api/projects.ts +++ b/apps/web/src/api/projects.ts @@ -6,32 +6,32 @@ import apiClient from './client'; export interface ProjectItem { id: string; - owner_user_id: string; name: string; description: string; - shared_users: string[]; } +/** 后端 ProjectResponse 只返回 id, name, description */ interface BackendProjectResponse { id: string; - owner_user_id: string; name: string; description: string; - shared_users: string[]; +} + +/** 后端 ListProjectsResponse 返回 { items: [...] } */ +interface BackendListProjectsResponse { + items: BackendProjectResponse[]; } const toProjectItem = (item: BackendProjectResponse): ProjectItem => ({ id: item.id, - owner_user_id: item.owner_user_id, name: item.name, description: item.description, - shared_users: item.shared_users || [], }); /** 获取当前用户的项目列表 */ export const getProjects = async (): Promise => { - const response = await apiClient.get('/projects'); - return (response.data || []).map(toProjectItem); + const response = await apiClient.get('/projects'); + return (response.data.items || []).map(toProjectItem); }; /** 创建项目 */