refactor(api): 拆分 bgm/projects/tags 为目录结构(API 层全面目录化收尾)
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 22s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 35s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m13s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 32s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m11s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m40s
AI Code Review / AI Code Review (pull_request) Successful in 1m20s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 1m13s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m20s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 47s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 2m39s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 6m56s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 30s
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1244h26m31s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 1245h3m27s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1245h3m29s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1245h3m31s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 1245h25m29s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1245h28m39s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 1245h28m43s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 1245h28m45s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 1245h28m48s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1245h49m22s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1245h49m24s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1245h49m26s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1245h36m9s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 1246h1m21s

批量拆分三个小 API 文件:
- bgm.ts (68行) → types/constants/bgm/index
- projects.ts (60行) → types/utils/projects/index
- tags.ts (40行) → types/tags/index

全部保持 @/api/xxx 导入路径向后兼容。

至此前端 API 层所有单文件模块全部目录化,共 13 个 API 模块统一结构。
This commit is contained in:
2026-07-26 17:19:40 +08:00
parent 5fa915cdad
commit 7a5a9bcacf
12 changed files with 155 additions and 103 deletions
+38
View File
@@ -0,0 +1,38 @@
/**
* 项目相关 API 函数
* 素材库需要 project_id,前端自动管理默认项目
*/
import apiClient from "../client"
import type { BackendListProjectsResponse, BackendProjectResponse, ProjectItem } from "./types"
import { toProjectItem } from "./utils"
/** 获取当前用户的项目列表 */
export const getProjects = async (): Promise<ProjectItem[]> => {
const response = await apiClient.get<BackendListProjectsResponse>("/projects")
return (response.data.items || []).map(toProjectItem)
}
/** 创建项目 */
export const createProject = async (data: {
name: string
description?: string
}): Promise<ProjectItem> => {
const response = await apiClient.post<BackendProjectResponse>("/projects", {
name: data.name,
description: data.description || "",
})
return toProjectItem(response.data)
}
/** 获取或创建默认项目(素材库需要 project_id) */
export const getOrCreateDefaultProject = async (): Promise<ProjectItem> => {
const projects = await getProjects()
if (projects.length > 0) {
return projects[0]
}
// 没有项目时自动创建默认项目
return createProject({
name: "默认项目",
description: "系统自动创建的默认项目",
})
}