ci: Prettier纳入两层防御体系 (#520)
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Successful in 1m6s
CI Build & Deploy Pipeline / Build Staging Web Image (push) Successful in 1m49s
CI Build & Deploy Pipeline / Build Production API Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (push) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (push) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 3m1s
CI/CD Pipeline / Unit Tests (push) Successful in 3m20s
CI/CD Pipeline / Integration Tests (push) Successful in 1m29s
CI Build & Deploy Pipeline / Build Staging API Image (push) Successful in 7m4s
CI Build & Deploy Pipeline / Build Staging Worker Image (push) Successful in 7m54s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 45s
CI Build & Deploy Pipeline / Staging E2E Tests (push) Failing after 2m50s
CI Build & Deploy Pipeline / Staging API Integration Tests (push) Successful in 3m28s

Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
This commit was merged in pull request #520.
This commit is contained in:
2026-07-18 18:08:19 +08:00
committed by auto-approve-bot
parent 1ee779a566
commit 0fcb77b991
145 changed files with 10310 additions and 12869 deletions
+21 -22
View File
@@ -2,60 +2,59 @@
* 项目相关 API
* 素材库需要 project_id,前端自动管理默认项目
*/
import apiClient from "./client";
import apiClient from "./client"
export interface ProjectItem {
id: string;
name: string;
description: string;
id: string
name: string
description: string
}
/** 后端 ProjectResponse 只返回 id, name, description */
interface BackendProjectResponse {
id: string;
name: string;
description: string;
id: string
name: string
description: string
}
/** 后端 ListProjectsResponse 返回 { items: [...] } */
interface BackendListProjectsResponse {
items: BackendProjectResponse[];
items: BackendProjectResponse[]
}
const toProjectItem = (item: BackendProjectResponse): ProjectItem => ({
id: item.id,
name: item.name,
description: item.description,
});
})
/** 获取当前用户的项目列表 */
export const getProjects = async (): Promise<ProjectItem[]> => {
const response =
await apiClient.get<BackendListProjectsResponse>("/projects");
return (response.data.items || []).map(toProjectItem);
};
const response = await apiClient.get<BackendListProjectsResponse>("/projects")
return (response.data.items || []).map(toProjectItem)
}
/** 创建项目 */
export const createProject = async (data: {
name: string;
description?: string;
name: string
description?: string
}): Promise<ProjectItem> => {
const response = await apiClient.post<BackendProjectResponse>("/projects", {
name: data.name,
description: data.description || "",
});
return toProjectItem(response.data);
};
})
return toProjectItem(response.data)
}
/** 获取或创建默认项目(素材库需要 project_id */
export const getOrCreateDefaultProject = async (): Promise<ProjectItem> => {
const projects = await getProjects();
const projects = await getProjects()
if (projects.length > 0) {
return projects[0];
return projects[0]
}
// 没有项目时自动创建默认项目
return createProject({
name: "默认项目",
description: "系统自动创建的默认项目",
});
};
})
}