fix(editor): 片段同步失败提示 + 删除片段二次确认 #440

Merged
xiaoxia merged 1 commits from fix/editor-clip-ux into develop 2026-07-17 11:33:09 +08:00
@@ -622,8 +622,17 @@ const EditingPlanner: React.FC = () => {
};
const handleClipRemove = (clipId: string) => {
setClips((prev) => prev.filter((c) => c.id !== clipId));
if (selectedClipId === clipId) setSelectedClipId(null);
Modal.confirm({
title: "删除片段",
content: "确定要删除这个片段吗?此操作可通过撤销恢复。",
okText: "删除",
okType: "danger",
cancelText: "取消",
onOk: () => {
setClips((prev) => prev.filter((c) => c.id !== clipId));
if (selectedClipId === clipId) setSelectedClipId(null);
},
});
};
const handleClipUpdate = useCallback(
@@ -1009,17 +1018,13 @@ const EditingPlanner: React.FC = () => {
const syncClipsToBackend = async (planId: string): Promise<void> => {
if (clips.length === 0) return;
// 1. 获取后端现有片段 ID
try {
const existing = await getEditPlanClips(planId, { limit: 500 });
if (existing.items.length > 0) {
await batchDeleteEditPlanClips(
planId,
existing.items.map((c) => c.id),
);
}
} catch (err) {
console.warn("[获取后端片段失败,跳过删除]", err);
// 1. 获取并删除后端现有片段
const existing = await getEditPlanClips(planId, { limit: 500 });
if (existing.items.length > 0) {
await batchDeleteEditPlanClips(
planId,
existing.items.map((c) => c.id),
);
}
// 2. 批量创建新片段(并发 3 个)
@@ -1118,6 +1123,7 @@ const EditingPlanner: React.FC = () => {
await syncClipsToBackend(planId);
} catch (syncErr) {
console.warn("[片段同步失败]", syncErr);
message.warning("片段同步失败,将使用模板默认配置生成");
// 同步失败不阻塞生成,后端有模板兜底
}