78d1c88ca1
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 1m44s
CI/CD Pipeline / Unit Tests (push) Successful in 1m44s
CI/CD Pipeline / Frontend Lint (push) Successful in 2m28s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Integration Tests (push) Successful in 1m8s
CI/CD Pipeline / Build Staging API Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Web Image (push) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
/**
|
||
* 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 ?? [];
|
||
};
|