feat(phase3): 砍掉剪辑计划独立入口,统一模板编辑器定位 #648

Merged
auto-approve-bot merged 1 commits from feat/phase3-remove-edit-plan-entries into develop 2026-07-20 18:14:56 +08:00
18 changed files with 40 additions and 1798 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ export interface BgmPresetsQuery {
keyword?: string
}
/** BGM 混音配置(嵌入剪辑计划 */
/** BGM 混音配置(嵌入模板 */
export interface BgmMixConfig {
/** 是否启用 BGM */
enabled: boolean
+20 -20
View File
@@ -1,5 +1,5 @@
/**
* 剪辑计划 API — 对接后端 Edit Plans Schema
* 模板草稿 API — 对接后端 Template Editor Schema
* 字段名严格匹配后端 API 响应
*/
import apiClient from "./client"
@@ -18,7 +18,7 @@ import type {
* 后端 API 类型(严格匹配后端 Schema)
* ============================================================ */
/** 剪辑计划状态枚举 */
/** 模板草稿状态枚举 */
export type EditPlanStatus =
"draft" | "editing" | "rendering" | "completed" | "failed" | "cancelled"
@@ -71,7 +71,7 @@ export interface SegmentTransitionConfig {
duration: number
}
/** 剪辑计划中的单个片段(config 内部 segments 项) */
/** 模板草稿中的单个片段(config 内部 segments 项) */
export interface EditPlanSegment {
segment_order: number
duration_min: number
@@ -83,7 +83,7 @@ export interface EditPlanSegment {
trim_config?: SegmentTrimConfig
}
/** 剪辑计划 config 完整类型(对齐后端 config JSON 结构) */
/** 模板草稿 config 完整类型(对齐后端 config JSON 结构) */
export interface EditPlanConfig {
title_config?: TitleConfig
subtitle_config?: SubtitleConfig
@@ -123,7 +123,7 @@ export interface EditPlanConfig {
material_mode?: string
}
/** 剪辑计划(后端响应) */
/** 模板草稿(后端响应) */
export interface EditPlan {
id: string
template_id: string
@@ -137,17 +137,17 @@ export interface EditPlan {
updated_at: string
}
/** 创建剪辑计划请求(后端要求 template_id + name 必填) */
/** 创建模板草稿请求(后端要求 template_id + name 必填) */
export interface CreateEditPlanRequest {
template_id: string
name: string
config?: EditPlanConfig
total_duration?: number
/** 来源剪辑计划 ID(从剪辑计划跳转到智能剪辑时关联) */
/** 来源模板草稿 ID(从模板编辑器跳转到智能剪辑时关联) */
source_edit_plan_id?: string
}
/** 更新剪辑计划请求 */
/** 更新模板草稿请求 */
export interface UpdateEditPlanRequest {
name?: string
config?: EditPlanConfig
@@ -163,7 +163,7 @@ export interface GenerateResponse {
clip_count: number
}
/** 剪辑计划关联的生成记录(实际是 GenerationTask 对象) */
/** 模板草稿关联的生成记录(实际是 GenerationTask 对象) */
export interface EditPlanGeneration {
id: string // 即 generation_task_id
source_edit_plan_id: string
@@ -323,7 +323,7 @@ export interface MediaAsset {
* API 函数 — 严格对接后端
* ============================================================ */
/** 剪辑计划列表查询参数 */
/** 模板草稿列表查询参数 */
export interface EditPlanListParams {
page?: number
page_size?: number
@@ -331,7 +331,7 @@ export interface EditPlanListParams {
status?: string
}
/** 剪辑计划列表分页响应 */
/** 模板草稿列表分页响应 */
export interface EditPlanListResponse {
items: EditPlan[]
total: number
@@ -339,7 +339,7 @@ export interface EditPlanListResponse {
page_size: number
}
/** 获取剪辑计划列表(支持分页和筛选) */
/** 获取模板草稿列表(支持分页和筛选) */
export async function getEditPlans(params?: EditPlanListParams): Promise<EditPlanListResponse> {
const response = await apiClient.get<EditPlanListResponse>("/edit-plans", {
params,
@@ -347,19 +347,19 @@ export async function getEditPlans(params?: EditPlanListParams): Promise<EditPla
return response.data
}
/** 获取单个剪辑计划 */
/** 获取单个模板草稿 */
export async function getEditPlan(planId: string): Promise<EditPlan> {
const response = await apiClient.get(`/edit-plans/${planId}`)
return response.data
}
/** 创建剪辑计划 */
/** 创建模板草稿 */
export async function createEditPlan(data: CreateEditPlanRequest): Promise<EditPlan> {
const response = await apiClient.post("/edit-plans", data)
return response.data
}
/** 更新剪辑计划 */
/** 更新模板草稿 */
export async function updateEditPlan(
planId: string,
data: UpdateEditPlanRequest,
@@ -368,18 +368,18 @@ export async function updateEditPlan(
return response.data
}
/** 删除剪辑计划 */
/** 删除模板草稿 */
export async function deleteEditPlan(planId: string): Promise<void> {
await apiClient.delete(`/edit-plans/${planId}`)
}
/** 触发剪辑计划生成 */
/** 触发生成 */
export async function generateEditPlan(planId: string): Promise<GenerateResponse> {
const response = await apiClient.post(`/edit-plans/${planId}/generate`)
return response.data
}
/** 获取剪辑计划生成状态(轮询用) */
/** 获取生成状态(轮询用) */
export async function getGenerationStatus(planId: string): Promise<GenerationStatusResponse> {
const response = await apiClient.get(`/edit-plans/${planId}/generation-status`)
return response.data
@@ -403,7 +403,7 @@ export async function generateCover(
return response.data
}
/** 获取剪辑计划关联的生成记录 */
/** 获取模板草稿关联的生成记录 */
export async function getEditPlanGenerations(planId: string): Promise<EditPlanGeneration[]> {
const response = await apiClient.get(`/edit-plans/${planId}/generations`)
return response.data.items || []
@@ -607,7 +607,7 @@ export interface CopyEditPlanRequest {
project_id?: string
}
/** 复制剪辑计划(含所有片段配置) */
/** 复制模板草稿(含所有片段配置) */
export async function copyEditPlan(planId: string, data?: CopyEditPlanRequest): Promise<EditPlan> {
const response = await apiClient.post<EditPlan>(`/edit-plans/${planId}/copy`, data || {})
return response.data
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* 剪辑计划编辑器 API
* 模板编辑器 API
* 对接后端 /api/v1/templates 路由
*/
import apiClient from "./client"
+4 -4
View File
@@ -4,7 +4,7 @@
* - GET /api/v1/templates — 模板列表(分页/筛选)
* - GET /api/v1/templates/{id} — 模板详情
* - POST /api/v1/templates/{id}/copy — 复制模板
* - POST /api/v1/templates/{id}/generate — 从模板生成剪辑计划
* - POST /api/v1/templates/{id}/generate — 从模板生成
* - POST /api/v1/templates/{id}/toggle-favorite — 收藏/取消收藏
*/
import apiClient from "./client"
@@ -76,14 +76,14 @@ export interface TemplateListResponse {
page_size: number
}
/** 从模板生成剪辑计划请求 */
/** 从模板生成请求 */
export interface GenerateFromTemplateRequest {
asset_ids?: string[]
name?: string
config?: EditPlanConfig
}
/** 从模板生成剪辑计划响应 */
/** 从模板生成响应 */
export interface GenerateFromTemplateResponse {
plan_id: string
template_id: string
@@ -134,7 +134,7 @@ export const copyTemplate = async (templateId: string): Promise<CopyTemplateResp
return response.data
}
/** 从模板生成剪辑计划 */
/** 从模板生成 */
export const generateFromTemplate = async (
templateId: string,
data?: GenerateFromTemplateRequest,
+1 -12
View File
@@ -81,12 +81,7 @@ export const NAV_ITEMS: NavItem[] = [
path: "/app/my-templates",
icon: React.createElement(FolderOutlined),
},
{
key: "edit-plans",
label: "剪辑计划",
path: "/app/edit-plans",
icon: React.createElement(UnorderedListOutlined),
},
{
key: "generate",
label: "智能剪辑",
@@ -142,12 +137,6 @@ export const NAV_GROUPS: NavGroup[] = [
path: "/app/editing-planner",
icon: React.createElement(EditOutlined),
},
{
key: "edit-plans",
label: "剪辑计划",
path: "/app/edit-plans",
icon: React.createElement(UnorderedListOutlined),
},
],
},
{
-515
View File
@@ -1,515 +0,0 @@
/**
* 剪辑计划管理页面
* 展示用户的所有剪辑计划,支持状态筛选、模板筛选、分页、一键重新生成
*/
import { useState, useCallback } from "react"
import { useNavigate } from "react-router-dom"
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
import { Table, Tabs, Select, Tag, Button, message, Popconfirm, Tooltip } from "antd"
import {
CheckCircleOutlined,
ClockCircleOutlined,
SyncOutlined,
CloseCircleOutlined,
EditOutlined,
DeleteOutlined,
FileTextOutlined,
ThunderboltOutlined,
CopyOutlined,
UnorderedListOutlined,
StopOutlined,
} from "@ant-design/icons"
import type { ColumnsType } from "antd/es/table"
import {
getEditPlans,
deleteEditPlan,
generateEditPlan,
cancelGeneration,
copyEditPlan,
type EditPlan,
type EditPlanStatus,
type EditPlanListParams,
} from "@/api/editPlans"
import { getTemplatesList, type TemplateItem } from "@/api/templates"
import "./edit-plans.css"
/* ──────────── 常量 ──────────── */
/** 状态 Tab 配置 */
const STATUS_TABS: { key: EditPlanStatus | "all"; label: string }[] = [
{ key: "all", label: "全部" },
{ key: "draft", label: "草稿" },
{ key: "editing", label: "编辑中" },
{ key: "rendering", label: "渲染中" },
{ key: "completed", label: "已完成" },
{ key: "failed", label: "失败" },
{ key: "cancelled", label: "已取消" },
]
/** 状态标签配置 */
const STATUS_CONFIG: Record<
EditPlanStatus,
{ label: string; color: string; icon: React.ReactNode }
> = {
draft: {
label: "草稿",
color: "default",
icon: <FileTextOutlined />,
},
editing: {
label: "编辑中",
color: "processing",
icon: <EditOutlined />,
},
rendering: {
label: "渲染中",
color: "warning",
icon: <SyncOutlined spin />,
},
completed: {
label: "已完成",
color: "success",
icon: <CheckCircleOutlined />,
},
failed: {
label: "失败",
color: "error",
icon: <CloseCircleOutlined />,
},
cancelled: {
label: "已取消",
color: "default",
icon: <StopOutlined />,
},
}
/* ──────────── 工具函数 ──────────── */
/** 格式化时长 */
const formatDuration = (seconds: number): string => {
if (seconds <= 0) return "-"
const totalSec = Math.round(seconds)
const m = Math.floor(totalSec / 60)
const s = totalSec % 60
if (m === 0) return `${s}`
return `${m}${s > 0 ? `${s}` : ""}`
}
/** 格式化时间 */
const formatTime = (dateStr?: string | null): string => {
if (!dateStr) return "-"
const date = new Date(dateStr)
return date.toLocaleString("zh-CN", {
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
})
}
/* ──────────── 主组件 ──────────── */
export default function EditPlans() {
const navigate = useNavigate()
const queryClient = useQueryClient()
// 筛选状态
const [statusFilter, setStatusFilter] = useState<EditPlanStatus | "all">("all")
const [templateFilter, setTemplateFilter] = useState<string>("all")
const [page, setPage] = useState(1)
const [pageSize, setPageSize] = useState(20)
// 查询参数
const queryParams: EditPlanListParams = {
page,
page_size: pageSize,
...(statusFilter !== "all" && { status: statusFilter }),
...(templateFilter !== "all" && { template_id: templateFilter }),
}
// 获取剪辑计划列表
const {
data: planData,
isLoading,
error,
} = useQuery({
queryKey: ["edit-plans", queryParams],
queryFn: () => getEditPlans(queryParams),
refetchInterval: (query) => {
// 有进行中的计划时自动刷新
const plans = query.state.data?.items ?? []
const hasRunning = plans.some((p) => p.status === "rendering" || p.status === "editing")
return hasRunning ? 5000 : false
},
})
// 获取模板列表(用于筛选下拉)
const { data: templates } = useQuery({
queryKey: ["templates-list-simple"],
queryFn: getTemplatesList,
})
const plans = planData?.items ?? []
const total = planData?.total ?? 0
// 模板名称映射
const templateNameMap = new Map<string, string>()
;(templates ?? []).forEach((t: TemplateItem) => {
templateNameMap.set(t.id, t.name)
})
// 删除计划
const deleteMutation = useMutation({
mutationFn: deleteEditPlan,
onSuccess: () => {
message.success("剪辑计划已删除")
queryClient.invalidateQueries({ queryKey: ["edit-plans"] })
},
onError: () => {
message.error("删除失败,请稍后重试")
},
})
// 重新生成
const regenerateMutation = useMutation({
mutationFn: generateEditPlan,
onSuccess: () => {
message.success("已重新提交生成")
queryClient.invalidateQueries({ queryKey: ["edit-plans"] })
},
onError: () => {
message.error("重新生成失败,请稍后重试")
},
})
// 取消生成
const cancelMutation = useMutation({
mutationFn: cancelGeneration,
onSuccess: () => {
message.success("已提交取消请求")
queryClient.invalidateQueries({ queryKey: ["edit-plans"] })
},
onError: () => {
message.error("取消失败,请稍后重试")
},
})
// 复制计划
const copyMutation = useMutation({
mutationFn: ({ planId, name }: { planId: string; name?: string }) =>
copyEditPlan(planId, name ? { name } : undefined),
onSuccess: (newPlan) => {
message.success("计划已复制")
queryClient.invalidateQueries({ queryKey: ["edit-plans"] })
// 自动跳转到新计划的编辑器
navigate(`/app/editing-planner?planId=${newPlan.id}`)
},
onError: () => {
message.error("复制失败,请稍后重试")
},
})
// 跳转到剪辑编辑器
const handleEdit = useCallback(
(plan: EditPlan) => {
navigate(`/app/editing-planner?planId=${plan.id}`)
},
[navigate],
)
// 表格列定义
const columns: ColumnsType<EditPlan> = [
{
title: "计划名称",
dataIndex: "name",
key: "name",
width: 240,
ellipsis: true,
render: (name: string, record: EditPlan) => (
<Tooltip title={name}>
<span className="plan-name" onClick={() => handleEdit(record)}>
{name}
</span>
</Tooltip>
),
},
{
title: "模板",
dataIndex: "template_id",
key: "template_id",
width: 140,
ellipsis: true,
render: (templateId: string) => {
const name = templateNameMap.get(templateId)
return (
<Tag color="blue" className="plan-template-tag">
{name || templateId.slice(0, 8)}
</Tag>
)
},
},
{
title: "状态",
dataIndex: "status",
key: "status",
width: 120,
render: (status: EditPlanStatus) => {
const config = STATUS_CONFIG[status] || {
label: status,
color: "default",
icon: null,
}
return (
<Tag color={config.color} icon={config.icon} className="plan-status-tag">
{config.label}
</Tag>
)
},
},
{
title: "时长",
dataIndex: "total_duration",
key: "total_duration",
width: 100,
render: (seconds: number) => <span className="plan-duration">{formatDuration(seconds)}</span>,
},
{
title: "视频数",
dataIndex: "result_count",
key: "result_count",
width: 80,
align: "center",
render: (count: number) => (
<span className="plan-result-count">{count > 0 ? count : "—"}</span>
),
},
{
title: "创建时间",
dataIndex: "created_at",
key: "created_at",
width: 130,
render: (time: string) => <span className="plan-time">{formatTime(time)}</span>,
},
{
title: "更新时间",
dataIndex: "updated_at",
key: "updated_at",
width: 130,
render: (time: string) => <span className="plan-time">{formatTime(time)}</span>,
},
{
title: "操作",
key: "action",
width: 240,
fixed: "right",
render: (_: unknown, record: EditPlan) => (
<div className="plan-actions">
<Tooltip title="片段管理">
<Button
type="link"
size="small"
icon={<UnorderedListOutlined />}
onClick={() => navigate(`/app/edit-plans/${record.id}/clips`)}
className="plan-action-btn"
>
</Button>
</Tooltip>
<Button
type="link"
size="small"
icon={<EditOutlined />}
onClick={() => handleEdit(record)}
className="plan-action-btn"
>
</Button>
{record.status === "rendering" && (
<Popconfirm
title="确认取消生成"
description="确定要取消当前生成任务吗?此操作不可恢复。"
onConfirm={() => cancelMutation.mutate(record.id)}
okText="确定"
cancelText="再等等"
okButtonProps={{ danger: true }}
>
<Button
type="link"
size="small"
danger
icon={<StopOutlined />}
loading={cancelMutation.isPending}
className="plan-action-btn plan-cancel-btn"
>
</Button>
</Popconfirm>
)}
{(record.status === "failed" ||
record.status === "completed" ||
record.status === "cancelled") && (
<Popconfirm
title="确认重新生成"
description="确定要重新生成这个剪辑计划吗?"
onConfirm={() => regenerateMutation.mutate(record.id)}
okText="确定"
cancelText="取消"
>
<Button
type="link"
size="small"
icon={<ThunderboltOutlined />}
loading={regenerateMutation.isPending}
className="plan-action-btn plan-regenerate-btn"
>
</Button>
</Popconfirm>
)}
<Popconfirm
title="复制计划"
description="确定要复制这个剪辑计划吗?将创建一个编辑中的新副本。"
onConfirm={() =>
copyMutation.mutate({
planId: record.id,
name: `${record.name} 副本`,
})
}
okText="确定"
cancelText="取消"
>
<Button
type="link"
size="small"
icon={<CopyOutlined />}
loading={copyMutation.isPending}
className="plan-action-btn"
>
</Button>
</Popconfirm>
<Popconfirm
title="确认删除"
description="确定要删除这个剪辑计划吗?此操作不可恢复。"
onConfirm={() => deleteMutation.mutate(record.id)}
okText="确定"
cancelText="取消"
okButtonProps={{ danger: true }}
>
<Button
type="link"
size="small"
danger
icon={<DeleteOutlined />}
loading={deleteMutation.isPending}
className="plan-action-btn"
>
</Button>
</Popconfirm>
</div>
),
},
]
// 错误处理
if (error) {
return (
<div className="edit-plans-page">
<div className="edit-plans-error">
<CloseCircleOutlined />
<p></p>
<Button onClick={() => window.location.reload()}></Button>
</div>
</div>
)
}
return (
<div className="edit-plans-page">
{/* 页面标题 */}
<div className="edit-plans-header">
<div className="edit-plans-header-text">
<h2></h2>
<p></p>
</div>
<Button type="primary" onClick={() => navigate("/app/templates")}>
</Button>
</div>
{/* 筛选栏 */}
<div className="edit-plans-filters">
{/* 状态 Tab */}
<Tabs
activeKey={statusFilter}
onChange={(key) => {
setStatusFilter(key as EditPlanStatus | "all")
setPage(1)
}}
items={STATUS_TABS.map((tab) => ({
key: tab.key,
label: tab.label,
}))}
className="edit-plans-status-tabs"
/>
{/* 模板筛选 */}
<Select
value={templateFilter}
onChange={(value) => {
setTemplateFilter(value)
setPage(1)
}}
options={[
{ value: "all", label: "全部模板" },
...(templates ?? []).map((t: TemplateItem) => ({
value: t.id,
label: t.name,
})),
]}
style={{ minWidth: 180 }}
placeholder="选择模板"
className="edit-plans-template-filter"
/>
</div>
{/* 计划表格 */}
<Table
columns={columns}
dataSource={plans}
rowKey="id"
loading={isLoading}
pagination={{
current: page,
pageSize,
total,
showSizeChanger: true,
showQuickJumper: true,
showTotal: (t) => `${t}`,
onChange: (p, ps) => {
setPage(p)
setPageSize(ps)
},
}}
scroll={{ x: 900 }}
className="edit-plans-table"
locale={{
emptyText: (
<div className="edit-plans-empty">
<ClockCircleOutlined />
<p></p>
<Button
type="primary"
style={{ marginTop: 12 }}
onClick={() => navigate("/app/templates")}
>
</Button>
</div>
),
}}
/>
</div>
)
}
@@ -1,621 +0,0 @@
/**
* 剪辑计划片段管理页面
* 对接后端 PR#389 片段 CRUD API
* 功能:列表查看、创建、编辑、删除、批量删除、拖拽排序、从素材导入
*/
import { useState, useCallback } from "react"
import { useParams, useNavigate } from "react-router-dom"
import { useQuery, useQueryClient } from "@tanstack/react-query"
import {
Table,
Button,
Space,
message,
Popconfirm,
Modal,
Form,
Input,
InputNumber,
Select,
Tag,
Drawer,
Empty,
Card,
} from "antd"
import {
ArrowLeftOutlined,
PlusOutlined,
DeleteOutlined,
EditOutlined,
UploadOutlined,
OrderedListOutlined,
SaveOutlined,
} from "@ant-design/icons"
import type { ColumnsType } from "antd/es/table"
import {
getEditPlan,
getEditPlanClips,
createEditPlanClip,
updateEditPlanClip,
deleteEditPlanClip,
batchDeleteEditPlanClips,
reorderEditPlanClips,
createClipsFromAssets,
getMediaAssets,
type EditPlanClip,
type EditPlanClipStatus,
} from "@/api/editPlans"
import "./plan-clips.css"
/* ──────────── 常量 ──────────── */
const CLIP_TYPE_OPTIONS = [
{ value: "main", label: "主片段" },
{ value: "intro", label: "片头" },
{ value: "outro", label: "片尾" },
{ value: "overlay", label: "叠加层" },
{ value: "background", label: "背景" },
{ value: "b_roll", label: "B-roll" },
]
const STATUS_COLORS: Record<EditPlanClipStatus, string> = {
pending: "default",
processing: "processing",
ready: "success",
failed: "error",
}
const STATUS_LABELS: Record<EditPlanClipStatus, string> = {
pending: "待处理",
processing: "处理中",
ready: "就绪",
failed: "失败",
}
const TRANSITION_OPTIONS = [
{ value: "cut", label: "硬切" },
{ value: "fade", label: "淡入淡出" },
{ value: "dissolve", label: "溶解" },
{ value: "zoom", label: "缩放" },
{ value: "slide_left", label: "左滑" },
{ value: "slide_right", label: "右滑" },
{ value: "slide_up", label: "上滑" },
{ value: "slide_down", label: "下滑" },
{ value: "wipe_left", label: "左擦除" },
{ value: "wipe_right", label: "右擦除" },
{ value: "wipe_up", label: "上擦除" },
{ value: "wipe_down", label: "下擦除" },
{ value: "circlecrop", label: "圆形裁切" },
{ value: "rectcrop", label: "矩形裁切" },
]
/* ──────────── 组件 ──────────── */
const PlanClipsManager: React.FC = () => {
const { planId } = useParams<{ planId: string }>()
const navigate = useNavigate()
const queryClient = useQueryClient()
/* ── 计划信息 ── */
const { data: plan, isLoading: planLoading } = useQuery({
queryKey: ["editPlan", planId],
queryFn: () => getEditPlan(planId!),
enabled: !!planId,
})
/* ── 片段列表 ── */
const { data: clipsData, isLoading: clipsLoading } = useQuery({
queryKey: ["editPlanClips", planId],
queryFn: () => getEditPlanClips(planId!, { limit: 500 }),
enabled: !!planId,
})
const clips = clipsData?.items ?? []
/* ── 选中的片段(批量操作) ── */
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([])
/* ── 编辑弹窗 ── */
const [editModalOpen, setEditModalOpen] = useState(false)
const [editingClip, setEditingClip] = useState<EditPlanClip | null>(null)
const [editForm] = Form.useForm()
const [editLoading, setEditLoading] = useState(false)
/* ── 素材导入抽屉 ── */
const [importDrawerOpen, setImportDrawerOpen] = useState(false)
const [selectedAssetIds, setSelectedAssetIds] = useState<string[]>([])
const [importLoading, setImportLoading] = useState(false)
const { data: assets } = useQuery({
queryKey: ["mediaAssets"],
queryFn: () => getMediaAssets(),
enabled: importDrawerOpen,
})
/* ── 重新排序模式 ── */
const [reorderMode, setReorderMode] = useState(false)
const [reorderItems, setReorderItems] = useState<EditPlanClip[]>([])
/* ── 列定义 ── */
const columns: ColumnsType<EditPlanClip> = [
{
title: "序号",
dataIndex: "order",
width: 70,
render: (_, __, index) => index + 1,
},
{
title: "类型",
dataIndex: "clip_type",
width: 100,
render: (type: string) => {
const opt = CLIP_TYPE_OPTIONS.find((o) => o.value === type)
return <Tag>{opt?.label || type}</Tag>
},
},
{
title: "素材",
dataIndex: "asset_id",
width: 150,
ellipsis: true,
render: (assetId: string) =>
assetId ? (
<code className="clip-asset-id">{assetId.slice(0, 12)}...</code>
) : (
<span style={{ color: "#999" }}></span>
),
},
{
title: "文本内容",
dataIndex: "text_content",
ellipsis: true,
render: (text: string) => text || <span style={{ color: "#999" }}>-</span>,
},
{
title: "时长",
dataIndex: "duration",
width: 90,
render: (d: number) => `${d?.toFixed(1) || 0}s`,
},
{
title: "转场",
dataIndex: "transition_effect",
width: 100,
render: (effect: string) => {
const opt = TRANSITION_OPTIONS.find((o) => o.value === effect)
return opt?.label || effect || "硬切"
},
},
{
title: "播放速度",
dataIndex: "playback_speed",
width: 90,
render: (s: number) => `${s || 1.0}x`,
},
{
title: "状态",
dataIndex: "status",
width: 90,
render: (status: EditPlanClipStatus) => (
<Tag color={STATUS_COLORS[status] || "default"}>{STATUS_LABELS[status] || status}</Tag>
),
},
{
title: "操作",
key: "action",
width: 140,
fixed: "right",
render: (_, record) => (
<Space size="small">
<Button
type="link"
size="small"
icon={<EditOutlined />}
onClick={() => handleEditClip(record)}
>
</Button>
<Popconfirm
title="删除片段"
description="确定删除这个片段吗?"
onConfirm={() => handleDeleteClip(record.id)}
okText="确定"
cancelText="取消"
okButtonProps={{ danger: true }}
>
<Button type="link" size="small" danger icon={<DeleteOutlined />}>
</Button>
</Popconfirm>
</Space>
),
},
]
/* ── 编辑片段 ── */
const handleEditClip = useCallback(
(clip: EditPlanClip) => {
setEditingClip(clip)
editForm.setFieldsValue({
clip_type: clip.clip_type,
asset_id: clip.asset_id,
text_content: clip.text_content,
duration: clip.duration,
start_time: clip.start_time,
transition_effect: clip.transition_effect,
transition_duration: clip.transition_duration,
playback_speed: clip.playback_speed,
})
setEditModalOpen(true)
},
[editForm],
)
const handleNewClip = useCallback(() => {
setEditingClip(null)
editForm.resetFields()
editForm.setFieldsValue({
clip_type: "main",
duration: 5,
transition_effect: "cut",
transition_duration: 0,
playback_speed: 1.0,
})
setEditModalOpen(true)
}, [editForm])
const handleSaveClip = async () => {
if (!planId) return
try {
const values = await editForm.validateFields()
setEditLoading(true)
if (editingClip) {
// 更新
await updateEditPlanClip(planId, editingClip.id, values)
message.success("片段已更新")
} else {
// 新建
const maxOrder = clips.length > 0 ? Math.max(...clips.map((c) => c.order)) : -1
await createEditPlanClip(planId, {
...values,
order: maxOrder + 1,
})
message.success("片段已创建")
}
queryClient.invalidateQueries({ queryKey: ["editPlanClips", planId] })
setEditModalOpen(false)
} catch (err) {
console.error(err)
message.error(editingClip ? "更新失败" : "创建失败")
} finally {
setEditLoading(false)
}
}
/* ── 删除片段 ── */
const handleDeleteClip = async (clipId: string) => {
if (!planId) return
try {
await deleteEditPlanClip(planId, clipId)
message.success("已删除")
queryClient.invalidateQueries({ queryKey: ["editPlanClips", planId] })
setSelectedRowKeys((prev) => prev.filter((k) => k !== clipId))
} catch {
message.error("删除失败")
}
}
/* ── 批量删除 ── */
const handleBatchDelete = async () => {
if (!planId || selectedRowKeys.length === 0) return
try {
await batchDeleteEditPlanClips(
planId,
selectedRowKeys.map((k) => String(k)),
)
message.success(`已删除 ${selectedRowKeys.length} 个片段`)
queryClient.invalidateQueries({ queryKey: ["editPlanClips", planId] })
setSelectedRowKeys([])
} catch {
message.error("批量删除失败")
}
}
/* ── 从素材导入 ── */
const handleImportFromAssets = async () => {
if (!planId || selectedAssetIds.length === 0) return
try {
setImportLoading(true)
const res = await createClipsFromAssets(planId, selectedAssetIds)
message.success(`已导入 ${res.created_count} 个片段`)
queryClient.invalidateQueries({ queryKey: ["editPlanClips", planId] })
setImportDrawerOpen(false)
setSelectedAssetIds([])
} catch {
message.error("导入失败")
} finally {
setImportLoading(false)
}
}
/* ── 排序模式 ── */
const enterReorderMode = () => {
setReorderItems([...clips].sort((a, b) => a.order - b.order))
setReorderMode(true)
}
const moveClip = (fromIndex: number, toIndex: number) => {
if (toIndex < 0 || toIndex >= reorderItems.length) return
const newItems = [...reorderItems]
const [moved] = newItems.splice(fromIndex, 1)
newItems.splice(toIndex, 0, moved)
setReorderItems(newItems)
}
const saveReorder = async () => {
if (!planId) return
const items = reorderItems.map((clip, index) => ({
clip_id: clip.id,
new_order: index,
}))
try {
await reorderEditPlanClips(planId, items)
message.success("排序已保存")
queryClient.invalidateQueries({ queryKey: ["editPlanClips", planId] })
setReorderMode(false)
} catch {
message.error("排序保存失败")
}
}
const cancelReorder = () => {
setReorderMode(false)
setReorderItems([])
}
/* ── 渲染 ── */
const displayClips = reorderMode ? reorderItems : [...clips].sort((a, b) => a.order - b.order)
return (
<div className="plan-clips-page">
{/* 顶部 */}
<div className="plan-clips-header">
<div className="plan-clips-header-left">
<Button
type="text"
icon={<ArrowLeftOutlined />}
onClick={() => navigate("/app/edit-plans")}
>
</Button>
<div className="plan-clips-title">
<h2>{plan?.name || "加载中..."}</h2>
<p>
{planLoading
? "加载中..."
: `${clipsData?.total || 0} 个片段 · ${plan?.status || ""}`}
</p>
</div>
</div>
<div className="plan-clips-header-right">
<Space>
<Button icon={<UploadOutlined />} onClick={() => setImportDrawerOpen(true)}>
</Button>
{reorderMode ? (
<>
<Button onClick={cancelReorder}></Button>
<Button type="primary" icon={<SaveOutlined />} onClick={saveReorder}>
</Button>
</>
) : (
<>
<Button
icon={<OrderedListOutlined />}
onClick={enterReorderMode}
disabled={clips.length === 0}
>
</Button>
<Button type="primary" icon={<PlusOutlined />} onClick={handleNewClip}>
</Button>
</>
)}
</Space>
</div>
</div>
{/* 批量操作栏 */}
{!reorderMode && selectedRowKeys.length > 0 && (
<div className="plan-clips-batch-bar">
<span> {selectedRowKeys.length} </span>
<Popconfirm
title="批量删除"
description={`确定删除选中的 ${selectedRowKeys.length} 个片段吗?`}
onConfirm={handleBatchDelete}
okText="确定"
cancelText="取消"
okButtonProps={{ danger: true }}
>
<Button danger icon={<DeleteOutlined />}>
</Button>
</Popconfirm>
</div>
)}
{/* 排序列表 */}
{reorderMode && (
<Card className="plan-clips-reorder-card" title="拖拽调整顺序">
<div className="plan-clips-reorder-list">
{reorderItems.map((clip, index) => (
<div key={clip.id} className="plan-clips-reorder-item">
<span className="reorder-index">{index + 1}</span>
<span className="reorder-type">
{CLIP_TYPE_OPTIONS.find((o) => o.value === clip.clip_type)?.label ||
clip.clip_type}
</span>
<span className="reorder-content">
{clip.text_content || clip.asset_id || "无内容"}
</span>
<span className="reorder-duration">{clip.duration.toFixed(1)}s</span>
<Space>
<Button
size="small"
onClick={() => moveClip(index, index - 1)}
disabled={index === 0}
>
</Button>
<Button
size="small"
onClick={() => moveClip(index, index + 1)}
disabled={index === reorderItems.length - 1}
>
</Button>
</Space>
</div>
))}
</div>
</Card>
)}
{/* 片段列表 */}
{!reorderMode && (
<div className="plan-clips-table-wrap">
<Table
rowKey="id"
columns={columns}
dataSource={displayClips}
loading={clipsLoading}
rowSelection={{
selectedRowKeys,
onChange: setSelectedRowKeys,
}}
pagination={false}
locale={{
emptyText: (
<Empty
description="暂无片段,点击上方按钮添加或从素材导入"
image={Empty.PRESENTED_IMAGE_SIMPLE}
/>
),
}}
scroll={{ x: 1000 }}
/>
</div>
)}
{/* 编辑弹窗 */}
<Modal
title={editingClip ? "编辑片段" : "添加片段"}
open={editModalOpen}
onCancel={() => setEditModalOpen(false)}
onOk={handleSaveClip}
confirmLoading={editLoading}
okText="保存"
cancelText="取消"
width={560}
>
<Form form={editForm} layout="vertical">
<Form.Item
label="片段类型"
name="clip_type"
rules={[{ required: true, message: "请选择类型" }]}
>
<Select options={CLIP_TYPE_OPTIONS} />
</Form.Item>
<Form.Item label="素材 ID" name="asset_id">
<Input placeholder="关联的素材 ID(可选)" />
</Form.Item>
<Form.Item label="文本内容" name="text_content">
<Input.TextArea rows={3} placeholder="字幕/配音文案等" />
</Form.Item>
<div style={{ display: "flex", gap: 16 }}>
<Form.Item label="起始时间(秒)" name="start_time" style={{ flex: 1 }}>
<InputNumber min={0} step={0.1} style={{ width: "100%" }} />
</Form.Item>
<Form.Item label="时长(秒)" name="duration" style={{ flex: 1 }}>
<InputNumber min={0} step={0.1} style={{ width: "100%" }} />
</Form.Item>
</div>
<div style={{ display: "flex", gap: 16 }}>
<Form.Item label="转场效果" name="transition_effect" style={{ flex: 1 }}>
<Select options={TRANSITION_OPTIONS} />
</Form.Item>
<Form.Item label="转场时长" name="transition_duration" style={{ flex: 1 }}>
<InputNumber min={0} step={0.1} style={{ width: "100%" }} />
</Form.Item>
</div>
<Form.Item label="播放速度" name="playback_speed">
<InputNumber min={0.1} max={10} step={0.1} style={{ width: "100%" }} />
</Form.Item>
</Form>
</Modal>
{/* 素材导入抽屉 */}
<Drawer
title="从视频库导入"
open={importDrawerOpen}
onClose={() => setImportDrawerOpen(false)}
width={480}
extra={
<Button
type="primary"
onClick={handleImportFromAssets}
loading={importLoading}
disabled={selectedAssetIds.length === 0}
>
{selectedAssetIds.length > 0 ? `(${selectedAssetIds.length})` : ""}
</Button>
}
>
{assets && assets.length > 0 ? (
<div className="asset-import-list">
{assets.map((asset) => (
<div
key={asset.id}
className={`asset-import-item ${
selectedAssetIds.includes(asset.id) ? "selected" : ""
}`}
onClick={() => {
setSelectedAssetIds((prev) =>
prev.includes(asset.id)
? prev.filter((id) => id !== asset.id)
: [...prev, asset.id],
)
}}
>
<div className="asset-thumb">
{asset.thumbnail_url ? (
<img src={asset.thumbnail_url} alt={asset.name} />
) : (
<div className="asset-thumb-placeholder">{asset.type}</div>
)}
</div>
<div className="asset-info">
<div className="asset-name" title={asset.name}>
{asset.name}
</div>
<div className="asset-meta">
{asset.type}
{asset.duration ? ` · ${asset.duration.toFixed(1)}s` : ""}
</div>
</div>
</div>
))}
</div>
) : (
<Empty description="视频库为空" />
)}
</Drawer>
</div>
)
}
export default PlanClipsManager
@@ -1,260 +0,0 @@
/**
* 剪辑计划管理页面样式
*/
/* ── 页面容器 ──────────────────────────────────────────── */
.edit-plans-page {
padding: 24px;
max-width: 1400px;
margin: 0 auto;
}
/* ── 页面头部 ──────────────────────────────────────────── */
.edit-plans-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
margin-bottom: 24px;
}
.edit-plans-header-text h2 {
margin: 0 0 4px;
font-size: 22px;
font-weight: 600;
color: var(--text-primary, #1e293b);
}
.edit-plans-header-text p {
margin: 0;
font-size: 14px;
color: var(--text-secondary, #64748b);
}
/* ── 筛选栏 ────────────────────────────────────────────── */
.edit-plans-filters {
display: flex;
align-items: center;
gap: 16px;
margin-bottom: 20px;
flex-wrap: wrap;
}
.edit-plans-status-tabs {
flex: 1;
}
.edit-plans-status-tabs .ant-tabs-nav {
margin-bottom: 0 !important;
}
.edit-plans-status-tabs .ant-tabs-tab {
padding: 8px 16px !important;
font-size: 14px;
}
.edit-plans-status-tabs .ant-tabs-tab-active .ant-tabs-tab-btn {
color: var(--primary-500, #6366f1) !important;
font-weight: 500;
}
.edit-plans-status-tabs .ant-tabs-ink-bar {
background: var(--primary-500, #6366f1) !important;
}
.edit-plans-template-filter {
min-width: 180px;
}
/* ── 表格 ──────────────────────────────────────────────── */
.edit-plans-table {
background: var(--bg-surface, #fff);
border-radius: var(--radius-lg, 12px);
overflow: hidden;
border: 1px solid var(--border-primary, #e2e8f0);
}
.edit-plans-table .ant-table {
font-size: 14px;
}
.edit-plans-table .ant-table-thead > tr > th {
background: var(--bg-tertiary, #f8fafc) !important;
border-bottom: 1px solid var(--border-primary, #e2e8f0);
font-weight: 500;
color: var(--text-secondary, #64748b);
font-size: 13px;
padding: 12px 16px;
}
.edit-plans-table .ant-table-tbody > tr > td {
padding: 14px 16px;
border-bottom: 1px solid var(--border-light, #f1f5f9);
}
.edit-plans-table .ant-table-tbody > tr:hover > td {
background: var(--bg-hover, #f8fafc) !important;
}
/* ── 计划名称 ──────────────────────────────────────────── */
.plan-name {
font-weight: 500;
color: var(--text-primary, #1e293b);
cursor: pointer;
transition: color 0.2s;
}
.plan-name:hover {
color: var(--primary-500, #6366f1);
}
/* ── 状态标签 ──────────────────────────────────────────── */
.plan-status-tag {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 4px 10px;
border-radius: 16px;
font-size: 12px;
font-weight: 500;
}
.plan-status-tag.ant-tag-default {
background: #f1f5f9;
color: #64748b;
border-color: transparent;
}
.plan-status-tag.ant-tag-processing {
background: #eff6ff;
color: #2563eb;
border-color: transparent;
}
.plan-status-tag.ant-tag-success {
background: #f0fdf4;
color: #16a34a;
border-color: transparent;
}
.plan-status-tag.ant-tag-error {
background: #fef2f2;
color: #dc2626;
border-color: transparent;
}
.plan-status-tag.ant-tag-warning {
background: #fffbeb;
color: #d97706;
border-color: transparent;
}
/* ── 时长 ──────────────────────────────────────────────── */
.plan-duration {
font-variant-numeric: tabular-nums;
color: var(--text-secondary, #64748b);
}
/* ── 时间 ──────────────────────────────────────────────── */
.plan-time {
color: var(--text-secondary, #64748b);
font-size: 13px;
}
/* ── 操作按钮 ──────────────────────────────────────────── */
.plan-actions {
display: flex;
gap: 4px;
}
.plan-action-btn {
padding: 4px 8px !important;
font-size: 13px !important;
}
.plan-action-btn.ant-btn-link {
color: var(--primary-500, #6366f1);
}
.plan-action-btn.ant-btn-link:hover {
color: var(--primary-600, #4f46e5);
}
.plan-regenerate-btn {
color: var(--primary-500, #6366f1) !important;
}
.plan-regenerate-btn:hover {
color: var(--primary-600, #4f46e5) !important;
}
/* ── 空状态 ────────────────────────────────────────────── */
.edit-plans-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px 20px;
text-align: center;
}
.edit-plans-empty .anticon {
font-size: 48px;
color: var(--text-disabled, #cbd5e1);
margin-bottom: 16px;
}
.edit-plans-empty p {
margin: 0;
font-size: 14px;
color: var(--text-secondary, #64748b);
}
/* ── 错误状态 ──────────────────────────────────────────── */
.edit-plans-error {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px 20px;
text-align: center;
background: var(--bg-surface, #fff);
border-radius: var(--radius-lg, 12px);
border: 1px solid var(--border-primary, #e2e8f0);
}
.edit-plans-error .anticon {
font-size: 48px;
color: #ef4444;
margin-bottom: 16px;
}
.edit-plans-error p {
margin: 0 0 16px;
font-size: 14px;
color: var(--text-secondary, #64748b);
}
/* ── 响应式 ────────────────────────────────────────────── */
@media (max-width: 768px) {
.edit-plans-page {
padding: 16px;
}
.edit-plans-header {
flex-direction: column;
gap: 12px;
}
.edit-plans-filters {
flex-direction: column;
align-items: stretch;
}
.edit-plans-status-tabs {
width: 100%;
}
.edit-plans-template-filter {
width: 100%;
}
}
@@ -1,203 +0,0 @@
/* 剪辑计划片段管理页面 */
.plan-clips-page {
padding: 24px;
min-height: 100vh;
background: #f5f7fa;
}
.plan-clips-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.plan-clips-header-left {
display: flex;
align-items: center;
gap: 16px;
}
.plan-clips-title h2 {
margin: 0;
font-size: 20px;
font-weight: 600;
color: #1f2937;
}
.plan-clips-title p {
margin: 4px 0 0;
font-size: 13px;
color: #6b7280;
}
.plan-clips-batch-bar {
display: flex;
align-items: center;
gap: 16px;
padding: 12px 20px;
margin-bottom: 16px;
background: #e6f4ff;
border-radius: 8px;
font-size: 14px;
color: #1677ff;
}
.plan-clips-table-wrap {
background: #fff;
border-radius: 12px;
padding: 16px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.clip-asset-id {
font-size: 12px;
color: #6b7280;
background: #f3f4f6;
padding: 2px 6px;
border-radius: 4px;
}
/* 排序模式 */
.plan-clips-reorder-card {
margin-bottom: 16px;
border-radius: 12px;
}
.plan-clips-reorder-list {
display: flex;
flex-direction: column;
gap: 8px;
}
.plan-clips-reorder-item {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 16px;
background: #f9fafb;
border: 1px solid #e5e7eb;
border-radius: 8px;
cursor: grab;
transition: all 0.2s;
}
.plan-clips-reorder-item:hover {
border-color: #1677ff;
background: #f0f7ff;
}
.reorder-index {
width: 28px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
background: #1677ff;
color: #fff;
border-radius: 50%;
font-size: 13px;
font-weight: 600;
flex-shrink: 0;
}
.reorder-type {
flex-shrink: 0;
font-size: 12px;
color: #6b7280;
padding: 2px 8px;
background: #eef2ff;
border-radius: 4px;
}
.reorder-content {
flex: 1;
font-size: 14px;
color: #1f2937;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.reorder-duration {
flex-shrink: 0;
font-size: 13px;
color: #6b7280;
font-variant-numeric: tabular-nums;
}
/* 素材导入 */
.asset-import-list {
display: flex;
flex-direction: column;
gap: 8px;
max-height: calc(100vh - 200px);
overflow-y: auto;
}
.asset-import-item {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 12px;
border: 1px solid #e5e7eb;
border-radius: 8px;
cursor: pointer;
transition: all 0.2s;
}
.asset-import-item:hover {
border-color: #1677ff;
background: #f0f7ff;
}
.asset-import-item.selected {
border-color: #1677ff;
background: #e6f4ff;
}
.asset-thumb {
width: 56px;
height: 40px;
border-radius: 4px;
overflow: hidden;
background: #f3f4f6;
flex-shrink: 0;
}
.asset-thumb img {
width: 100%;
height: 100%;
object-fit: cover;
}
.asset-thumb-placeholder {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 11px;
color: #9ca3af;
text-transform: uppercase;
}
.asset-info {
flex: 1;
min-width: 0;
}
.asset-name {
font-size: 14px;
color: #1f2937;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.asset-meta {
font-size: 12px;
color: #9ca3af;
margin-top: 2px;
}
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* 剪辑计划编辑器 — V21 原型 1:1 还原样式
* 模板编辑器 — V21 原型 1:1 还原样式
* 颜色:对齐全局V21设计系统,使用 var(--bg-primary)、var(--bg-secondary)、var(--primary) 等
* 布局:3行(顶栏52 + 模式栏56 + 三栏主体flex
* 面板宽度:左240 / 右280
+3 -3
View File
@@ -206,7 +206,7 @@ const EditingPlanner: React.FC = () => {
setSelectedAssetIds(ids)
}
/* ── 剪辑计划(从列表编辑进入时) ── */
/* ── 模板草稿(从模板列表编辑进入时) ── */
const [loadedPlanId] = useState<string | null>(urlPlanId || null)
/* ── 播放 ── */
@@ -336,7 +336,7 @@ const EditingPlanner: React.FC = () => {
}, [loadedTemplateId, resetClips])
/**
* 加载已有剪辑计划数据到编辑器
* 加载已有模板草稿数据到编辑器
* 从列表页"编辑"按钮进入时,URL 带 planId,需要还原计划配置
*/
useEffect(() => {
@@ -456,7 +456,7 @@ const EditingPlanner: React.FC = () => {
setTimeout(() => resetClips(mapped), 100)
}
})
.catch(() => message.error("加载剪辑计划失败"))
.catch(() => message.error("加载模板草稿失败"))
}, [loadedPlanId, resetClips])
/* ──────────── 计算 ──────────── */
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* 生成历史弹窗 — 展示当前剪辑计划的生成任务记录
* 生成历史弹窗 — 展示当前模板草稿的生成任务记录
* 从 EditingPlanner 拆分,避免主文件过大
*/
import React from "react"
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* 剪辑计划片段管理 Hook
* 模板片段管理 Hook
* 对接后端 PR#389 片段 CRUD API,替代原来的 config.segments 模式
*
* 功能:
+5 -5
View File
@@ -400,7 +400,7 @@ const GeneratePage: React.FC = () => {
const progressTimer = useRef<ReturnType<typeof setInterval>>(undefined)
const audioRef = useRef<HTMLAudioElement | null>(null)
/* ── URL 参数:从剪辑计划跳转过来时携带 edit_plan_id + plan_config ── */
/* ── URL 参数:从模板编辑器跳转过来时携带 edit_plan_id + plan_config ── */
const [searchParams] = useSearchParams()
const editPlanId = searchParams.get("edit_plan_id")
const planConfigStr = searchParams.get("plan_config")
@@ -478,7 +478,7 @@ const GeneratePage: React.FC = () => {
setSelectedMaterials(cfg.asset_ids.filter((v): v is string => typeof v === "string"))
}
} catch (err) {
console.warn("加载剪辑计划配置失败:", err)
console.warn("加载模板草稿配置失败:", err)
}
}
loadPlanConfig()
@@ -1309,7 +1309,7 @@ const GeneratePage: React.FC = () => {
<div className="xx-empty-state">
<p></p>
<p style={{ fontSize: 13, color: "var(--text-tertiary)" }}>
</p>
</div>
) : (
@@ -1658,7 +1658,7 @@ const GeneratePage: React.FC = () => {
<span>AI </span>
</div>
<div className="xx-preview-plan-card">
<div className="xx-preview-plan-title"></div>
<div className="xx-preview-plan-title">稿</div>
<div className="xx-preview-plan-info">
<div className="xx-preview-plan-row">
<span className="xx-preview-plan-label"></span>
@@ -2792,7 +2792,7 @@ const GeneratePage: React.FC = () => {
fontWeight: 600,
}}
>
🎬
🎬 稿
</span>
)}
</div>
@@ -3,7 +3,7 @@
* 对接后端模板管理 API
* - 分页查询(page/page_size/category/keyword/duration_range
* - 模板详情(素材规则、字幕样式、BGM、比例等参数配置)
* - 复制模板 / 从模板生成剪辑计划
* - 复制模板 / 从模板生成
* - 卡片网格布局 + 类型筛选 + 搜索 + 收藏
*/
import React, { useState, useMemo, useCallback } from "react"
@@ -597,7 +597,7 @@ const TemplateLibrary: React.FC = () => {
<div className="xx-templates-header">
<div className="xx-templates-header-text">
<h2></h2>
<p></p>
<p></p>
</div>
<Button type="primary" onClick={() => navigate("/app/editing-planner")}>
+
-14
View File
@@ -156,20 +156,6 @@ export const router = createBrowserRouter([
Component: m.default,
})),
},
{
path: "edit-plans",
lazy: () =>
import("@/pages/edit-plans/EditPlans").then((m) => ({
Component: m.default,
})),
},
{
path: "edit-plans/:planId/clips",
lazy: () =>
import("@/pages/edit-plans/PlanClipsManager").then((m) => ({
Component: m.default,
})),
},
{
path: "voice-clone",
lazy: () =>
@@ -1,74 +0,0 @@
import React from "react"
import { describe, expect, it, vi } from "vitest"
import { render } from "@testing-library/react"
import { MemoryRouter } from "react-router-dom"
import EditPlans from "@/pages/edit-plans/EditPlans"
vi.mock("react-router-dom", async () => {
const actual = await vi.importActual("react-router-dom")
return {
...actual,
useNavigate: () => vi.fn(),
}
})
vi.mock("@tanstack/react-query", () => ({
useQuery: vi.fn().mockImplementation((opts: any) => {
const key = opts?.queryKey?.[0] || ""
if (key === "templates-list-simple") {
return { data: [], isLoading: false, isError: false, refetch: vi.fn() }
}
return {
data: { items: [], total: 0 },
isLoading: false,
isError: false,
refetch: vi.fn(),
}
}),
useMutation: () => ({
mutate: vi.fn(),
mutateAsync: vi.fn(),
isLoading: false,
}),
useQueryClient: () => ({
invalidateQueries: vi.fn(),
setQueryData: vi.fn(),
}),
}))
vi.mock("@ant-design/icons", () => ({
CheckCircleOutlined: () => <span>CheckCircleOutlined</span>,
ClockCircleOutlined: () => <span>ClockCircleOutlined</span>,
SyncOutlined: () => <span>SyncOutlined</span>,
CloseCircleOutlined: () => <span>CloseCircleOutlined</span>,
EditOutlined: () => <span>EditOutlined</span>,
DeleteOutlined: () => <span>DeleteOutlined</span>,
FileTextOutlined: () => <span>FileTextOutlined</span>,
ThunderboltOutlined: () => <span>ThunderboltOutlined</span>,
CopyOutlined: () => <span>CopyOutlined</span>,
UnorderedListOutlined: () => <span>UnorderedListOutlined</span>,
StopOutlined: () => <span>StopOutlined</span>,
}))
vi.mock("@/api/templates", () => ({
getTemplatesList: vi.fn().mockResolvedValue([]),
}))
vi.mock("@/api/editPlans", () => ({
getEditPlans: vi.fn().mockResolvedValue({ items: [], total: 0 }),
deleteEditPlan: vi.fn(),
generateEditPlan: vi.fn(),
cancelGeneration: vi.fn(),
copyEditPlan: vi.fn(),
}))
describe("EditPlans", () => {
it("should render without crashing", () => {
const { container } = render(
<MemoryRouter>
<EditPlans />
</MemoryRouter>,
)
expect(container).toBeTruthy()
})
})
@@ -1,60 +0,0 @@
import React from "react"
import { describe, expect, it, vi } from "vitest"
import { render } from "@testing-library/react"
import { MemoryRouter } from "react-router-dom"
import PlanClipsManager from "@/pages/edit-plans/PlanClipsManager"
vi.mock("react-router-dom", async () => {
const actual = await vi.importActual("react-router-dom")
return {
...actual,
useNavigate: () => vi.fn(),
useParams: () => ({ templateId: "test-123" }),
}
})
vi.mock("@tanstack/react-query", () => ({
useQuery: () => ({
data: { clips: [], name: "Test Plan" },
isLoading: false,
isError: false,
refetch: vi.fn(),
}),
useMutation: () => ({
mutate: vi.fn(),
mutateAsync: vi.fn(),
isLoading: false,
}),
useQueryClient: () => ({
invalidateQueries: vi.fn(),
setQueryData: vi.fn(),
}),
}))
vi.mock("@ant-design/icons", () => ({
ArrowLeftOutlined: () => <span>ArrowLeftOutlined</span>,
PlusOutlined: () => <span>PlusOutlined</span>,
DeleteOutlined: () => <span>DeleteOutlined</span>,
EditOutlined: () => <span>EditOutlined</span>,
UploadOutlined: () => <span>UploadOutlined</span>,
OrderedListOutlined: () => <span>OrderedListOutlined</span>,
SaveOutlined: () => <span>SaveOutlined</span>,
}))
vi.mock("@/api/editPlans", () => ({
getPlanClips: vi.fn().mockResolvedValue({ clips: [], name: "" }),
updatePlanClipsOrder: vi.fn(),
deletePlanClip: vi.fn(),
createPlanClip: vi.fn(),
}))
describe("PlanClipsManager", () => {
it("should render without crashing", () => {
const { container } = render(
<MemoryRouter>
<PlanClipsManager />
</MemoryRouter>,
)
expect(container).toBeTruthy()
})
})