Compare commits

...

2 Commits

Author SHA1 Message Date
xiaoxia 36cb6123e7 Merge branch 'develop' into refactor/bgm-projects-tags-api
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 22s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m5s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m4s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 1m30s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 26s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 36s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m56s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 41s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 42s
AI Code Review / AI Code Review (pull_request) Successful in 1m21s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m52s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 15m16s
CI/CD Pipeline / CI Gate (pull_request) 失败: CI/CD Pipeline / Validate - Code Quality (pull_request) [frontend-only]
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 18s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 13s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
2026-07-27 12:34:50 +08:00
xiaoxia 7a5a9bcacf 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 / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
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 / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 30s
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
批量拆分三个小 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 模块统一结构。
2026-07-26 17:19:40 +08:00
12 changed files with 155 additions and 103 deletions
-68
View File
@@ -1,68 +0,0 @@
/**
* BGM 预设音乐 API
* 对接后端 BGM 混音能力:预设列表查询(按风格分类 + 关键词搜索)
*/
import apiClient from "./client"
/* ──────────── 类型 ──────────── */
/** BGM 风格分类 */
export type BgmCategory = "轻快" | "治愈" | "科技" | "电商"
/** BGM 预设项 */
export interface BgmPreset {
id: string
name: string
category: BgmCategory
/** 音频文件 URL */
url: string
/** 时长(秒) */
duration: number
/** 关键词标签 */
tags: string[]
/** 封面图 URL */
cover_url?: string
}
/** BGM 预设列表查询参数 */
export interface BgmPresetsQuery {
category?: BgmCategory | string
keyword?: string
}
/** BGM 混音配置(嵌入模板) */
export interface BgmMixConfig {
/** 是否启用 BGM */
enabled: boolean
/** 选中的 BGM ID */
music_id: string
/** BGM 音量 0-100 */
volume: number
/** 淡入时长(秒) 0-3 */
fade_in: number
/** 淡出时长(秒) 0-3 */
fade_out: number
/** 人声闪避(sidechain */
voice_dodge: boolean
}
/** 默认 BGM 混音配置 */
export const DEFAULT_BGM_MIX_CONFIG: BgmMixConfig = {
enabled: false,
music_id: "",
volume: 50,
fade_in: 0.5,
fade_out: 0.5,
voice_dodge: true,
}
/* ──────────── API ──────────── */
/** 获取 BGM 预设列表 */
export const getBgmPresets = async (params?: BgmPresetsQuery): Promise<BgmPreset[]> => {
const searchParams: Record<string, string> = {}
if (params?.category) searchParams.category = params.category
if (params?.keyword) searchParams.keyword = params.keyword
const res = await apiClient.get("/bgm/presets", { params: searchParams })
return res.data?.data ?? res.data ?? []
}
+14
View File
@@ -0,0 +1,14 @@
/**
* BGM 预设音乐 API 函数
*/
import apiClient from "../client"
import type { BgmPreset, BgmPresetsQuery } from "./types"
/** 获取 BGM 预设列表 */
export const getBgmPresets = async (params?: BgmPresetsQuery): Promise<BgmPreset[]> => {
const searchParams: Record<string, string> = {}
if (params?.category) searchParams.category = params.category
if (params?.keyword) searchParams.keyword = params.keyword
const res = await apiClient.get("/bgm/presets", { params: searchParams })
return res.data?.data ?? res.data ?? []
}
+14
View File
@@ -0,0 +1,14 @@
/**
* BGM 相关常量
*/
import type { BgmMixConfig } from "./types"
/** 默认 BGM 混音配置 */
export const DEFAULT_BGM_MIX_CONFIG: BgmMixConfig = {
enabled: false,
music_id: "",
volume: 50,
fade_in: 0.5,
fade_out: 0.5,
voice_dodge: true,
}
+13
View File
@@ -0,0 +1,13 @@
/**
* BGM API — 目录化入口
* 保持与原 bgm.ts 相同导出,向后兼容
*/
// 类型
export type { BgmCategory, BgmPreset, BgmPresetsQuery, BgmMixConfig } from "./types"
// 常量
export { DEFAULT_BGM_MIX_CONFIG } from "./constants"
// API 函数
export { getBgmPresets } from "./bgm"
+43
View File
@@ -0,0 +1,43 @@
/**
* BGM 相关类型定义
*/
/** BGM 风格分类 */
export type BgmCategory = "轻快" | "治愈" | "科技" | "电商"
/** BGM 预设项 */
export interface BgmPreset {
id: string
name: string
category: BgmCategory
/** 音频文件 URL */
url: string
/** 时长(秒) */
duration: number
/** 关键词标签 */
tags: string[]
/** 封面图 URL */
cover_url?: string
}
/** BGM 预设列表查询参数 */
export interface BgmPresetsQuery {
category?: BgmCategory | string
keyword?: string
}
/** BGM 混音配置(嵌入模板) */
export interface BgmMixConfig {
/** 是否启用 BGM */
enabled: boolean
/** 选中的 BGM ID */
music_id: string
/** BGM 音量 0-100 */
volume: number
/** 淡入时长(秒) 0-3 */
fade_in: number
/** 淡出时长(秒) 0-3 */
fade_out: number
/** 人声闪避(sidechain */
voice_dodge: boolean
}
+13
View File
@@ -0,0 +1,13 @@
/**
* 项目 API — 目录化入口
* 保持与原 projects.ts 相同导出,向后兼容
*/
// 类型
export type { ProjectItem, BackendProjectResponse, BackendListProjectsResponse } from "./types"
// 工具函数
export { toProjectItem } from "./utils"
// API 函数
export { getProjects, createProject, getOrCreateDefaultProject } from "./projects"
@@ -1,32 +1,10 @@
/**
* API
* API
* project_id
*/
import apiClient from "./client"
export interface ProjectItem {
id: string
name: string
description: string
}
/** 后端 ProjectResponse 只返回 id, name, description */
interface BackendProjectResponse {
id: string
name: string
description: string
}
/** 后端 ListProjectsResponse 返回 { items: [...] } */
interface BackendListProjectsResponse {
items: BackendProjectResponse[]
}
const toProjectItem = (item: BackendProjectResponse): ProjectItem => ({
id: item.id,
name: item.name,
description: item.description,
})
import apiClient from "../client"
import type { BackendListProjectsResponse, BackendProjectResponse, ProjectItem } from "./types"
import { toProjectItem } from "./utils"
/** 获取当前用户的项目列表 */
export const getProjects = async (): Promise<ProjectItem[]> => {
+21
View File
@@ -0,0 +1,21 @@
/**
* 项目相关类型定义
*/
export interface ProjectItem {
id: string
name: string
description: string
}
/** 后端 ProjectResponse 只返回 id, name, description */
export interface BackendProjectResponse {
id: string
name: string
description: string
}
/** 后端 ListProjectsResponse 返回 { items: [...] } */
export interface BackendListProjectsResponse {
items: BackendProjectResponse[]
}
+10
View File
@@ -0,0 +1,10 @@
/**
* 项目相关工具函数
*/
import type { BackendProjectResponse, ProjectItem } from "./types"
export const toProjectItem = (item: BackendProjectResponse): ProjectItem => ({
id: item.id,
name: item.name,
description: item.description,
})
+10
View File
@@ -0,0 +1,10 @@
/**
* 标签 API — 目录化入口
* 保持与原 tags.ts 相同导出,向后兼容
*/
// 类型
export type { TagItem } from "./types"
// API 函数
export { getTags, createTag, deleteTag, tagAsset, untagAsset } from "./tags"
@@ -1,15 +1,9 @@
/**
* CRUD API
* CRUD API
* P3
*/
import apiClient from "./client"
export interface TagItem {
id: string
name: string
created_at?: string
usage_count?: number
}
import apiClient from "../client"
import type { TagItem } from "./types"
/** 获取当前用户所有标签 */
export const getTags = async (): Promise<TagItem[]> => {
+10
View File
@@ -0,0 +1,10 @@
/**
* 标签相关类型定义
*/
export interface TagItem {
id: string
name: string
created_at?: string
usage_count?: number
}