fix: prettier formatting for voice material module files
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
CI/CD Pipeline / Deploy Staging (push) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Production Runtime Images (push) Has been cancelled
CI/CD Pipeline / Deploy Production (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Has been cancelled

This commit is contained in:
CI Test
2026-07-07 11:04:30 +08:00
parent 734d7eb377
commit d1970bd44b
3 changed files with 55 additions and 21 deletions
+4 -1
View File
@@ -119,7 +119,10 @@ export const ensureDefaultLibrary = async (data: {
project_id: string;
kind: "video" | "voice" | "image";
}): Promise<AssetLibraryItem> => {
const response = await apiClient.post("/asset-libraries/ensure-default", data);
const response = await apiClient.post(
"/asset-libraries/ensure-default",
data,
);
return response.data;
};
+3 -1
View File
@@ -759,7 +759,9 @@ const GeneratePage: React.FC = () => {
}}
role="button"
tabIndex={0}
aria-pressed={voiceMode === "preset" && selectedVoice === v.voice_id}
aria-pressed={
voiceMode === "preset" && selectedVoice === v.voice_id
}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
@@ -8,7 +8,13 @@
* - 编辑元信息(名称、描述、性别、风格标签)
* - 删除素材
*/
import React, { useState, useRef, useCallback, useEffect, useMemo } from "react";
import React, {
useState,
useRef,
useCallback,
useEffect,
useMemo,
} from "react";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import {
AudioOutlined,
@@ -63,7 +69,11 @@ const STYLE_TAGS = [
];
/** 性别选项 */
const GENDER_OPTIONS: { value: VoiceGender; label: string; icon: React.ReactNode }[] = [
const GENDER_OPTIONS: {
value: VoiceGender;
label: string;
icon: React.ReactNode;
}[] = [
{ value: "male", label: "男声", icon: <ManOutlined /> },
{ value: "female", label: "女声", icon: <WomanOutlined /> },
{ value: "child", label: "童声", icon: <UserOutlined /> },
@@ -102,7 +112,7 @@ const mapAssetToMaterial = (asset: AssetItem): VoiceMaterial => {
id: asset.id,
name: asset.name,
description: (meta.description as string) || "",
gender: ((meta.gender as VoiceGender) || "neutral"),
gender: (meta.gender as VoiceGender) || "neutral",
tags,
fileName: asset.storage_key?.split("/").pop() || asset.name,
fileSize: asset.file_size || 0,
@@ -180,7 +190,9 @@ const getAudioDuration = (file: File): Promise<number> => {
interface MaterialFormProps {
initial?: VoiceMaterial;
onSubmit: (data: Omit<VoiceMaterial, "id" | "createdAt"> & { file?: File }) => void;
onSubmit: (
data: Omit<VoiceMaterial, "id" | "createdAt"> & { file?: File },
) => void;
onCancel: () => void;
loading?: boolean;
}
@@ -193,8 +205,12 @@ const MaterialForm: React.FC<MaterialFormProps> = ({
}) => {
const [name, setName] = useState(initial?.name ?? "");
const [description, setDescription] = useState(initial?.description ?? "");
const [gender, setGender] = useState<VoiceGender>(initial?.gender ?? "female");
const [selectedTags, setSelectedTags] = useState<string[]>(initial?.tags ?? []);
const [gender, setGender] = useState<VoiceGender>(
initial?.gender ?? "female",
);
const [selectedTags, setSelectedTags] = useState<string[]>(
initial?.tags ?? [],
);
const [file, setFile] = useState<File | undefined>(undefined);
const fileInputRef = useRef<HTMLInputElement>(null);
@@ -390,7 +406,9 @@ const VoiceMaterialCard: React.FC<VoiceCardProps> = ({
material.duration > 0 ? (currentTime / material.duration) * 100 : 0;
return (
<div className={`vmat-card ${genderClass(material.gender)}${isPlaying ? " playing" : ""}`}>
<div
className={`vmat-card ${genderClass(material.gender)}${isPlaying ? " playing" : ""}`}
>
{/* 操作按钮 */}
<div className="vmat-card-actions">
<button
@@ -478,7 +496,9 @@ const VoiceMaterialCard: React.FC<VoiceCardProps> = ({
/>
</div>
<span className="vmat-time">
{isPlaying ? formatDuration(currentTime) : formatDuration(material.duration)}
{isPlaying
? formatDuration(currentTime)
: formatDuration(material.duration)}
</span>
</div>
</div>
@@ -523,7 +543,9 @@ const VoiceMaterialRow: React.FC<VoiceRowProps> = ({
material.duration > 0 ? (currentTime / material.duration) * 100 : 0;
return (
<div className={`vmat-row ${genderClass(material.gender)}${isPlaying ? " playing" : ""}`}>
<div
className={`vmat-row ${genderClass(material.gender)}${isPlaying ? " playing" : ""}`}
>
{/* 播放按钮 */}
<button
type="button"
@@ -574,7 +596,9 @@ const VoiceMaterialRow: React.FC<VoiceRowProps> = ({
{/* 时长 */}
<span className="vmat-row-time">
{isPlaying ? formatDuration(currentTime) : formatDuration(material.duration)}
{isPlaying
? formatDuration(currentTime)
: formatDuration(material.duration)}
</span>
{/* 文件大小 */}
@@ -654,11 +678,16 @@ const VoiceMaterialLibrary: React.FC = () => {
const filterGenderParam = filterGender !== "all" ? filterGender : undefined;
const filterStyleParam = filterTag !== "all" ? filterTag : undefined;
const {
data: assets = [],
isLoading,
} = useQuery({
queryKey: ["assets", "voice", { keyword: filterKeyword, gender: filterGenderParam, style: filterStyleParam }],
const { data: assets = [], isLoading } = useQuery({
queryKey: [
"assets",
"voice",
{
keyword: filterKeyword,
gender: filterGenderParam,
style: filterStyleParam,
},
],
queryFn: () =>
getAssetsByKind("voice", {
keyword: filterKeyword,
@@ -761,7 +790,9 @@ const VoiceMaterialLibrary: React.FC = () => {
// ── 弹窗状态 ──────────────────────────────────────────────
const [uploadOpen, setUploadOpen] = useState(false);
const [editingMaterial, setEditingMaterial] = useState<VoiceMaterial | null>(null);
const [editingMaterial, setEditingMaterial] = useState<VoiceMaterial | null>(
null,
);
// ── 播放控制 ──────────────────────────────────────────────
const stopPlayback = useCallback(() => {
@@ -983,9 +1014,7 @@ const VoiceMaterialLibrary: React.FC = () => {
/>
</div>
<div className="vmat-toolbar-right">
<span className="vmat-result-count">
共 {filtered.length} 个素材
</span>
<span className="vmat-result-count">共 {filtered.length} 个素材</span>
<div className="vmat-view-toggle">
<button
type="button"