- lib/slots.ts 按位置注册(侧栏入口、作品页操作区 / 面板区、整理记录行操作、设置分区),默认直接显示; components/slots 挂载点:面板类直接渲染,动作类渲染成按钮 / 菜单项、对话框在菜单外渲染 - 作品页操作区与面板区、整理记录行菜单接入插槽;补字幕改由 features/subtitles.tsx 注册, 作品页按钮行为不变,整理记录行菜单新增「补字幕」(成功 / 部分成功的入库类整理) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { Captions } from "lucide-react";
|
|
import { SubtitleDialog } from "~/components/subtitles/subtitle-dialog.tsx";
|
|
import type { SlotRegistry } from "~/lib/slots.ts";
|
|
|
|
// 补字幕(功能模块样板,ADR-006):作品页操作区「补字幕」、整理记录行菜单「补字幕」,都打开同一个补字幕对话框。
|
|
|
|
export function registerSubtitles(registry: SlotRegistry): void {
|
|
registry.register("entity.actions", {
|
|
id: "subtitles.entity",
|
|
feature: "subtitles",
|
|
label: "补字幕",
|
|
icon: Captions,
|
|
visible: ({ entity }) => entity.status !== "merged",
|
|
Dialog: ({ entity, onClose }) => (
|
|
<SubtitleDialog entityId={entity.id} title={entity.title} open onOpenChange={(o) => !o && onClose()} />
|
|
),
|
|
});
|
|
registry.register("organize.record.actions", {
|
|
id: "subtitles.record",
|
|
feature: "subtitles",
|
|
label: "补字幕",
|
|
icon: Captions,
|
|
// 入库成功(或部分成功)且认到作品的整理才有视频可配字幕
|
|
visible: ({ record }) =>
|
|
!!record.media &&
|
|
(record.status === "succeeded" || record.status === "partial") &&
|
|
["copy", "move", "in_place"].includes(record.action),
|
|
Dialog: ({ record, onClose }) => (
|
|
<SubtitleDialog
|
|
entityId={record.media!.entityId}
|
|
title={record.media!.title}
|
|
open
|
|
onOpenChange={(o) => !o && onClose()}
|
|
/>
|
|
),
|
|
});
|
|
}
|