From 014b42fe47ff23ef35d19b48bb1b69c1ddeeb9a9 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 27 Jul 2026 00:40:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor(editing-planner):=20=E6=8B=86?= =?UTF-8?q?=E5=88=86=20types.ts=20=E4=B8=BA=E7=9B=AE=E5=BD=95=E7=BB=93?= =?UTF-8?q?=E6=9E=84=EF=BC=8C=E6=8C=89=E5=8A=9F=E8=83=BD=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E5=88=86=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原 types.ts 单文件 550 行,按功能拆分为 14 个模块文件: - transition: 转场特效 - speed: 片段调速 - tts: TTS 配音 - trim: 片段裁剪 - watermark: 水印配置 - intro-outro: 片头片尾 - pip: 混剪 PiP - filter: 滤镜调色 - chroma-key: 绿幕抠像 - sticker: 贴纸配置 - cover: 封面配置 - clip: 片段数据 - title: 标题设置 - subtitle: 字幕样式(原有) - clipProperties: ClipPropertiesPanel 专属类型(原有) index.ts 统一 re-export,保持 @/pages/editing-planner/types 导入路径向后兼容 --- apps/web/src/pages/editing-planner/types.ts | 550 ------------------ .../pages/editing-planner/types/chroma-key.ts | 50 ++ .../src/pages/editing-planner/types/clip.ts | 36 ++ .../editing-planner/types/clipProperties.ts | 2 +- .../src/pages/editing-planner/types/cover.ts | 32 + .../src/pages/editing-planner/types/filter.ts | 62 ++ .../src/pages/editing-planner/types/index.ts | 99 ++++ .../editing-planner/types/intro-outro.ts | 33 ++ .../src/pages/editing-planner/types/pip.ts | 95 +++ .../src/pages/editing-planner/types/speed.ts | 17 + .../pages/editing-planner/types/sticker.ts | 93 +++ .../src/pages/editing-planner/types/title.ts | 20 + .../pages/editing-planner/types/transition.ts | 35 ++ .../src/pages/editing-planner/types/trim.ts | 13 + .../src/pages/editing-planner/types/tts.ts | 35 ++ .../pages/editing-planner/types/watermark.ts | 45 ++ 16 files changed, 666 insertions(+), 551 deletions(-) delete mode 100644 apps/web/src/pages/editing-planner/types.ts create mode 100644 apps/web/src/pages/editing-planner/types/chroma-key.ts create mode 100644 apps/web/src/pages/editing-planner/types/clip.ts mode change 100755 => 100644 apps/web/src/pages/editing-planner/types/clipProperties.ts create mode 100644 apps/web/src/pages/editing-planner/types/cover.ts create mode 100644 apps/web/src/pages/editing-planner/types/filter.ts create mode 100644 apps/web/src/pages/editing-planner/types/index.ts create mode 100644 apps/web/src/pages/editing-planner/types/intro-outro.ts create mode 100644 apps/web/src/pages/editing-planner/types/pip.ts create mode 100644 apps/web/src/pages/editing-planner/types/speed.ts create mode 100644 apps/web/src/pages/editing-planner/types/sticker.ts create mode 100644 apps/web/src/pages/editing-planner/types/title.ts create mode 100644 apps/web/src/pages/editing-planner/types/transition.ts create mode 100644 apps/web/src/pages/editing-planner/types/trim.ts create mode 100644 apps/web/src/pages/editing-planner/types/tts.ts create mode 100644 apps/web/src/pages/editing-planner/types/watermark.ts diff --git a/apps/web/src/pages/editing-planner/types.ts b/apps/web/src/pages/editing-planner/types.ts deleted file mode 100644 index 4be6060a2..000000000 --- a/apps/web/src/pages/editing-planner/types.ts +++ /dev/null @@ -1,550 +0,0 @@ -/** - * 片段(Clip)统一类型定义 - * 片段 = 时间规划 + 类型标记,不绑定任何素材 - */ - -export type ClipType = "voice" | "pip" - -/* ──────── 转场特效 ──────── */ - -/** 14 种转场类型 */ -export type TransitionType = - | "none" - | "cut" - | "fade" - | "dissolve" - | "zoom" - | "slide_left" - | "slide_right" - | "slide_up" - | "slide_down" - | "wipe_left" - | "wipe_right" - | "wipe_up" - | "wipe_down" - | "circlecrop" - | "rectcrop" - -/** 片段间转场配置 */ -export interface TransitionConfig { - /** 转场类型 */ - type: TransitionType - /** 转场时长(秒),0.3 ~ 2.0 */ - duration: number -} - -/** 默认转场配置 */ -export const DEFAULT_TRANSITION: TransitionConfig = { - type: "none", - duration: 0.5, -} - -/* ──────── 片段调速 ──────── */ - -/** 片段调速配置 */ -export interface SpeedConfig { - /** 播放速度,0.25 ~ 4.0 */ - rate: number - /** 音调修正(变速不变调) */ - pitchCorrection: boolean -} - -/** 默认调速配置 */ -export const DEFAULT_SPEED: SpeedConfig = { - rate: 1.0, - pitchCorrection: true, -} - -/* ──────── TTS 配音 ──────── */ - -/** 配音模式 */ -export type TtsMode = "none" | "upload" | "tts" - -/** TTS 配音配置 */ -export interface TtsConfig { - /** 配音模式 */ - mode: TtsMode - /** TTS 合成文本 */ - text: string - /** 音色 ID */ - voice_id: string - /** 语速 0.5 ~ 2.0 */ - speed: number - /** 语调(半音)-12 ~ +12 */ - pitch: number - /** 音量 0 ~ 100 */ - volume: number - /** 字幕联动 */ - subtitle_sync: boolean -} - -/** 默认 TTS 配置 */ -export const DEFAULT_TTS_CONFIG: TtsConfig = { - mode: "none", - text: "", - voice_id: "", - speed: 1.0, - pitch: 0, - volume: 100, - subtitle_sync: true, -} - -/* ──────── 裁剪配置 ──────── */ - -/** 片段裁剪配置 — 定义素材的入点/出点 */ -export interface TrimConfig { - /** 入点(秒),素材原始时间轴上的起始位置 */ - start_time: number - /** 出点(秒),素材原始时间轴上的结束位置 */ - end_time: number - /** 素材原始总时长(秒),用于"恢复原始长度" */ - original_duration?: number -} - -/* ──────── 水印配置 ──────── */ - -/** 水印类型 */ -export type WatermarkType = "none" | "image" | "text" | "scroll" - -/** 水印位置 */ -export type WatermarkPosition = "top_left" | "top_right" | "bottom_left" | "bottom_right" | "center" - -/** 滚动水印方向 */ -export type ScrollDirection = "horizontal" | "vertical" | "diagonal" - -/** 水印配置 */ -export interface WatermarkConfig { - /** 水印类型 */ - type: WatermarkType - /** 图片水印 URL */ - image_url?: string - /** 水印宽度(像素或百分比 0~1) */ - width?: number - /** 水印高度(像素或百分比 0~1) */ - height?: number - /** 水印位置 */ - position: WatermarkPosition - /** 水印不透明度 0~1 */ - opacity: number - /** 文字水印内容 */ - text?: string - /** 文字水印字号 */ - font_size?: number - /** 文字水印颜色 */ - color?: string - /** 滚动水印方向 */ - scroll_direction?: ScrollDirection - /** 滚动水印速度(像素/秒) */ - scroll_speed?: number -} - -/** 默认水印配置 */ -export const DEFAULT_WATERMARK: WatermarkConfig = { - type: "none", - position: "bottom_right", - opacity: 0.7, -} - -/* ──────── 片头片尾配置 ──────── */ - -/** 片头片尾素材类型 */ -export type IntroOutroKind = "none" | "video" | "image" - -/** 片头/片尾单项配置 */ -export interface IntroOutroItem { - /** 素材类型 */ - kind: IntroOutroKind - /** 素材 URL */ - url?: string - /** 显示时长(秒) */ - duration: number - /** 过渡动画 */ - transition?: TransitionType - /** 过渡时长(秒) */ - transition_duration?: number -} - -/** 片头片尾完整配置 */ -export interface IntroOutroConfig { - intro: IntroOutroItem - outro: IntroOutroItem -} - -/** 默认片头片尾配置 */ -export const DEFAULT_INTRO_OUTRO: IntroOutroConfig = { - intro: { kind: "none", duration: 3 }, - outro: { kind: "none", duration: 3 }, -} - -/* ──────── 混剪配置 ──────── */ - -/** 九宫格位置 */ -export type PipGridPosition = - | "top_left" - | "top_center" - | "top_right" - | "center_left" - | "center" - | "center_right" - | "bottom_left" - | "bottom_center" - | "bottom_right" - -/** 入场动画类型 */ -export type PipAnimType = "none" | "fade_in" | "slide_in" - -/** 入场方向 */ -export type PipSlideDirection = "left" | "right" | "up" | "down" - -/** 混剪图层 */ -export interface PipLayer { - id: string - /** 图层名称(用户可编辑) */ - name: string - /** 素材类型 */ - material_type: "image" | "video" - /** 素材 URL */ - material_url: string - /** 素材缩略图 */ - thumbnail_url?: string - /** 九宫格快捷位置 */ - grid_position: PipGridPosition - /** 精确 X 坐标(百分比 0~100) */ - x: number - /** 精确 Y 坐标(百分比 0~100) */ - y: number - /** 宽度(百分比 0~100,相对主画面) */ - width: number - /** 高度(百分比 0~100,相对主画面) */ - height: number - /** 锁定宽高比 */ - aspect_lock: boolean - /** 圆角(百分比 0~50) */ - border_radius: number - /** 不透明度(0~100) */ - opacity: number - /** 开始时间(秒) */ - start_time: number - /** 持续时长(秒) */ - duration: number - /** 入场动画 */ - animation: PipAnimType - /** 入场方向 */ - slide_direction: PipSlideDirection - /** 图层顺序(z-index) */ - z_index: number -} - -/** 混剪配置 */ -export interface PipConfig { - /** 是否启用混剪 */ - enabled: boolean - /** 图层列表 */ - layers: PipLayer[] -} - -/** 默认 PiP 图层 */ -export const DEFAULT_PIP_LAYER: PipLayer = { - id: "", - name: "图层", - material_type: "image", - material_url: "", - grid_position: "top_right", - x: 70, - y: 5, - width: 25, - height: 25, - aspect_lock: true, - border_radius: 0, - opacity: 100, - start_time: 0, - duration: 5, - animation: "none", - slide_direction: "right", - z_index: 1, -} - -/** 默认 PiP 配置 */ -export const DEFAULT_PIP_CONFIG: PipConfig = { - enabled: false, - layers: [], -} - -/* ──────── 滤镜调色 ──────── */ - -/** 预设滤镜 */ -export type FilterPreset = - | "none" - | "original" - | "fresh" - | "warm" - | "cool" - | "vintage" - | "cinema" - | "bw" - | "sunshine" - | "film" - -/** 预设滤镜标签 */ -export const FILTER_PRESET_LABELS: Record = { - none: "无", - original: "原片", - fresh: "清新", - warm: "暖调", - cool: "冷色", - vintage: "复古", - cinema: "电影", - bw: "黑白", - sunshine: "暖阳", - film: "胶片", -} - -/** 滤镜调色配置 */ -export interface FilterConfig { - /** 是否启用滤镜 */ - enabled: boolean - /** 预设滤镜 */ - preset: FilterPreset - /** 亮度(-100 ~ 100) */ - brightness: number - /** 对比度(-100 ~ 100) */ - contrast: number - /** 饱和度(-100 ~ 100) */ - saturation: number - /** 色温(-100 ~ 100,负值偏蓝,正值偏黄) */ - temperature: number - /** 色调(-100 ~ 100,负值偏绿,正值偏品红) */ - tint: number - /** 锐度(0 ~ 100) */ - sharpness: number -} - -/** 默认滤镜调色配置 */ -export const DEFAULT_FILTER_CONFIG: FilterConfig = { - enabled: false, - preset: "none", - brightness: 0, - contrast: 0, - saturation: 0, - temperature: 0, - tint: 0, - sharpness: 0, -} - -/* ──────── 绿幕抠像 ──────── */ - -/** 绿幕抠像颜色预设 */ -export type ChromaKeyColorPreset = "green" | "blue" | "red" | "pure_green" | "soft_green" - -/** 颜色预设标签 */ -export const CHROMA_KEY_PRESET_LABELS: Record = { - green: "绿", - blue: "蓝", - red: "红", - pure_green: "精绿", - soft_green: "柔绿", -} - -/** 颜色预设对应的默认色值 */ -export const CHROMA_KEY_PRESET_COLORS: Record = { - green: "#00FF00", - blue: "#0000FF", - red: "#FF0000", - pure_green: "#00C800", - soft_green: "#40E040", -} - -/** 绿幕抠像配置 */ -export interface ChromaKeyConfig { - /** 是否启用绿幕抠像 */ - enabled: boolean - /** 颜色预设 */ - color_preset: ChromaKeyColorPreset - /** 抠像目标颜色(HEX) */ - color: string - /** 相似度(0 ~ 100,越大容忍的色差范围越广) */ - similarity: number - /** 边缘平滑(0 ~ 100,越大边缘越柔和) */ - blend: number - /** 溢色抑制(0 ~ 100,去除边缘颜色溢出) */ - spill: number -} - -/** 默认绿幕抠像配置 */ -export const DEFAULT_CHROMA_KEY_CONFIG: ChromaKeyConfig = { - enabled: false, - color_preset: "green", - color: "#00FF00", - similarity: 30, - blend: 10, - spill: 20, -} - -/* ──────── 贴纸配置 ──────── */ - -/** 贴纸类型 */ -export type StickerType = "emoji" | "image" | "text" - -/** 文字花字预设 */ -export type TextStickerPreset = - | "normal" // 普通 - | "highlight" // 高亮 - | "bubble" // 气泡 - | "neon" // 霓虹 - | "shadow" // 投影 - | "outline" // 描边 - | "gradient" // 渐变 - | "handwrite" // 手写 - -/** 贴纸项 */ -export interface StickerItem { - id: string - /** 贴纸类型 */ - type: StickerType - /** 内容(emoji 字符 / 图片 URL / 文字内容) */ - content: string - /** X 坐标(百分比 0~100) */ - x: number - /** Y 坐标(百分比 0~100) */ - y: number - /** 宽度(百分比 0~100) */ - width: number - /** 高度(百分比 0~100) */ - height: number - /** 旋转角度(度 -180~180) */ - rotation: number - /** 不透明度(0~100) */ - opacity: number - /** 开始时间(秒) */ - start_time: number - /** 持续时长(秒,0 表示全程显示) */ - duration: number - /** 图层顺序 */ - z_index: number - /** 文字花字预设(仅 type=text 时有效) */ - text_preset: TextStickerPreset - /** 文字颜色(仅 type=text 时有效) */ - text_color: string - /** 文字大小(px,仅 type=text 时有效) */ - font_size: number -} - -/** 贴纸配置 */ -export interface StickerConfig { - enabled: boolean - items: StickerItem[] -} - -/** 默认贴纸项 */ -export const DEFAULT_STICKER_ITEM: StickerItem = { - id: "", - type: "emoji", - content: "😀", - x: 50, - y: 50, - width: 15, - height: 15, - rotation: 0, - opacity: 100, - start_time: 0, - duration: 0, - z_index: 1, - text_preset: "normal", - text_color: "#FFFFFF", - font_size: 24, -} - -/** 默认贴纸配置 */ -export const DEFAULT_STICKER_CONFIG: StickerConfig = { - enabled: false, - items: [], -} - -/** 文字花字预设标签 */ -export const TEXT_STICKER_PRESET_LABELS: Record = { - normal: "普通", - highlight: "高亮", - bubble: "气泡", - neon: "霓虹", - shadow: "投影", - outline: "描边", - gradient: "渐变", - handwrite: "手写", -} - -/* ──────── 封面配置 ──────── */ - -/** 封面来源模式 */ -export type CoverMode = "auto" | "frame" | "upload" - -/** 封面配置 */ -export interface CoverConfig { - /** 是否启用自定义封面 */ - enabled: boolean - /** 封面来源模式 */ - mode: CoverMode - /** 抽帧时间点(秒,mode=frame 时使用) */ - frame_time: number - /** 上传的封面 URL(mode=upload 时使用) */ - upload_url: string - /** AI 智能推荐的抽帧时间(由后端分析得出) */ - ai_suggested_time: number | null - /** 封面缩略图 URL */ - thumbnail_url: string -} - -/** 默认封面配置 */ -export const DEFAULT_COVER_CONFIG: CoverConfig = { - enabled: false, - mode: "auto", - frame_time: 0, - upload_url: "", - ai_suggested_time: null, - thumbnail_url: "", -} - -/* ──────── 片段数据 ──────── */ - -export interface ClipData { - id: string - type: ClipType // 片段类型:voice(口播)或 pip(混剪) - duration: number // 时长(秒) - startOffset: number // 仅 voice 类型:在口播素材中的起始时间(秒) - /** 素材库素材 ID(main/pip 类型片段使用) */ - media_asset_id?: string - // 保留兼容字段(后端序列化需要) - template_segment_id?: string - script_text?: string - order?: number - /** 配音素材 ID(voice 类型片段使用) */ - voice_asset_id?: string - /** 配音素材文件 URL(voice 类型片段使用) */ - voice_file_url?: string - /** 与前一片段之间的转场效果 */ - transition?: TransitionConfig - /** 播放速度配置 */ - speed?: SpeedConfig - /** TTS 配音配置 */ - tts_config?: TtsConfig - /** 裁剪配置 — 定义素材入点/出点 */ - trim_config?: TrimConfig -} - -/* ──────── 标题设置 ──────── */ - -/** - * 标题设置 — 对齐后端 title_config 字段 - * 前端 UI 使用 camelCase,发送到后端时映射为 snake_case - */ -export interface TitleSettings { - aiAutoSelect: boolean - title: string - position: string - font: string - size: number - bold: boolean - italic: boolean - stroke: boolean - shadow: boolean - color: string -} diff --git a/apps/web/src/pages/editing-planner/types/chroma-key.ts b/apps/web/src/pages/editing-planner/types/chroma-key.ts new file mode 100644 index 000000000..980401567 --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/chroma-key.ts @@ -0,0 +1,50 @@ +/** + * 绿幕抠像类型 + */ + +/** 绿幕抠像颜色预设 */ +export type ChromaKeyColorPreset = "green" | "blue" | "red" | "pure_green" | "soft_green" + +/** 颜色预设标签 */ +export const CHROMA_KEY_PRESET_LABELS: Record = { + green: "绿", + blue: "蓝", + red: "红", + pure_green: "精绿", + soft_green: "柔绿", +} + +/** 颜色预设对应的默认色值 */ +export const CHROMA_KEY_PRESET_COLORS: Record = { + green: "#00FF00", + blue: "#0000FF", + red: "#FF0000", + pure_green: "#00C800", + soft_green: "#40E040", +} + +/** 绿幕抠像配置 */ +export interface ChromaKeyConfig { + /** 是否启用绿幕抠像 */ + enabled: boolean + /** 颜色预设 */ + color_preset: ChromaKeyColorPreset + /** 抠像目标颜色(HEX) */ + color: string + /** 相似度(0 ~ 100,越大容忍的色差范围越广) */ + similarity: number + /** 边缘平滑(0 ~ 100,越大边缘越柔和) */ + blend: number + /** 溢色抑制(0 ~ 100,去除边缘颜色溢出) */ + spill: number +} + +/** 默认绿幕抠像配置 */ +export const DEFAULT_CHROMA_KEY_CONFIG: ChromaKeyConfig = { + enabled: false, + color_preset: "green", + color: "#00FF00", + similarity: 30, + blend: 10, + spill: 20, +} diff --git a/apps/web/src/pages/editing-planner/types/clip.ts b/apps/web/src/pages/editing-planner/types/clip.ts new file mode 100644 index 000000000..8602b8318 --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/clip.ts @@ -0,0 +1,36 @@ +/** + * 片段数据类型 + */ +import type { TransitionConfig } from "./transition" +import type { SpeedConfig } from "./speed" +import type { TtsConfig } from "./tts" +import type { TrimConfig } from "./trim" + +/** 片段类型 */ +export type ClipType = "voice" | "pip" + +/** 片段数据 — 时间规划 + 类型标记,不绑定任何素材 */ +export interface ClipData { + id: string + type: ClipType // 片段类型:voice(口播)或 pip(混剪) + duration: number // 时长(秒) + startOffset: number // 仅 voice 类型:在口播素材中的起始时间(秒) + /** 素材库素材 ID(main/pip 类型片段使用) */ + media_asset_id?: string + // 保留兼容字段(后端序列化需要) + template_segment_id?: string + script_text?: string + order?: number + /** 配音素材 ID(voice 类型片段使用) */ + voice_asset_id?: string + /** 配音素材文件 URL(voice 类型片段使用) */ + voice_file_url?: string + /** 与前一片段之间的转场效果 */ + transition?: TransitionConfig + /** 播放速度配置 */ + speed?: SpeedConfig + /** TTS 配音配置 */ + tts_config?: TtsConfig + /** 裁剪配置 — 定义素材入点/出点 */ + trim_config?: TrimConfig +} diff --git a/apps/web/src/pages/editing-planner/types/clipProperties.ts b/apps/web/src/pages/editing-planner/types/clipProperties.ts old mode 100755 new mode 100644 index 26125a186..3f37015f2 --- a/apps/web/src/pages/editing-planner/types/clipProperties.ts +++ b/apps/web/src/pages/editing-planner/types/clipProperties.ts @@ -1,7 +1,7 @@ /** * ClipPropertiesPanel 相关类型定义 */ -import type { ClipData } from "@/pages/editing-planner/types" +import type { ClipData } from "./clip" import type { TemplateMode } from "@/api/editing-planner" import type { AssetItem } from "@/api/assets" diff --git a/apps/web/src/pages/editing-planner/types/cover.ts b/apps/web/src/pages/editing-planner/types/cover.ts new file mode 100644 index 000000000..c3a02e887 --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/cover.ts @@ -0,0 +1,32 @@ +/** + * 封面配置类型 + */ + +/** 封面来源模式 */ +export type CoverMode = "auto" | "frame" | "upload" + +/** 封面配置 */ +export interface CoverConfig { + /** 是否启用自定义封面 */ + enabled: boolean + /** 封面来源模式 */ + mode: CoverMode + /** 抽帧时间点(秒,mode=frame 时使用) */ + frame_time: number + /** 上传的封面 URL(mode=upload 时使用) */ + upload_url: string + /** AI 智能推荐的抽帧时间(由后端分析得出) */ + ai_suggested_time: number | null + /** 封面缩略图 URL */ + thumbnail_url: string +} + +/** 默认封面配置 */ +export const DEFAULT_COVER_CONFIG: CoverConfig = { + enabled: false, + mode: "auto", + frame_time: 0, + upload_url: "", + ai_suggested_time: null, + thumbnail_url: "", +} diff --git a/apps/web/src/pages/editing-planner/types/filter.ts b/apps/web/src/pages/editing-planner/types/filter.ts new file mode 100644 index 000000000..03f0201cc --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/filter.ts @@ -0,0 +1,62 @@ +/** + * 滤镜调色类型 + */ + +/** 预设滤镜 */ +export type FilterPreset = + | "none" + | "original" + | "fresh" + | "warm" + | "cool" + | "vintage" + | "cinema" + | "bw" + | "sunshine" + | "film" + +/** 预设滤镜标签 */ +export const FILTER_PRESET_LABELS: Record = { + none: "无", + original: "原片", + fresh: "清新", + warm: "暖调", + cool: "冷色", + vintage: "复古", + cinema: "电影", + bw: "黑白", + sunshine: "暖阳", + film: "胶片", +} + +/** 滤镜调色配置 */ +export interface FilterConfig { + /** 是否启用滤镜 */ + enabled: boolean + /** 预设滤镜 */ + preset: FilterPreset + /** 亮度(-100 ~ 100) */ + brightness: number + /** 对比度(-100 ~ 100) */ + contrast: number + /** 饱和度(-100 ~ 100) */ + saturation: number + /** 色温(-100 ~ 100,负值偏蓝,正值偏黄) */ + temperature: number + /** 色调(-100 ~ 100,负值偏绿,正值偏品红) */ + tint: number + /** 锐度(0 ~ 100) */ + sharpness: number +} + +/** 默认滤镜调色配置 */ +export const DEFAULT_FILTER_CONFIG: FilterConfig = { + enabled: false, + preset: "none", + brightness: 0, + contrast: 0, + saturation: 0, + temperature: 0, + tint: 0, + sharpness: 0, +} diff --git a/apps/web/src/pages/editing-planner/types/index.ts b/apps/web/src/pages/editing-planner/types/index.ts new file mode 100644 index 000000000..a7caa72ab --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/index.ts @@ -0,0 +1,99 @@ +/** + * EditingPlanner 类型定义入口 + * 按功能模块拆分,统一从这里导出 + */ + +/* 转场 */ +export { + type TransitionType, + type TransitionConfig, + DEFAULT_TRANSITION, +} from "./transition" + +/* 调速 */ +export { type SpeedConfig, DEFAULT_SPEED } from "./speed" + +/* TTS 配音 */ +export { + type TtsMode, + type TtsConfig, + DEFAULT_TTS_CONFIG, +} from "./tts" + +/* 裁剪 */ +export { type TrimConfig } from "./trim" + +/* 水印 */ +export { + type WatermarkType, + type WatermarkPosition, + type ScrollDirection, + type WatermarkConfig, + DEFAULT_WATERMARK, +} from "./watermark" + +/* 片头片尾 */ +export { + type IntroOutroKind, + type IntroOutroItem, + type IntroOutroConfig, + DEFAULT_INTRO_OUTRO, +} from "./intro-outro" + +/* 混剪 PiP */ +export { + type PipGridPosition, + type PipAnimType, + type PipSlideDirection, + type PipLayer, + type PipConfig, + DEFAULT_PIP_LAYER, + DEFAULT_PIP_CONFIG, +} from "./pip" + +/* 滤镜调色 */ +export { + type FilterPreset, + FILTER_PRESET_LABELS, + type FilterConfig, + DEFAULT_FILTER_CONFIG, +} from "./filter" + +/* 绿幕抠像 */ +export { + type ChromaKeyColorPreset, + CHROMA_KEY_PRESET_LABELS, + CHROMA_KEY_PRESET_COLORS, + type ChromaKeyConfig, + DEFAULT_CHROMA_KEY_CONFIG, +} from "./chroma-key" + +/* 贴纸 */ +export { + type StickerType, + type TextStickerPreset, + type StickerItem, + type StickerConfig, + DEFAULT_STICKER_ITEM, + DEFAULT_STICKER_CONFIG, + TEXT_STICKER_PRESET_LABELS, +} from "./sticker" + +/* 封面 */ +export { + type CoverMode, + type CoverConfig, + DEFAULT_COVER_CONFIG, +} from "./cover" + +/* 片段数据 */ +export { type ClipType, type ClipData } from "./clip" + +/* 标题设置 */ +export { type TitleSettings } from "./title" + +/* 字幕样式 */ +export { + type SubtitleStyleConfig, + DEFAULT_SUBTITLE_STYLE, +} from "./subtitle" diff --git a/apps/web/src/pages/editing-planner/types/intro-outro.ts b/apps/web/src/pages/editing-planner/types/intro-outro.ts new file mode 100644 index 000000000..f0c53f934 --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/intro-outro.ts @@ -0,0 +1,33 @@ +/** + * 片头片尾配置类型 + */ +import type { TransitionType } from "./transition" + +/** 片头片尾素材类型 */ +export type IntroOutroKind = "none" | "video" | "image" + +/** 片头/片尾单项配置 */ +export interface IntroOutroItem { + /** 素材类型 */ + kind: IntroOutroKind + /** 素材 URL */ + url?: string + /** 显示时长(秒) */ + duration: number + /** 过渡动画 */ + transition?: TransitionType + /** 过渡时长(秒) */ + transition_duration?: number +} + +/** 片头片尾完整配置 */ +export interface IntroOutroConfig { + intro: IntroOutroItem + outro: IntroOutroItem +} + +/** 默认片头片尾配置 */ +export const DEFAULT_INTRO_OUTRO: IntroOutroConfig = { + intro: { kind: "none", duration: 3 }, + outro: { kind: "none", duration: 3 }, +} diff --git a/apps/web/src/pages/editing-planner/types/pip.ts b/apps/web/src/pages/editing-planner/types/pip.ts new file mode 100644 index 000000000..27c012ac9 --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/pip.ts @@ -0,0 +1,95 @@ +/** + * 混剪(PiP)配置类型 + */ + +/** 九宫格位置 */ +export type PipGridPosition = + | "top_left" + | "top_center" + | "top_right" + | "center_left" + | "center" + | "center_right" + | "bottom_left" + | "bottom_center" + | "bottom_right" + +/** 入场动画类型 */ +export type PipAnimType = "none" | "fade_in" | "slide_in" + +/** 入场方向 */ +export type PipSlideDirection = "left" | "right" | "up" | "down" + +/** 混剪图层 */ +export interface PipLayer { + id: string + /** 图层名称(用户可编辑) */ + name: string + /** 素材类型 */ + material_type: "image" | "video" + /** 素材 URL */ + material_url: string + /** 素材缩略图 */ + thumbnail_url?: string + /** 九宫格快捷位置 */ + grid_position: PipGridPosition + /** 精确 X 坐标(百分比 0~100) */ + x: number + /** 精确 Y 坐标(百分比 0~100) */ + y: number + /** 宽度(百分比 0~100,相对主画面) */ + width: number + /** 高度(百分比 0~100,相对主画面) */ + height: number + /** 锁定宽高比 */ + aspect_lock: boolean + /** 圆角(百分比 0~50) */ + border_radius: number + /** 不透明度(0~100) */ + opacity: number + /** 开始时间(秒) */ + start_time: number + /** 持续时长(秒) */ + duration: number + /** 入场动画 */ + animation: PipAnimType + /** 入场方向 */ + slide_direction: PipSlideDirection + /** 图层顺序(z-index) */ + z_index: number +} + +/** 混剪配置 */ +export interface PipConfig { + /** 是否启用混剪 */ + enabled: boolean + /** 图层列表 */ + layers: PipLayer[] +} + +/** 默认 PiP 图层 */ +export const DEFAULT_PIP_LAYER: PipLayer = { + id: "", + name: "图层", + material_type: "image", + material_url: "", + grid_position: "top_right", + x: 70, + y: 5, + width: 25, + height: 25, + aspect_lock: true, + border_radius: 0, + opacity: 100, + start_time: 0, + duration: 5, + animation: "none", + slide_direction: "right", + z_index: 1, +} + +/** 默认 PiP 配置 */ +export const DEFAULT_PIP_CONFIG: PipConfig = { + enabled: false, + layers: [], +} diff --git a/apps/web/src/pages/editing-planner/types/speed.ts b/apps/web/src/pages/editing-planner/types/speed.ts new file mode 100644 index 000000000..227b54de1 --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/speed.ts @@ -0,0 +1,17 @@ +/** + * 片段调速类型 + */ + +/** 片段调速配置 */ +export interface SpeedConfig { + /** 播放速度,0.25 ~ 4.0 */ + rate: number + /** 音调修正(变速不变调) */ + pitchCorrection: boolean +} + +/** 默认调速配置 */ +export const DEFAULT_SPEED: SpeedConfig = { + rate: 1.0, + pitchCorrection: true, +} diff --git a/apps/web/src/pages/editing-planner/types/sticker.ts b/apps/web/src/pages/editing-planner/types/sticker.ts new file mode 100644 index 000000000..95bed824e --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/sticker.ts @@ -0,0 +1,93 @@ +/** + * 贴纸配置类型 + */ + +/** 贴纸类型 */ +export type StickerType = "emoji" | "image" | "text" + +/** 文字花字预设 */ +export type TextStickerPreset = + | "normal" // 普通 + | "highlight" // 高亮 + | "bubble" // 气泡 + | "neon" // 霓虹 + | "shadow" // 投影 + | "outline" // 描边 + | "gradient" // 渐变 + | "handwrite" // 手写 + +/** 贴纸项 */ +export interface StickerItem { + id: string + /** 贴纸类型 */ + type: StickerType + /** 内容(emoji 字符 / 图片 URL / 文字内容) */ + content: string + /** X 坐标(百分比 0~100) */ + x: number + /** Y 坐标(百分比 0~100) */ + y: number + /** 宽度(百分比 0~100) */ + width: number + /** 高度(百分比 0~100) */ + height: number + /** 旋转角度(度 -180~180) */ + rotation: number + /** 不透明度(0~100) */ + opacity: number + /** 开始时间(秒) */ + start_time: number + /** 持续时长(秒,0 表示全程显示) */ + duration: number + /** 图层顺序 */ + z_index: number + /** 文字花字预设(仅 type=text 时有效) */ + text_preset: TextStickerPreset + /** 文字颜色(仅 type=text 时有效) */ + text_color: string + /** 文字大小(px,仅 type=text 时有效) */ + font_size: number +} + +/** 贴纸配置 */ +export interface StickerConfig { + enabled: boolean + items: StickerItem[] +} + +/** 默认贴纸项 */ +export const DEFAULT_STICKER_ITEM: StickerItem = { + id: "", + type: "emoji", + content: "😀", + x: 50, + y: 50, + width: 15, + height: 15, + rotation: 0, + opacity: 100, + start_time: 0, + duration: 0, + z_index: 1, + text_preset: "normal", + text_color: "#FFFFFF", + font_size: 24, +} + +/** 默认贴纸配置 */ +export const DEFAULT_STICKER_CONFIG: StickerConfig = { + enabled: false, + items: [], +} + +/** 文字花字预设标签 */ +export const TEXT_STICKER_PRESET_LABELS: Record = { + normal: "普通", + highlight: "高亮", + bubble: "气泡", + neon: "霓虹", + shadow: "投影", + outline: "描边", + gradient: "渐变", + handwrite: "手写", +} diff --git a/apps/web/src/pages/editing-planner/types/title.ts b/apps/web/src/pages/editing-planner/types/title.ts new file mode 100644 index 000000000..e6c8df4a3 --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/title.ts @@ -0,0 +1,20 @@ +/** + * 标题设置类型 + */ + +/** + * 标题设置 — 对齐后端 title_config 字段 + * 前端 UI 使用 camelCase,发送到后端时映射为 snake_case + */ +export interface TitleSettings { + aiAutoSelect: boolean + title: string + position: string + font: string + size: number + bold: boolean + italic: boolean + stroke: boolean + shadow: boolean + color: string +} diff --git a/apps/web/src/pages/editing-planner/types/transition.ts b/apps/web/src/pages/editing-planner/types/transition.ts new file mode 100644 index 000000000..ad04cb554 --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/transition.ts @@ -0,0 +1,35 @@ +/** + * 转场特效类型 + */ + +/** 14 种转场类型 */ +export type TransitionType = + | "none" + | "cut" + | "fade" + | "dissolve" + | "zoom" + | "slide_left" + | "slide_right" + | "slide_up" + | "slide_down" + | "wipe_left" + | "wipe_right" + | "wipe_up" + | "wipe_down" + | "circlecrop" + | "rectcrop" + +/** 片段间转场配置 */ +export interface TransitionConfig { + /** 转场类型 */ + type: TransitionType + /** 转场时长(秒),0.3 ~ 2.0 */ + duration: number +} + +/** 默认转场配置 */ +export const DEFAULT_TRANSITION: TransitionConfig = { + type: "none", + duration: 0.5, +} diff --git a/apps/web/src/pages/editing-planner/types/trim.ts b/apps/web/src/pages/editing-planner/types/trim.ts new file mode 100644 index 000000000..f9bfa71bf --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/trim.ts @@ -0,0 +1,13 @@ +/** + * 片段裁剪类型 + */ + +/** 片段裁剪配置 — 定义素材的入点/出点 */ +export interface TrimConfig { + /** 入点(秒),素材原始时间轴上的起始位置 */ + start_time: number + /** 出点(秒),素材原始时间轴上的结束位置 */ + end_time: number + /** 素材原始总时长(秒),用于"恢复原始长度" */ + original_duration?: number +} diff --git a/apps/web/src/pages/editing-planner/types/tts.ts b/apps/web/src/pages/editing-planner/types/tts.ts new file mode 100644 index 000000000..32436e42e --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/tts.ts @@ -0,0 +1,35 @@ +/** + * TTS 配音类型 + */ + +/** 配音模式 */ +export type TtsMode = "none" | "upload" | "tts" + +/** TTS 配音配置 */ +export interface TtsConfig { + /** 配音模式 */ + mode: TtsMode + /** TTS 合成文本 */ + text: string + /** 音色 ID */ + voice_id: string + /** 语速 0.5 ~ 2.0 */ + speed: number + /** 语调(半音)-12 ~ +12 */ + pitch: number + /** 音量 0 ~ 100 */ + volume: number + /** 字幕联动 */ + subtitle_sync: boolean +} + +/** 默认 TTS 配置 */ +export const DEFAULT_TTS_CONFIG: TtsConfig = { + mode: "none", + text: "", + voice_id: "", + speed: 1.0, + pitch: 0, + volume: 100, + subtitle_sync: true, +} diff --git a/apps/web/src/pages/editing-planner/types/watermark.ts b/apps/web/src/pages/editing-planner/types/watermark.ts new file mode 100644 index 000000000..f8c3e288b --- /dev/null +++ b/apps/web/src/pages/editing-planner/types/watermark.ts @@ -0,0 +1,45 @@ +/** + * 水印配置类型 + */ + +/** 水印类型 */ +export type WatermarkType = "none" | "image" | "text" | "scroll" + +/** 水印位置 */ +export type WatermarkPosition = "top_left" | "top_right" | "bottom_left" | "bottom_right" | "center" + +/** 滚动水印方向 */ +export type ScrollDirection = "horizontal" | "vertical" | "diagonal" + +/** 水印配置 */ +export interface WatermarkConfig { + /** 水印类型 */ + type: WatermarkType + /** 图片水印 URL */ + image_url?: string + /** 水印宽度(像素或百分比 0~1) */ + width?: number + /** 水印高度(像素或百分比 0~1) */ + height?: number + /** 水印位置 */ + position: WatermarkPosition + /** 水印不透明度 0~1 */ + opacity: number + /** 文字水印内容 */ + text?: string + /** 文字水印字号 */ + font_size?: number + /** 文字水印颜色 */ + color?: string + /** 滚动水印方向 */ + scroll_direction?: ScrollDirection + /** 滚动水印速度(像素/秒) */ + scroll_speed?: number +} + +/** 默认水印配置 */ +export const DEFAULT_WATERMARK: WatermarkConfig = { + type: "none", + position: "bottom_right", + opacity: 0.7, +} -- 2.54.0 From 539911b73dd4a8218aa227d7c0782f72288e59dd Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 27 Jul 2026 08:39:48 +0800 Subject: [PATCH 2/2] style: prettier format fix --- .../src/pages/editing-planner/types/index.ts | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/apps/web/src/pages/editing-planner/types/index.ts b/apps/web/src/pages/editing-planner/types/index.ts index a7caa72ab..072ad49e1 100644 --- a/apps/web/src/pages/editing-planner/types/index.ts +++ b/apps/web/src/pages/editing-planner/types/index.ts @@ -4,21 +4,13 @@ */ /* 转场 */ -export { - type TransitionType, - type TransitionConfig, - DEFAULT_TRANSITION, -} from "./transition" +export { type TransitionType, type TransitionConfig, DEFAULT_TRANSITION } from "./transition" /* 调速 */ export { type SpeedConfig, DEFAULT_SPEED } from "./speed" /* TTS 配音 */ -export { - type TtsMode, - type TtsConfig, - DEFAULT_TTS_CONFIG, -} from "./tts" +export { type TtsMode, type TtsConfig, DEFAULT_TTS_CONFIG } from "./tts" /* 裁剪 */ export { type TrimConfig } from "./trim" @@ -80,11 +72,7 @@ export { } from "./sticker" /* 封面 */ -export { - type CoverMode, - type CoverConfig, - DEFAULT_COVER_CONFIG, -} from "./cover" +export { type CoverMode, type CoverConfig, DEFAULT_COVER_CONFIG } from "./cover" /* 片段数据 */ export { type ClipType, type ClipData } from "./clip" @@ -93,7 +81,4 @@ export { type ClipType, type ClipData } from "./clip" export { type TitleSettings } from "./title" /* 字幕样式 */ -export { - type SubtitleStyleConfig, - DEFAULT_SUBTITLE_STYLE, -} from "./subtitle" +export { type SubtitleStyleConfig, DEFAULT_SUBTITLE_STYLE } from "./subtitle" -- 2.54.0