fix: 修复AssetLibrary和TemplateLibrary类型错误
CI/CD Pipeline / Frontend Lint (push) Failing after 139h10m2s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 139h10m2s
Deploy / Production Browser E2E (push) Failing after 1797h45m10s
Deploy / Build Production Runtime Images (push) Failing after 1797h45m15s
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Staging E2E Tests (push) Has been cancelled
Deploy / Deploy Production (push) Failing after 1798h16m38s
CI/CD Pipeline / Frontend Lint (push) Failing after 139h10m2s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 139h10m2s
Deploy / Production Browser E2E (push) Failing after 1797h45m10s
Deploy / Build Production Runtime Images (push) Failing after 1797h45m15s
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Staging E2E Tests (push) Has been cancelled
Deploy / Deploy Production (push) Failing after 1798h16m38s
This commit is contained in:
@@ -93,24 +93,25 @@ const formatDuration = (seconds: number): string => {
|
||||
const mapLibrary = (item: AssetLibraryItem): LibraryItem => ({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
kind: inferKind(item.default_mime_type || "video"),
|
||||
kind: item.kind || inferKind("video"),
|
||||
count: item.asset_count ?? 0,
|
||||
});
|
||||
|
||||
/** 将后端 ApiAssetItem 映射为前端 AssetItem */
|
||||
const mapAsset = (item: ApiAssetItem): AssetItem => {
|
||||
const { status, label } = inferStatus(
|
||||
item.quality_score,
|
||||
item.classification_status,
|
||||
item.quality_score ?? undefined,
|
||||
item.classification_status ?? undefined,
|
||||
);
|
||||
const metadata = item.metadata || {};
|
||||
return {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
kind: inferKind(item.mime_type || ""),
|
||||
thumbUrl: item.thumbnail_url,
|
||||
thumbUrl: metadata.thumbnail_url as string | undefined,
|
||||
status,
|
||||
statusLabel: label,
|
||||
duration: item.duration != null ? formatDuration(item.duration) : undefined,
|
||||
duration: metadata.duration != null ? formatDuration(metadata.duration as number) : undefined,
|
||||
size: item.file_size ? +(item.file_size / (1024 * 1024)).toFixed(1) : 0,
|
||||
createdAt: item.created_at
|
||||
? new Date(item.created_at).toISOString().slice(0, 10)
|
||||
@@ -268,7 +269,7 @@ const AssetLibrary: React.FC = () => {
|
||||
refetch: refetchAssets,
|
||||
} = useQuery<ApiAssetItem[], Error>({
|
||||
queryKey: ["assets", effectiveLibId],
|
||||
queryFn: () => getAssets(effectiveLibId || undefined),
|
||||
queryFn: () => getAssets(effectiveLibId),
|
||||
enabled: !!effectiveLibId,
|
||||
staleTime: 30_000,
|
||||
});
|
||||
@@ -298,17 +299,6 @@ const AssetLibrary: React.FC = () => {
|
||||
},
|
||||
});
|
||||
|
||||
const deleteAssetMutation = useMutation({
|
||||
mutationFn: deleteAsset,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["assets"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["asset-libraries"] });
|
||||
},
|
||||
onError: () => {
|
||||
message.error("删除素材失败");
|
||||
},
|
||||
});
|
||||
|
||||
/* 状态 */
|
||||
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());
|
||||
|
||||
@@ -326,8 +316,6 @@ const AssetLibrary: React.FC = () => {
|
||||
const [newLibKind, setNewLibKind] = useState<AssetKind>("video");
|
||||
|
||||
/* 派生数据 */
|
||||
const activeLibrary = libraries.find((l) => l.id === effectiveLibId);
|
||||
|
||||
const filteredAssets = useMemo(() => {
|
||||
let list = assets;
|
||||
|
||||
@@ -392,10 +380,8 @@ const AssetLibrary: React.FC = () => {
|
||||
if (file.size > LARGE_FILE_THRESHOLD) {
|
||||
message.info(`大文件 "${file.name}" 将使用直传上传`);
|
||||
}
|
||||
await uploadAssetDirect(file, (p) => {
|
||||
// 可选:显示上传进度
|
||||
if (p === 100) message.success(`"${file.name}" 上传成功`);
|
||||
});
|
||||
await uploadAssetDirect({ file, library_id: effectiveLibId });
|
||||
message.success(`"${file.name}" 上传成功`);
|
||||
queryClient.invalidateQueries({ queryKey: ["assets"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["asset-libraries"] });
|
||||
} catch {
|
||||
@@ -413,7 +399,7 @@ const AssetLibrary: React.FC = () => {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const newLib = await createLibMutation.mutateAsync(newLibName.trim());
|
||||
const newLib = await createLibMutation.mutateAsync({ name: newLibName.trim(), kind: newLibKind });
|
||||
setActiveLibId(newLib.id);
|
||||
setCreateModalOpen(false);
|
||||
setNewLibName("");
|
||||
@@ -440,9 +426,9 @@ const AssetLibrary: React.FC = () => {
|
||||
/* 诊断 — 调用真实 API */
|
||||
const handleDiagnose = async (asset: AssetItem) => {
|
||||
try {
|
||||
const result = await getAssetDiagnosis(asset.id);
|
||||
const score = result.quality_score ?? "-";
|
||||
message.success(`"${asset.name}" 诊断完成,质量分:${score}`);
|
||||
const result = await getAssetDiagnosis();
|
||||
const score = result.readiness_score ?? "-";
|
||||
message.success(`"${asset.name}" 诊断完成,就绪分:${score}`);
|
||||
queryClient.invalidateQueries({ queryKey: ["assets"] });
|
||||
} catch {
|
||||
message.error(`"${asset.name}" 诊断失败`);
|
||||
|
||||
@@ -13,7 +13,6 @@ import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { Button } from "@/components/ui";
|
||||
import {
|
||||
getTemplates,
|
||||
getTemplate,
|
||||
toggleFavoriteTemplate,
|
||||
type TemplateItem,
|
||||
} from "@/api/templates";
|
||||
|
||||
Reference in New Issue
Block a user