fix(P1): 修复视频库左侧列表显示配音库 - 去掉voice→video硬映射 (#564) #570

Merged
auto-approve-bot merged 2 commits from fix/asset-library-voice-kind-mapping into develop 2026-07-19 11:04:04 +08:00
+10 -2
View File
@@ -32,6 +32,7 @@ import {
ThunderboltOutlined,
CheckCircleOutlined,
CloseCircleOutlined,
AudioOutlined,
} from "@ant-design/icons"
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
import {
@@ -56,7 +57,7 @@ import "./assets.css"
/* ============================================================
* 类型
* ============================================================ */
type AssetKind = "video" | "image"
type AssetKind = "video" | "image" | "voice"
type StatusType = "ok" | "warn" | "bad" | "info"
interface LibraryItem {
@@ -88,6 +89,7 @@ interface AssetItem {
/** 根据 mime_type 推断前端 AssetKind */
const inferKind = (mimeType: string): AssetKind => {
if (mimeType.startsWith("video/")) return "video"
if (mimeType.startsWith("audio/")) return "voice"
return "image"
}
@@ -142,7 +144,7 @@ const formatDuration = (seconds: number): string => {
const mapLibrary = (item: AssetLibraryItem): LibraryItem => ({
id: item.id,
name: item.name,
kind: (item.kind === "voice" ? "video" : item.kind) || inferKind("video"),
kind: item.kind || inferKind("video"),
count: item.asset_count ?? 0,
})
@@ -191,6 +193,8 @@ const kindIcon = (kind: AssetKind) => {
return <VideoCameraOutlined />
case "image":
return <PictureOutlined />
case "voice":
return <AudioOutlined />
}
}
@@ -200,6 +204,8 @@ const kindLabel = (kind: AssetKind) => {
return "视频"
case "image":
return "图片"
case "voice":
return "配音"
}
}
@@ -210,6 +216,8 @@ const thumbGradient = (kind: AssetKind): string => {
return "linear-gradient(135deg, #312e81 0%, #4f46e5 50%, #6366f1 100%)"
case "image":
return "linear-gradient(135deg, #78350f 0%, #d97706 50%, #f59e0b 100%)"
case "voice":
return "linear-gradient(135deg, #064e3b 0%, #059669 50%, #10b981 100%)"
}
}