feat(assets): 素材库页面加载时自动创建默认 video 库 (#1626)
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (push) Successful in 1s
CI/CD Pipeline / Check push changed paths (push) Successful in 4s
CI/CD Pipeline / Build Staging API Image (push) Successful in 4m34s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 4m43s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 4m48s
CI/CD Pipeline / Validate - Style (push) Successful in 5m37s
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Successful in 6m13s
CI/CD Pipeline / Integration Tests (push) Successful in 6m30s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m38s
CI/CD Pipeline / Staging API Integration Tests (push) Failing after 2m3s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 2m20s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 9m26s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 3m28s
CI/CD Pipeline / Validate - Security (push) Successful in 10m29s
CI/CD Pipeline / Unit Tests (push) Successful in 17m0s
CI/CD Pipeline / Production Browser E2E (push) Failing after 336h7m24s
CI/CD Pipeline / Canary Release to Production (push) Failing after 336h7m25s
CI/CD Pipeline / Deploy Production (push) Failing after 336h7m25s
CI/CD Pipeline / CI Gate (push) Failing after 336h7m26s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 336h7m26s
CI/CD Pipeline / Build Production Web Image (push) Failing after 336h7m26s
CI/CD Pipeline / Build Production API Image (push) Failing after 336h7m26s
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Failing after 336h19m35s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 336h24m28s
CI/CD Pipeline / PR Build Web Image (push) Failing after 336h24m29s
CI/CD Pipeline / Retag skipped Staging Web Image (push) Failing after 336h19m35s
CI/CD Pipeline / PR Build API Image (push) Failing after 336h24m29s
CI/CD Pipeline / Frontend Lint (push) Failing after 336h24m29s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 336h24m31s
CI/CD Pipeline / Retag skipped Staging API Image (push) Failing after 336h53m55s

Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
This commit was merged in pull request #1626.
This commit is contained in:
2026-09-02 15:00:34 +08:00
committed by auto-approve-bot
parent 24e66da061
commit 5fb9975913
@@ -3,9 +3,11 @@ import { useQuery } from "@tanstack/react-query"
import {
getAssetLibraries,
getAssets,
ensureDefaultLibrary,
type AssetLibraryItem,
type AssetItem as ApiAssetItem,
} from "@/api/assets"
import { getOrCreateDefaultProject } from "@/api/projects"
import { mapLibrary, mapAsset, type AssetItem, type LibraryItem } from "../types"
/**
@@ -16,7 +18,18 @@ export function useAssetsData() {
/* ── 视频库列表查询 ── */
const { data: apiLibraries = [], isLoading: libLoading } = useQuery<AssetLibraryItem[], Error>({
queryKey: ["asset-libraries"],
queryFn: getAssetLibraries,
queryFn: async () => {
const libs = await getAssetLibraries()
// 如果没有 video 类型的库,自动创建默认视频素材库(与 useVoiceMaterials 保持一致)
const hasVideoLib = libs.some((lib) => lib.kind === "video")
if (!hasVideoLib) {
const project = await getOrCreateDefaultProject()
await ensureDefaultLibrary({ project_id: project.id, kind: "video" })
// 创建后重新拉取最新列表
return getAssetLibraries()
}
return libs
},
staleTime: 60_000,
})