Skip to content

🎬 火宝短剧 - 基于AI的一站式短剧生成平台 《一句话生成完整短剧,从剧本到成片全自动化》 Huobao Drama - An AI-Powered End-to-End Short Drama Generator "One Sentence to Complete Drama: Fully Automated from Script to Final Video"

TypeScript

feat 增加整体风格、增加动作序列图片剪切

jiangzj4e14fdeedc67
diff --git a/api/handlers/video_generation.go b/api/handlers/video_generation.go
index 8a89a05..a739a90 100644
--- a/api/handlers/video_generation.go
+++ b/api/handlers/video_generation.go
@@ -16,9 +16,9 @@ type VideoGenerationHandler struct {
log *logger.Logger
}
-func NewVideoGenerationHandler(db *gorm.DB, transferService *services.ResourceTransferService, localStorage *storage.LocalStorage, aiService *services.AIService, log *logger.Logger) *VideoGenerationHandler {
+func NewVideoGenerationHandler(db *gorm.DB, transferService *services.ResourceTransferService, localStorage *storage.LocalStorage, aiService *services.AIService, log *logger.Logger, promptI18n *services.PromptI18n) *VideoGenerationHandler {
return &VideoGenerationHandler{
- videoService: services.NewVideoGenerationService(db, transferService, localStorage, aiService, log),
+ videoService: services.NewVideoGenerationService(db, transferService, localStorage, aiService, log, promptI18n),
log: log,
}
}
diff --git a/api/routes/routes.go b/api/routes/routes.go
index 187ef6e..8c5645e 100644
--- a/api/routes/routes.go
+++ b/api/routes/routes.go
@@ -32,12 +32,13 @@ func SetupRouter(cfg *config.Config, db *gorm.DB, log *logger.Logger, localStora
aiService := services2.NewAIService(db, log)
localStoragePtr := localStorage.(*storage2.LocalStorage)
transferService := services2.NewResourceTransferService(db, log)
+ promptI18n := services2.NewPromptI18n(cfg)
dramaHandler := handlers2.NewDramaHandler(db, cfg, log, nil)
aiConfigHandler := handlers2.NewAIConfigHandler(db, cfg, log)
scriptGenHandler := handlers2.NewScriptGenerationHandler(db, cfg, log)
imageGenService := services2.NewImageGenerationService(db, cfg, transferService, localStoragePtr, log)
imageGenHandler := handlers2.NewImageGenerationHandler(db, cfg, log, transferService, localStoragePtr)
- videoGenHandler := handlers2.NewVideoGenerationHandler(db, transferService, localStoragePtr, aiService, log)
+ videoGenHandler := handlers2.NewVideoGenerationHandler(db, transferService, localStoragePtr, aiService, log, promptI18n)
videoMergeHandler := handlers2.NewVideoMergeHandler(db, nil, cfg.Storage.LocalPath, cfg.Storage.BaseURL, log)
assetHandler := handlers2.NewAssetHandler(db, cfg, log)
characterLibraryService := services2.NewCharacterLibraryService(db, log, cfg)
diff --git a/application/services/drama_service.go b/application/services/drama_service.go
index 276f687..968a32e 100644
--- a/application/services/drama_service.go
+++ b/application/services/drama_service.go
@@ -31,6 +31,7 @@ type CreateDramaRequest struct {
Title string `json:"title" binding:"required,min=1,max=100"`
Description string `json:"description"`
Genre string `json:"genre"`
+ Style string `json:"style"`
Tags string `json:"tags"`
}
@@ -38,6 +39,7 @@ type UpdateDramaRequest struct {
Title string `json:"title" binding:"omitempty,min=1,max=100"`
Description string `json:"description"`
Genre string `json:"genre"`
+ Style string `json:"style"`
Tags string `json:"tags"`
Status string `json:"status" binding:"omitempty,oneof=draft planning production completed archived"`
}
@@ -54,6 +56,7 @@ func (s *DramaService) CreateDrama(req *CreateDramaRequest) (*models.Drama, erro
drama := &models.Drama{
Title: req.Title,
Status: "draft",
+ Style: "ghibli", // 默认风格
}
if req.Description != "" {
@@ -62,6 +65,9 @@ func (s *DramaService) CreateDrama(req *CreateDramaRequest) (*models.Drama, erro
if req.Genre != "" {
drama.Genre = &req.Genre
}
+ if req.Style != "" {
+ drama.Style = req.Style
+ }
if err := s.db.Create(drama).Error; err != nil {
s.log.Errorw("Failed to create drama", "error", err)
@@ -270,6 +276,9 @@ func (s *DramaService) UpdateDrama(dramaID string, req *UpdateDramaRequest) (*mo
if req.Genre != "" {
updates["genre"] = req.Genre
}
+ if req.Style != "" {
+ updates["style"] = req.Style
+ }
if req.Tags != "" {
updates["tags"] = req.Tags
}
diff --git a/application/services/image_generation_service.go b/application/services/image_generation_service.go
index 26d530a..996b2fe 100644
--- a/application/services/image_generation_service.go
+++ b/application/services/image_generation_service.go
@@ -163,6 +163,12 @@ func (s *ImageGenerationService) ProcessImageGeneration(imageGenID uint) {
return
}
+ // 获取drama的style信息
+ var drama models.Drama
+ if err := s.db.First(&drama, imageGen.DramaID).Error; err != nil {
+ s.log.Warnw("Failed to load drama for style", "error", err, "drama_id", imageGen.DramaID)
+ }
+
s.db.Model(&imageGen).Update("status", models.ImageStatusProcessing)
// 如果关联了background,同步更新background为generating状态
@@ -214,7 +220,7 @@ func (s *ImageGenerationService) ProcessImageGeneration(imageGenID uint) {
"local_path", imgPath)
} else {
referenceImages = append(referenceImages, base64Image)
- s.log.Infow("Loaded local image as base64 for generation",
+ s.log.Infow("Loaded local image for generation",
"id", imageGenID,
"local_path", imgPath)
}
@@ -256,7 +262,22 @@ func (s *ImageGenerationService) ProcessImageGeneration(imageGenID uint) {
opts = append(opts, image.WithReferenceImages(referenceImages))
}
+ // 构建完整的提示词:风格提示词 + 用户提示词
prompt := imageGen.Prompt
+
+ // 如果drama有风格设置,添加风格提示词
+ if drama.Style != "" && drama.Style != "realistic" {
+ stylePrompt := s.promptI18n.GetStylePrompt(drama.Style)
+ if stylePrompt != "" {
+ // 将风格提示词作为系统级约束添加到提示词前面
+ prompt = stylePrompt + "\n\n" + prompt
+ s.log.Infow("Added style prompt to image generation",
+ "id", imageGenID,
+ "style", drama.Style,
+ "style_prompt_length", len(stylePrompt))
+ }
+ }
+
prompt += ", imageRatio:" + imageRatio
result, err := client.GenerateImage(prompt, opts...)
if err != nil {
diff --git a/application/services/prompt_i18n.go b/application/services/prompt_i18n.go
index 832bcf7..b2f4b9a 100644
--- a/application/services/prompt_i18n.go
+++ b/application/services/prompt_i18n.go
@@ -313,20 +313,21 @@ Return a JSON object containing:
* **description**: A simplified Chinese description (for reference)`, style, imageRatio)
}
- return fmt.Sprintf(`你是一个专业的导演和图像生成提示词专家。请根据提供的镜头信息,严格按照以下的要求生成适合用于AI图像生成的提示词。
+ return fmt.Sprintf(`**Role:** 你是一位精通视觉叙事与图像生成提示词的专家。你能将用户描述的模糊场景,转化为具有逻辑连贯性、动作多样性的 9 组图片生成指令。
-**核心要求:**
-1. 3行3列共九宫格
-2. 1-9宫格需要展示动作演进
-3. 每个宫格需要体现出不同的动作镜头
-4. 所有画格严格保持角色一致性
+**Core Logic:**
-- **风格要求**:%s
-- **图片比例**:%s
-输出格式:
-返回一个JSON对象,包含:
-- prompt:完整的中文图片生成提示词(详细描述,适合AI图像生成)
-- description:简化的中文描述(供参考)`, style, imageRatio)
+1. **视觉锚定:** 保持主体、服装、画风在 9 个动作中高度一致。
+2. **动作矩阵:** 按照 3x3 九宫格逻辑设计 9 个完全不同的动作(如:行走、奔跑、回眸、战斗准备、跳跃、坐下、思考、倒地、特写凝视)。
+3. **提示词工程:** 使用高质量的视觉词汇(光影、材质、构图、景深)。
+
+**Aspect Ratio:**
+* %s
+
+**Output Specification:**
+必须返回一个 **JSON 对象**,其结构如下:
+* prompt: **完整的中文图片生成提示词**(包含主体+动作细节+环境+光影细节,确保 AI 能直接生成高质量图像)。
+* description: **简化的中文描述**(概括该动作的核心)。`, imageRatio)
}
// GetLastFramePrompt 获取尾帧提示词
@@ -647,3 +648,267 @@ func (p *PromptI18n) FormatUserPrompt(key string, args ...interface{}) string {
}
return template
}
+
+// GetStylePrompt 获取风格提示词
+func (p *PromptI18n) GetStylePrompt(style string) string {
+ if style == "" {
+ return ""
+ }
+
+ stylePrompts := map[string]map[string]string{
+ "zh": {
+ "ghibli": `**[专家角色定位]**
+你现在是一位吉卜力工作室顶级美术指导与背景画师,擅长捕捉"宏大自然与微观生活"的平衡感,深谙宫崎骏式的色彩心理学。
+
+**[风格核心逻辑]**
+- **视觉流派与质感**:采用经典的吉卜力风格。画面具有浓郁的水彩晕染质感(Watercolor texture),拒绝冰冷的3D渲染,强调温暖且有呼吸感的笔触。线条清晰且细腻,呈现出赛璐珞(Cel-shading)上色的明快感。
+- **色彩与光影美学**:使用**"高调色彩美学"**。主色调明亮、通透、高饱和度但色相柔和。光影模拟"夏日午后"的自然采光,光线如同浸透在空气中,具有极佳的明度。阴影部分带有微妙的蓝紫色调,增加画面的通透感。
+- **氛围意向**:怀旧、宁静、牧歌式的(Pastoral)、微风感。画面要传达出一种"世界依然美好"的宁静感和探索欲。`,
+
+ "guoman": `**[专家角色定位]**
+你是一位顶尖的数字插画艺术家,擅长将传统东方韵味与现代游戏美术的华丽视觉特效(VFX)相结合,是"东方幻想主义"构图的大师。
+
+**[风格核心逻辑]**
+- **视觉流派与质感**:融合了**新国风数字艺术(Modern Zen Illustration)**与**史诗级奇幻渲染**。画面质感细腻且带有微微的丝滑感,类似高精度的2D数字绘画。强调光影的体积感,画面中包含大量微小的粒子效果和发光氛围。
+- **核心色彩与发光美学**:使用**"撞色与内生光影"**。主色调通常是冷暖色调的剧烈碰撞(如靛青色与金橙色)。画面逻辑的核心在于**"局部发光"**:暗部点缀着发光的荧光元素(如荧光植物、灯火或水晶质感),这种对比营造了强烈的魔法感和神秘感。
+- **装饰性元素逻辑**:强调**"线条的流动感"**。画面中充斥着优美的曲线,这些线条通常由发光带、飘带或自然界的纹理(如流水的走势)组成,增强了整体的装饰性和节奏感。`,
+
+ "wasteland": `**[专家角色定位]**
+你是一位专注于"末世叙事"的视觉艺术家,擅长运用**硬核线条(Hard Line-art)**和**复古平面印刷感**来营造史诗般的荒凉氛围,深受让·吉罗(Moebius)和现代废土科幻插画的影响。
+
+**[风格核心逻辑]**
+- **视觉流派与笔触质感**:采用**硬缘线条绘图风格(Hard-edged Line Art)**。画面强调清晰的黑色轮廓线,具有强烈的漫画插图感。质感上呈现出一种**颗粒状的平面印刷感(Grainy textures)**或类似旧报纸、复古海报的纹理,拒绝平滑的渐变,倾向于使用排线或点阵来表现阴影。
+- **色彩美学逻辑**:采用**"低频限色色调(Limited Palette)"**。画面通常被一种压抑且统一的色调统治(如灰土色、铁锈橙、荒漠黄)。核心视觉冲击力来自于**一个强烈的对比色点**(如此处巨大的红色落日),这种"单点高亮"的逻辑在灰暗的废土背景中能瞬间抓住视线。
+- **光影表现手法**:使用**"高对比度强侧光(High-contrast Side Lighting)"**。模拟黄昏或黎明的低角度光线,产生极长的投影。光影逻辑极其简化,明暗交界线生硬且明确,营造出一种干枯、灼热且寂静的戏剧张力。`,
+
+ "nostalgia": `**[专家角色定位]**
+你是一位专注于**"怀旧赛璐珞(Nostalgic Cel-shading)"**风格的视觉艺术家,擅长模拟20世纪80-90年代手绘动画的质感,利用色彩与噪点营造一种温和、感性且略带忧郁的都市氛围。
+
+**[风格核心逻辑]**
+- **视觉流派与画面质感**:采用经典的**90年代复古动画风格(90s Retro Anime Style)**。画面具有明显的**胶片颗粒感(Film grain)**和微弱的**色散效果(Chromatic aberration)**,模拟旧式电视或磁带的播放质感。质感上强调"不完美的细腻",即线条略显柔和,不像现代矢量图那样锐利,给人一种手工绘制的温度感。
+- **色彩美学逻辑**:使用**"低对比度粉紫色调(Muted Pastel Palette)"**。画面被一种柔和的、如梦境般的暮色统治,通常以淡紫色、藕粉色或灰蓝色为主基调。色彩逻辑的核心在于**"弱化的黑场"**:没有纯黑,所有深色都带有紫色或蓝色的倾向。这种色调能瞬间勾勒出一种孤独但温馨的"都市黄昏"感。
+- **光影表现手法**:强调**"弥散的点光源(Diffuse Point Lights)"**。光线不是硬性的投射,而是呈晕染状。例如,路灯、车灯或月亮周围有一圈柔和的朦胧光晕(Glow effect)。地面通常带有微弱的雨后反光或湿润感,增加光影的层次感和梦幻感。`,
+
+ "pixel": `**[专家角色定位]**
+你是一位资深的**8位/16位像素艺术家 (Pixel Art Consultant)**,擅长利用受限的分辨率和调色盘来构建具有极强代入感的虚拟世界,模拟早期电子游戏(如《星露谷物语》或经典RPG)的视觉美学。
+
+**[风格核心逻辑]**
+- **视觉流派与画面质感**:采用纯正的**像素艺术风格 (Pixel Art)**。画面由清晰可见的方格(Pixels)组成,强调**"阶梯状线条 (Aliased lines)"**。质感上完全摒弃平滑的渐变和模糊,追求一种数码化的、网格化的块状美感。
+- **色彩美学逻辑**:使用**"受限调色盘 (Limited Color Palette)"**。色彩选择极度精简,不追求自然的过渡,而是通过大面积的色块叠加。色彩逻辑的核心在于**"抖动算法思维 (Dithering logic)"**:通过不同颜色方格的交替排列来模拟明暗变化,色调通常饱和度中等,呈现出一种清爽、明快的电子游戏感。
+- **光影表现手法**:强调**"色块式阴影 (Flat Shading)"**。光影表现不使用羽化或软光,而是通过增加一层更深的同色系像素块来表示投影。光线通常是恒定的,没有复杂的反射或折射,太阳或光源本身也被处理成一个规则的像素圆点。`,
+
+ "voxel": `**[专家角色定位]**
+你是一位顶尖的**3D体素建模师 (Voxel Artist)**,擅长利用统一规格的立方体单位构建充满童趣、模块化且具有高度秩序感的微缩世界。你的视觉风格强调**低多边形(Low-poly)的纯粹性**与**现代实时光影渲染**的结合。
+
+**[风格核心逻辑]**
+- **视觉流派与质感**:采用**三维体素风格 (3D Voxel Style)**。画面由无数等比例的立方体单元(Voxels)堆叠而成,呈现出一种强烈的模块化感。质感上具有明显的**"方块化线条"**,物体表面是平整的色块,这种简化的几何语言创造了一种独特的数字美感。
+- **色彩美学逻辑**:使用**"自然饱和度与渐变光影"**。色彩通常根据环境属性进行大块划分(如草地的绿、土地的褐),但关键在于**色彩的微小扰动 (Color Jitter)**:同一区域的方块颜色会有微妙的深浅差异,模拟真实环境的随机感。色调通常明亮、清新,充满活力感。
+- **光影表现手法**:强调**"全局光照渲染 (Global Illumination)"**。这是体素艺术升华的关键:尽管物体是方块状的,但光影必须是**电影级的写实渲染**。光线具有温暖的体积感(如耶稣光),阴影边缘柔和且带有环境遮蔽(AO)效果,方块边缘会被高亮勾勒,使画面看起来像是一个精致的现实微缩模型。`,
+
+ "urban": `**[专家角色定位]**
+你是一位顶尖的**网漫主笔(Lead Webtoon Artist)**,擅长创作具有现代都市感的人物立绘。你的视觉风格强调**锐利的轮廓线**、**利落的穿搭逻辑**以及**冷色调的都市氛围**,旨在营造一种"高冷、精致、工业化美感"的视觉冲击。
+
+**[风格核心逻辑]**
+- **视觉流派与画面质感**:采用**现代韩漫数字绘图风格 (Modern Webtoon Art Style)**。画面具有极干净的**矢量线条 (Crisp line art)**,没有任何多余的笔触。质感上呈现出一种平滑的数字皮肤质感,强调色彩的整洁度,避免了复杂的笔触叠加。
+- **色彩美学逻辑**:使用**"冷调都市灰(Muted Urban Tones)"**。画面以黑、白、灰、深蓝等中性色为主色调。色彩逻辑的核心在于**"高对比度的荧光色反差"**:整体处于清冷的低饱和度环境下,但利用背景中的**霓虹灯(Neon glow)**或电子屏产生高亮的粉、蓝、紫偏色,营造出一种深夜都市的疏离感。
+- **光影表现手法**:强调**"硬边赛璐珞阴影 (Hard Cel-shading)"**。阴影边缘极其干脆,没有渐变。光影逻辑模仿**"环境侧光"**:光线通常来自侧方的霓虹招牌,在人物一侧留下窄长的亮边(Rim lighting),增强了人物的轮廓感和立体感。`,
+
+ "guoman3d": `**[专家角色定位]**
+你是一位顶级**次世代游戏美术总监 (Lead Technical Artist)**,擅长使用虚幻引擎 5 (UE5) 创作高精度的 3D 仙侠角色。你的风格以**物理渲染 (PBR)** 的极高真实度、复杂的服饰层次感以及极具东方美学的全局光照处理著称。
+
+**[风格核心逻辑]**
+- **视觉流派与画面质感**:采用**高精细 3D 写实渲染风格 (High-fidelity 3D Rendering)**。画面具有极强的**次世代游戏质感 (Next-gen game aesthetic)**,强调皮肤的次表面散射 (SSS) 效果和极其真实的服饰纹理(如丝绸的平滑感、皮革的磨损感、金属的拉丝质感)。整体呈现出一种细腻的数码雕琢美,边缘锐利且细节丰富。
+- **色彩美学逻辑**:使用**"素雅沉稳的中性色调 (Sophisticated Neutral Palette)"**。不同于高饱和度的动漫风格,这种逻辑倾向于使用低饱和、高明度的色彩(如米白、石青、灰褐),并配以小面积的暗红色或金色作为高级感点缀。光影色彩通常偏向**清晨或傍晚的自然日光**,给人一种宁静、肃穆且大气的东方韵味。
+- **光影表现手法**:强调**"电影级动态光影 (Cinematic Lighting)"**。光源方向明确(通常是明亮的侧逆光),在人物边缘勾勒出一层淡淡的金边 (Rim Light),将主体与背景完美分离。同时利用环境遮蔽 (AO) 增加细节深度,让服饰的每一个褶皱都清晰可见,呈现出一种沉浸式的戏剧张力。`,
+
+ "chibi3d": `**[专家角色定位]**
+你是一位顶尖的 **3D 玩具设计师与灯光渲染师**,擅长创作高精细度的数字手办。你的视觉风格结合了 **Q 版二头身比例 (Chibi proportions)** 与 **超写实材质渲染 (PBR Rendering)**,旨在营造一种精致、可爱且具有高级触感的"数字潮流玩具"视觉效果。
+
+**[风格核心逻辑]**
+- **视觉流派与画面质感**:采用 **3D 盲盒艺术风格 (Blind Box / Toy Art Style)**。画面具有极强的 **类塑料与树脂质感 (Plastic and Resin texture)**,表面圆润、平滑,边缘带有微妙的倒角。主体呈现出明显的 **Q 版比例**(大头小身),增强了亲和力。
+- **色彩美学逻辑**:使用 **"温和的高饱和调色盘 (Muted Vibrant Palette)"**。色彩鲜艳但并不刺眼,通常带有一定的 **粉质感 (Pastel undertone)**。色彩分布遵循"主次分明"原则,利用大面积的自然底色(如森林绿、泥土褐)衬托主体鲜明的服饰色彩。
+- **光影表现手法**:光源通常柔和且均匀。**顶光/面光**:均匀照亮主体正面,突出五官和服饰细节。**环境遮蔽 (Ambient Occlusion)**:在缝隙和接触面产生细腻的阴影,增强物体的重量感和真实感。`,
+ },
+ "en": {
+ "ghibli": `**[Expert Role]**
+You are a top Art Director and Background Artist from Studio Ghibli. You excel at capturing the balance between "grand nature and microscopic life," and you possess a deep understanding of Hayao Miyazaki's color psychology.
+
+**[Core Style Logic]**
+- **Visual Genre & Texture**: Adopts the classic Ghibli style. The imagery features a rich **watercolor texture**, rejecting cold 3D rendering in favor of warm, "breathing" brushstrokes. Lines are clear yet delicate, presenting the vibrant feel of **cel-shading**.
+- **Color & Lighting Aesthetics**: Utilizes **"High-key Color Aesthetics."** The palette is bright, transparent, and high-saturated but with soft hues. Lighting simulates the natural light of a "summer afternoon," where light feels soaked into the air with excellent luminosity. Shadows contain subtle blue-purple tones to enhance the transparency of the frame.
+- **Atmospheric Intent**: Nostalgic, serene, **pastoral**, and breezy. The image should convey a sense of tranquility and a desire for exploration—a feeling that "the world is still beautiful."`,
+
+ "guoman": `**[Expert Role]**
+You are a top-tier digital illustration artist, skilled at merging traditional Eastern charm with the magnificent Visual Effects (VFX) of modern game art. You are a master of "Oriental Fantasy" composition.
+
+**[Core Style Logic]**
+- **Visual Genre & Texture**: A fusion of **Modern Zen Illustration (New Guofeng)** and epic fantasy rendering. The texture is delicate with a silky feel, similar to high-precision 2D digital painting. It emphasizes volumetric lighting and includes a large amount of tiny particle effects and glowing atmospheres.
+- **Core Color & Luminous Aesthetics**: Employs **"Contrasting Colors & Endogenous Lighting."** The main palette usually features intense collisions of cool and warm tones (e.g., indigo and golden orange). The core logic lies in **"Local Luminescence"**: dark areas are dotted with bioluminescent elements (like fluorescent plants, lanterns, or crystal textures), creating a strong sense of magic and mystery.
+- **Decorative Element Logic**: Emphasizes the **"Flow of Lines."** The frame is filled with elegant curves, often composed of light trails, ribbons, or natural textures (like the flow of water), enhancing the overall decorativeness and rhythm.`,
+
+ "wasteland": `**[Expert Role]**
+You are a visual artist focused on "Post-Apocalyptic Narrative," skilled at using **Hard Line-art** and a **retro print feel** to create epic, desolate atmospheres, heavily influenced by Moebius and modern wasteland sci-fi illustrations.
+
+**[Core Style Logic]**
+- **Visual Genre & Brushwork Texture**: Adopts a **Hard-edged Line Art** style. The image emphasizes bold black outlines with a strong comic illustration feel. The texture presents a **grainy, flat-print quality**, similar to old newspapers or retro posters, rejecting smooth gradients in favor of hatching or stippling for shadows.
+- **Color Aesthetic Logic**: Employs a **"Limited Palette."** The frame is typically dominated by an oppressive, unified tone (e.g., dusty earth, rust orange, desert yellow). The core visual impact comes from a **single strong contrast point** (such as a massive red setting sun), a "single-point highlight" logic that instantly grabs attention against the gloomy background.
+- **Lighting Technique**: Uses **"High-contrast Side Lighting."** Simulates the low-angle light of dusk or dawn, producing extremely long shadows. The lighting logic is highly simplified with sharp, distinct terminators, creating a dry, scorching, and silent dramatic tension.`,
+
+ "nostalgia": `**[Expert Role]**
+You are a visual artist specializing in the **"Nostalgic Cel-shading"** style, expert at simulating the texture of 1980s-90s hand-drawn animation. You use color and noise to create a gentle, emotional, and slightly melancholic urban atmosphere.
+
+**[Core Style Logic]**
+- **Visual Genre & Frame Texture**: Adopts the classic **90s Retro Anime Style**. The image features obvious **film grain** and slight **chromatic aberration**, simulating the playback quality of old TVs or VHS tapes. The texture emphasizes "imperfect delicacy"—lines are soft rather than sharp like modern vectors, giving a sense of handcrafted warmth.
+- **Color Aesthetic Logic**: Uses a **"Muted Pastel Palette."** The frame is dominated by a soft, dreamlike twilight, usually featuring lavender, lotus pink, or grayish-blue. The core logic is the **"Weakened Black Point"**: there are no pure blacks; all dark colors lean toward purple or blue. This tone instantly outlines a lonely but cozy "urban dusk" feel.
+- **Lighting Technique**: Emphasizes **"Diffuse Point Lights."** Light is not a hard projection but a bleeding glow. For example, streetlights, car headlights, or the moon have a soft, hazy halo (Glow effect). Surfaces often have a slight post-rain reflection or dampness, increasing the layers and dreaminess of the light.`,
+
+ "pixel": `**[Expert Role]**
+You are a senior **Pixel Art Consultant (8-bit/16-bit)**, skilled at using restricted resolutions and palettes to build highly immersive virtual worlds, simulating the aesthetics of early video games like *Stardew Valley* or classic RPGs.
+
+**[Core Style Logic]**
+- **Visual Genre & Frame Texture**: Adopts a pure **Pixel Art** style. The image consists of clearly visible squares (pixels), emphasizing **"Aliased lines."** It completely discards smooth gradients and blurring, pursuing a digital, grid-based blocky beauty.
+- **Color Aesthetic Logic**: Uses a **"Limited Color Palette."** Color choices are extremely streamlined, avoiding natural transitions in favor of large color block overlays. The core logic is **"Dithering logic"**: alternating pixel patterns of different colors to simulate shading. Tones are usually medium saturation, presenting a crisp, bright video game feel.
+- **Lighting Technique**: Emphasizes **"Flat Shading."** Lighting does not use feathering or soft light; instead, it uses a layer of darker pixels from the same color family to represent shadows. Light sources are constant without complex reflections, and even the sun or light sources are treated as regular pixel circles.`,
+
+ "voxel": `**[Expert Role]**
+You are a top-tier **3D Voxel Artist**, skilled at using uniform cube units to build whimsical, modular, and highly ordered miniature worlds. Your style combines the purity of **Low-poly** geometry with modern real-time lighting rendering.
+
+**[Core Style Logic]**
+- **Visual Genre & Texture**: Adopts a **3D Voxel Style**. The image is composed of countless proportional cubes (voxels) stacked together, presenting a strong modular feel. The texture features obvious **"blocky lines"** and flat color surfaces; this simplified geometric language creates a unique digital aesthetic.
+- **Color Aesthetic Logic**: Uses **"Natural Saturation & Gradient Lighting."** Colors are divided into large blocks based on environmental attributes (green for grass, brown for soil), but the key lies in **"Color Jitter"**: subtle shade variations between blocks in the same area to simulate the randomness of real environments. Tones are bright, fresh, and full of vitality.
+- **Lighting Technique**: Emphasizes **"Global Illumination Rendering."** This is the key to elevating voxel art: while objects are blocky, the lighting must be **cinematic and realistic**. Light has warm volumetric qualities (e.g., God rays), shadows are soft with Ambient Occlusion (AO) effects, and voxel edges are highlighted, making the scene look like an exquisite real-life miniature model.`,
+
+ "urban": `**[Expert Role]**
+You are a leading **Webtoon Artist**, specializing in modern urban character illustrations. Your visual style emphasizes **sharp outlines**, **slick fashion logic**, and a **cool-toned urban atmosphere**, aiming to create a "high-cold, sophisticated, industrial-chic" visual impact.
+
+**[Core Style Logic]**
+- **Visual Genre & Frame Texture**: Adopts the **Modern Webtoon Art Style**. The image features extremely clean **crisp line art** (vector-like) without any redundant strokes. The texture presents a smooth digital skin quality, emphasizing color cleanliness and avoiding complex brushwork layering.
+- **Color Aesthetic Logic**: Uses **"Muted Urban Tones."** The palette is dominated by neutral colors like black, white, gray, and deep blue. The core logic is **"High-contrast Neon Accents"**: while the overall environment is cool and low-saturation, highlights from **neon glows** or electronic screens (pink, blue, purple) create a sense of late-night urban detachment.
+- **Lighting Technique**: Emphasizes **"Hard Cel-shading."** Shadow edges are extremely crisp with no gradients. The logic mimics **"Environmental Rim Lighting"**: light usually comes from side neon signs, leaving a narrow bright edge (Rim lighting) on one side of the character, enhancing their silhouette and 3D feel.`,
+
+ "guoman3d": `**[Expert Role]**
+You are a top-tier **Next-gen Lead Technical Artist**, skilled in using Unreal Engine 5 (UE5) to create high-precision 3D Xianxia (Immortal Hero) characters. Your style is known for high-fidelity **Physically Based Rendering (PBR)**, complex clothing layers, and global illumination with an Eastern aesthetic.
+
+**[Core Style Logic]**
+- **Visual Genre & Frame Texture**: Adopts a **High-fidelity 3D Rendering style**. The image has a strong **next-gen game aesthetic**, emphasizing Subsurface Scattering (SSS) for skin and realistic fabric textures (smoothness of silk, wear on leather, brushed metal). The overall look is a delicate digital sculpture with sharp edges and rich details.
+- **Color Aesthetic Logic**: Uses a **"Sophisticated Neutral Palette."** Unlike high-saturation anime styles, this logic leans toward low-saturation, high-brightness colors (off-white, stone green, gray-brown), accented with small areas of dark red or gold for a premium feel. Lighting colors typically mimic **natural morning or evening sunlight**, giving an air of tranquility, solemnity, and grand Eastern charm.
+- **Lighting Technique**: Emphasizes **"Cinematic Lighting."** Light directions are clear (usually bright side-backlighting), creating a faint golden **Rim Light** that perfectly separates the subject from the background. Ambient Occlusion (AO) is used to increase detail depth, making every fold in the clothing visible and creating immersive dramatic tension.`,
+
+ "chibi3d": `**[Expert Role]**
+You are a top-tier **3D Toy Designer and Rendering Artist**, specializing in high-precision digital figurines. Your visual style combines **Chibi proportions** with **Ultra-realistic PBR rendering**, aiming to create a sophisticated, cute, and tactile "Art Toy" visual effect.
+
+**[Core Style Logic]**
+- **Visual Genre & Frame Texture**: Adopts a **3D Blind Box / Toy Art Style**. The image features strong **plastic and resin textures**; surfaces are rounded and smooth with subtle beveled edges. The subject uses **Chibi proportions** (large head, small body) to enhance appeal.
+- **Color Aesthetic Logic**: Uses a **"Muted Vibrant Palette."** Colors are vivid but not piercing, usually with a **pastel undertone**. Color distribution follows a "primary-secondary" principle, using large areas of natural base colors (forest green, earth brown) to set off the bright colors of the character's outfit.
+- **Lighting Technique**: Light sources are typically soft and even: **Top/Key Light**: Evenly illuminates the subject's front, highlighting facial features and clothing details. **Ambient Occlusion (AO)**: Produces delicate shadows in crevices and contact points, enhancing the object's sense of weight and realism.`,
+ },
+ }
+
+ lang := "zh"
+ if p.IsEnglish() {
+ lang = "en"
+ }
+
+ if prompts, ok := stylePrompts[lang]; ok {
+ if prompt, exists := prompts[style]; exists {
+ return prompt
+ }
+ }
+
+ return ""
+}
+
+// GetVideoConstraintPrompt 获取视频生成的约束提示词
+// referenceMode: "single" (单图), "first_last" (首尾帧), "multiple" (多图), "action_sequence" (动作序列)
+func (p *PromptI18n) GetVideoConstraintPrompt(referenceMode string) string {
+ // 动作序列图(九宫格)的约束提示词
+ actionSequencePrompts := map[string]string{
+ "zh": `### 角色定义
+
+你是一个极高精度的视频生成专家,擅长将九宫格(3x3)序列图转化为具有电影质感的连贯视频。你的核心任务是解析图像中的时空逻辑,并严格遵守首尾帧约束。
+
+### 核心执行逻辑
+
+1. **首尾帧锚定:** 必须提取九宫格的第一格(左上角)作为视频的起始帧(Frame 0),提取第九格(右下角)作为视频的结束帧(Final Frame)。
+2. **序列插值(Interpolation):** 九宫格的第 2 至 第 8 格定义了动作的关键路径。你需分析这些关键帧之间的逻辑位移、光影变化和物体形变。
+3. **一致性维护:** 确保角色特征(面部、服装)、场景细节、艺术风格在全视频中保持 100% 的时空稳定性。
+4. **动态补充:** 在九宫格定义的关键动作之间,自动补全流畅的过渡帧,确保视频动作频率自然(建议 24fps 或 30fps)。
+
+### 结构化约束指令
+
+* **输入解析:** 识别用户提供的场景描述词(Prompt)与九宫格参考图。
+* **动作矢量化:** 计算物体从 Grid 1 到 Grid 9 的运动矢量。如果九宫格展示的是缩放或平移,请在视频中还原精准的运镜。
+* **严禁幻觉:** 禁止引入九宫格和提示词中未提及的新元素或背景切换。`,
+
+ "en": `### Role Definition
+
+You are an ultra-high-precision video generation expert, specializing in transforming 9-grid (3x3) sequential images into coherent videos with cinematic quality. Your core task is to parse the spatiotemporal logic within the images and strictly adhere to first-and-last frame constraints.
+
+### Core Execution Logic
+
+1. **First-Last Frame Anchoring:** You must extract Grid 1 (top-left corner) as the video's starting frame (Frame 0) and Grid 9 (bottom-right corner) as the ending frame (Final Frame).
+2. **Sequence Interpolation:** Grids 2 through 8 define the key action path. You need to analyze the logical displacement, lighting changes, and object deformations between these keyframes.
+3. **Consistency Maintenance:** Ensure that character features (face, clothing), scene details, and artistic style maintain 100% spatiotemporal stability throughout the entire video.
+4. **Dynamic Supplementation:** Automatically fill in smooth transition frames between the keyframes defined by the 9-grid, ensuring natural video motion frequency (recommended 24fps or 30fps).
+
+### Structured Constraint Instructions
+
+* **Input Parsing:** Identify the scene description (Prompt) and 9-grid reference images provided by the user.
+* **Motion Vectorization:** Calculate the motion vectors of objects from Grid 1 to Grid 9. If the 9-grid shows scaling or panning, restore precise camera movements in the video.
+* **Hallucination Prohibition:** Do not introduce new elements or background switches not mentioned in the 9-grid and prompt.`,
+ }
+
+ // 通用约束提示词(单图、首尾帧、多图)
+ generalPrompts := map[string]string{
+ "zh": `### 角色定义
+
+你是一个顶级的视频动态分析师与合成专家。你能够仅凭一张静态图或一组起始/结束帧,精准识别画面中的物理属性、光影流向及潜在的运动趋势,生成符合物理定律的高质量视频。
+
+### 核心执行逻辑
+
+1. **模式识别:**
+* **单图模式(Single Image):** 将输入图视为 Frame 0。分析画面中的"张力点"(如倾斜的身体、流动的液体、眼神的方向),并向该方向延续动作。
+* **双图模式(First & Last Frames):** 严格锚定第一张图为起始,第二张图为终点。通过**语义插值算法**,计算两图之间所有元素的位移轨迹。
+
+2. **物理一致性(Physics Preservation):**
+* **质量守恒:** 确保物体在运动过程中体积、密度和材质质感不发生突变。
+* **运动惯性:** 遵循经典力学,起步平稳,加速自然,停止时不应有生硬的切断感。
+
+3. **环境外推:** 自动补充主画面之外的背景延伸,确保运镜(Pan/Tilt/Zoom)时不会出现画面空洞或黑边。`,
+
+ "en": `### Role Definition
+
+You are a top-tier video dynamics analyst and synthesis expert. You can accurately identify physical properties, light flow, and potential motion trends in a static image or a set of start/end frames, generating high-quality videos that comply with physical laws.
+
+### Core Execution Logic
+
+1. **Mode Recognition:**
+* **Single Image Mode:** Treat the input image as Frame 0. Analyze "tension points" in the frame (such as tilted bodies, flowing liquids, eye direction) and extend the action in that direction.
+* **First & Last Frames Mode:** Strictly anchor the first image as the start and the second image as the endpoint. Use **semantic interpolation algorithms** to calculate the displacement trajectories of all elements between the two images.
+
+2. **Physics Preservation:**
+* **Mass Conservation:** Ensure that objects do not undergo sudden changes in volume, density, or material texture during motion.
+* **Motion Inertia:** Follow classical mechanics with smooth starts, natural acceleration, and no abrupt stops.
+
+3. **Environment Extrapolation:** Automatically supplement background extensions beyond the main frame to ensure no voids or black edges appear during camera movements (Pan/Tilt/Zoom).`,
+ }
+
+ lang := "zh"
+ if p.IsEnglish() {
+ lang = "en"
+ }
+
+ // 如果是动作序列模式,返回九宫格约束提示词
+ if referenceMode == "action_sequence" {
+ if prompt, ok := actionSequencePrompts[lang]; ok {
+ return prompt
+ }
+ }
+
+ // 其他模式返回通用约束提示词
+ if prompt, ok := generalPrompts[lang]; ok {
+ return prompt
+ }
+
+ return ""
+}
diff --git a/application/services/video_generation_service.go b/application/services/video_generation_service.go
index 3ffe455..a0583ea 100644
--- a/application/services/video_generation_service.go
+++ b/application/services/video_generation_service.go
@@ -23,9 +23,10 @@ type VideoGenerationService struct {
localStorage *storage.LocalStorage
aiService *AIService
ffmpeg *ffmpeg.FFmpeg
+ promptI18n *PromptI18n
}
-func NewVideoGenerationService(db *gorm.DB, transferService *ResourceTransferService, localStorage *storage.LocalStorage, aiService *AIService, log *logger.Logger) *VideoGenerationService {
+func NewVideoGenerationService(db *gorm.DB, transferService *ResourceTransferService, localStorage *storage.LocalStorage, aiService *AIService, log *logger.Logger, promptI18n *PromptI18n) *VideoGenerationService {
service := &VideoGenerationService{
db: db,
localStorage: localStorage,
@@ -33,6 +34,7 @@ func NewVideoGenerationService(db *gorm.DB, transferService *ResourceTransferSer
aiService: aiService,
log: log,
ffmpeg: ffmpeg.NewFFmpeg(log),
+ promptI18n: promptI18n,
}
go service.RecoverPendingTasks()
@@ -49,13 +51,13 @@ type GenerateVideoRequest struct {
ReferenceMode string `json:"reference_mode"`
// 单图模式
- ImageURL string `json:"image_url"`
+ ImageURL string `json:"image_url"`
ImageLocalPath *string `json:"image_local_path"` // 单图模式的本地路径
// 首尾帧模式
- FirstFrameURL *string `json:"first_frame_url"`
+ FirstFrameURL *string `json:"first_frame_url"`
FirstFrameLocalPath *string `json:"first_frame_local_path"` // 首帧本地路径
- LastFrameURL *string `json:"last_frame_url"`
+ LastFrameURL *string `json:"last_frame_url"`
LastFrameLocalPath *string `json:"last_frame_local_path"` // 尾帧本地路径
// 多图模式
@@ -192,6 +194,12 @@ func (s *VideoGenerationService) ProcessVideoGeneration(videoGenID uint) {
return
}
+ // 获取drama的style信息
+ var drama models.Drama
+ if err := s.db.First(&drama, videoGen.DramaID).Error; err != nil {
+ s.log.Warnw("Failed to load drama for style", "error", err, "drama_id", videoGen.DramaID)
+ }
+
s.db.Model(&videoGen).Update("status", models.VideoStatusProcessing)
client, err := s.getVideoClient(videoGen.Provider, videoGen.Model)
@@ -286,7 +294,48 @@ func (s *VideoGenerationService) ProcessVideoGeneration(videoGenID uint) {
}
}
- result, err := client.GenerateVideo(imageURL, videoGen.Prompt, opts...)
+ // 构建完整的提示词:风格提示词 + 约束提示词 + 用户提示词
+ prompt := videoGen.Prompt
+
+ // 2. 添加视频约束提示词
+ // 根据参考图模式选择对应的约束提示词
+ referenceMode := "single" // 默认单图模式
+ if videoGen.ReferenceMode != nil {
+ referenceMode = *videoGen.ReferenceMode
+ }
+
+ // 如果是单图模式,需要检查图片是否为动作序列图
+ if referenceMode == "single" && videoGen.ImageGenID != nil {
+ var imageGen models.ImageGeneration
+ if err := s.db.First(&imageGen, *videoGen.ImageGenID).Error; err == nil {
+ // 如果图片的frame_type是action,使用动作序列约束提示词
+ if imageGen.FrameType != nil && *imageGen.FrameType == "action" {
+ referenceMode = "action_sequence"
+ s.log.Infow("Detected action sequence image in single mode",
+ "id", videoGenID,
+ "image_gen_id", *videoGen.ImageGenID,
+ "frame_type", *imageGen.FrameType)
+ }
+ }
+ }
+
+ constraintPrompt := s.promptI18n.GetVideoConstraintPrompt(referenceMode)
+ if constraintPrompt != "" {
+ prompt = constraintPrompt + "\n\n" + prompt
+ s.log.Infow("Added constraint prompt to video generation",
+ "id", videoGenID,
+ "reference_mode", referenceMode,
+ "constraint_prompt_length", len(constraintPrompt))
+ }
+
+ // 打印完整的提示词信息
+ s.log.Infow("Video generation prompts",
+ "id", videoGenID,
+ "user_prompt", videoGen.Prompt,
+ "constraint_prompt", constraintPrompt,
+ "final_prompt", prompt)
+
+ result, err := client.GenerateVideo(imageURL, prompt, opts...)
if err != nil {
s.log.Errorw("Video generation API call failed", "error", err, "id", videoGenID)
s.updateVideoGenError(videoGenID, err.Error())
@@ -719,7 +768,7 @@ func (s *VideoGenerationService) convertImageToBase64(imageURL string) (string,
// 尝试从本地存储读取
if s.localStorage != nil {
var relativePath string
-
+
// 1. 检查是否是本地URL(包含 /static/)
if strings.Contains(imageURL, "/static/") {
// 提取相对路径,例如从 "http://localhost:5678/static/images/xxx.jpg" 提取 "images/xxx.jpg"
@@ -731,11 +780,11 @@ func (s *VideoGenerationService) convertImageToBase64(imageURL string) (string,
// 2. 如果不是 HTTP/HTTPS URL,视为相对路径(如 "images/xxx.jpg")
relativePath = imageURL
}
-
+
// 如果识别出相对路径,尝试读取本地文件
if relativePath != "" {
absPath := s.localStorage.GetAbsolutePath(relativePath)
-
+
// 使用工具函数转换为base64
base64Str, err := utils.ImageToBase64(absPath)
if err == nil {
diff --git a/web/package.json b/web/package.json
index 6682cd4..9d2800d 100644
--- a/web/package.json
+++ b/web/package.json
@@ -16,6 +16,7 @@
"@ffmpeg/ffmpeg": "^0.12.15",
"@ffmpeg/util": "^0.12.2",
"axios": "^1.6.0",
+ "cropperjs": "^2.1.0",
"dayjs": "^1.11.10",
"element-plus": "^2.5.0",
"lodash-es": "^4.17.22",
diff --git a/web/src/components/common/CreateDramaDialog.vue b/web/src/components/common/CreateDramaDialog.vue
index 2917a40..da63f9b 100644
--- a/web/src/components/common/CreateDramaDialog.vue
+++ b/web/src/components/common/CreateDramaDialog.vue
@@ -8,19 +8,19 @@
class="create-dialog"
@closed="handleClosed"
>
- <div class="dialog-desc">{{ $t('drama.createDesc') }}</div>
-
- <el-form
- ref="formRef"
- :model="form"
- :rules="rules"
+ <div class="dialog-desc">{{ $t("drama.createDesc") }}</div>
+
+ <el-form
+ ref="formRef"
+ :model="form"
+ :rules="rules"
label-position="top"
class="create-form"
@submit.prevent="handleSubmit"
>
<el-form-item :label="$t('drama.projectName')" prop="title" required>
- <el-input
- v-model="form.title"
+ <el-input
+ v-model="form.title"
:placeholder="$t('drama.projectNamePlaceholder')"
size="large"
maxlength="100"
@@ -29,9 +29,9 @@
</el-form-item>
<el-form-item :label="$t('drama.projectDesc')" prop="description">
- <el-input
- v-model="form.description"
- type="textarea"
+ <el-input
+ v-model="form.description"
+ type="textarea"
:rows="4"
:placeholder="$t('drama.projectDescPlaceholder')"
maxlength="500"
@@ -39,21 +39,40 @@
resize="none"
/>
</el-form-item>
+
+ <el-form-item :label="$t('drama.style')" prop="style" required>
+ <el-select
+ v-model="form.style"
+ :placeholder="$t('drama.stylePlaceholder')"
+ size="large"
+ style="width: 100%"
+ >
+ <el-option :label="$t('drama.styles.ghibli')" value="ghibli" />
+ <el-option :label="$t('drama.styles.guoman')" value="guoman" />
+ <el-option :label="$t('drama.styles.wasteland')" value="wasteland" />
+ <el-option :label="$t('drama.styles.nostalgia')" value="nostalgia" />
+ <el-option :label="$t('drama.styles.pixel')" value="pixel" />
+ <el-option :label="$t('drama.styles.voxel')" value="voxel" />
+ <el-option :label="$t('drama.styles.urban')" value="urban" />
+ <el-option :label="$t('drama.styles.guoman3d')" value="guoman3d" />
+ <el-option :label="$t('drama.styles.chibi3d')" value="chibi3d" />
+ </el-select>
+ </el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button size="large" @click="handleClose">
- {{ $t('common.cancel') }}
+ {{ $t("common.cancel") }}
</el-button>
- <el-button
- type="primary"
+ <el-button
+ type="primary"
size="large"
:loading="loading"
@click="handleSubmit"
>
<el-icon v-if="!loading"><Plus /></el-icon>
- {{ $t('drama.createNew') }}
+ {{ $t("drama.createNew") }}
</el-button>
</div>
</template>
@@ -61,87 +80,97 @@
</template>
<script setup lang="ts">
-import { ref, reactive, watch } from 'vue'
-import { useRouter } from 'vue-router'
-import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
-import { Plus } from '@element-plus/icons-vue'
-import { dramaAPI } from '@/api/drama'
-import type { CreateDramaRequest } from '@/types/drama'
+import { ref, reactive, watch } from "vue";
+import { useRouter } from "vue-router";
+import { ElMessage, type FormInstance, type FormRules } from "element-plus";
+import { Plus } from "@element-plus/icons-vue";
+import { dramaAPI } from "@/api/drama";
+import type { CreateDramaRequest } from "@/types/drama";
/**
* CreateDramaDialog - Reusable dialog for creating new drama projects
* 创建短剧弹窗 - 可复用的创建短剧项目弹窗
*/
const props = defineProps<{
- modelValue: boolean
-}>()
+ modelValue: boolean;
+}>();
const emit = defineEmits<{
- 'update:modelValue': [value: boolean]
- 'created': [id: string]
-}>()
+ "update:modelValue": [value: boolean];
+ created: [id: string];
+}>();
-const router = useRouter()
-const formRef = ref<FormInstance>()
-const loading = ref(false)
+const router = useRouter();
+const formRef = ref<FormInstance>();
+const loading = ref(false);
// v-model binding / 双向绑定
-const visible = ref(props.modelValue)
-watch(() => props.modelValue, (val) => {
- visible.value = val
-})
+const visible = ref(props.modelValue);
+watch(
+ () => props.modelValue,
+ (val) => {
+ visible.value = val;
+ },
+);
watch(visible, (val) => {
- emit('update:modelValue', val)
-})
+ emit("update:modelValue", val);
+});
// Form data / 表单数据
const form = reactive<CreateDramaRequest>({
- title: '',
- description: ''
-})
+ title: "",
+ description: "",
+ style: "ghibli",
+});
// Validation rules / 验证规则
const rules: FormRules = {
title: [
- { required: true, message: '请输入项目标题', trigger: 'blur' },
- { min: 1, max: 100, message: '标题长度在 1 到 100 个字符', trigger: 'blur' }
- ]
-}
+ { required: true, message: "请输入项目标题", trigger: "blur" },
+ {
+ min: 1,
+ max: 100,
+ message: "标题长度在 1 到 100 个字符",
+ trigger: "blur",
+ },
+ ],
+ style: [{ required: true, message: "请选择风格", trigger: "change" }],
+};
// Reset form when dialog closes / 关闭时重置表单
const handleClosed = () => {
- form.title = ''
- form.description = ''
- formRef.value?.resetFields()
-}
+ form.title = "";
+ form.description = "";
+ formRef.value?.resetFields();
+};
// Close dialog / 关闭弹窗
const handleClose = () => {
- visible.value = false
-}
+ visible.value = false;
+};
// Submit form / 提交表单
const handleSubmit = async () => {
- if (!formRef.value) return
-
+ if (!formRef.value) return;
+
await formRef.value.validate(async (valid) => {
if (valid) {
- loading.value = true
+ loading.value = true;
try {
- const drama = await dramaAPI.create(form)
- ElMessage.success('创建成功')
- visible.value = false
- emit('created', drama.id)
+ const drama = await dramaAPI.create(form);
+ ElMessage.success("创建成功");
+ visible.value = false;
+ emit("created", drama.id);
// Navigate to drama detail page / 跳转到短剧详情页
- router.push(`/dramas/${drama.id}`)
+ router.push(`/dramas/${drama.id}`);
} catch (error: any) {
- ElMessage.error(error.message || '创建失败')
+ ElMessage.error(error.message || "创建失败");
} finally {
- loading.value = false
+ loading.value = false;
}
}
- })
-}
+ });
+};
</script>
<style scoped>
diff --git a/web/src/components/common/ImageCropDialog.vue b/web/src/components/common/ImageCropDialog.vue
new file mode 100644
index 0000000..31375ca
--- /dev/null
+++ b/web/src/components/common/ImageCropDialog.vue
@@ -0,0 +1,731 @@
+<template>
+ <el-dialog
+ v-model="dialogVisible"
+ title="裁剪动作序列图"
+ :close-on-click-modal="false"
+ destroy-on-close
+ class="crop-dialog"
+ align-center
+ >
+ <div class="crop-container">
+ <!-- 顶部文件夹区域 -->
+ <div class="folder-area">
+ <div
+ v-for="folder in folders"
+ :key="folder.type"
+ class="folder-item"
+ :class="{ 'drag-over': dragOverFolder === folder.type }"
+ @dragover.prevent="handleFolderDragOver(folder.type)"
+ @dragleave="handleFolderDragLeave"
+ @drop="handleFolderDrop($event, folder.type)"
+ >
+ <el-icon :size="20" class="folder-icon">
+ <Folder />
+ </el-icon>
+ <span class="folder-name">{{ folder.name }}</span>
+ <el-badge :value="folder.count" :hidden="folder.count === 0" />
+ </div>
+ </div>
+
+ <!-- 下方区域 -->
+ <div class="content-area">
+ <!-- 左侧裁剪区域 -->
+ <div class="crop-area">
+ <div class="crop-canvas-wrapper">
+ <cropper-canvas
+ ref="cropperCanvasRef"
+ background
+ class="cropper-canvas-element"
+ >
+ <cropper-image
+ v-if="imageUrl"
+ ref="cropperImageRef"
+ :src="imageUrl"
+ alt="crop"
+ rotatable
+ scalable
+ skewable
+ translatable
+ />
+ <cropper-shade hidden></cropper-shade>
+ <cropper-handle action="move" plain></cropper-handle>
+ <cropper-selection initial-coverage="0.8" movable resizable>
+ <cropper-grid role="grid" bordered covered></cropper-grid>
+ <cropper-crosshair centered></cropper-crosshair>
+ <cropper-handle
+ action="move"
+ theme-color="rgba(255, 255, 255, 0.35)"
+ ></cropper-handle>
+ <cropper-handle action="n-resize"></cropper-handle>
+ <cropper-handle action="e-resize"></cropper-handle>
+ <cropper-handle action="s-resize"></cropper-handle>
+ <cropper-handle action="w-resize"></cropper-handle>
+ <cropper-handle action="ne-resize"></cropper-handle>
+ <cropper-handle action="nw-resize"></cropper-handle>
+ <cropper-handle action="se-resize"></cropper-handle>
+ <cropper-handle action="sw-resize"></cropper-handle>
+ </cropper-selection>
+ </cropper-canvas>
+ </div>
+ <div class="crop-controls">
+ <el-button type="primary" @click="cropImage" :disabled="!canCrop">
+ 裁剪
+ </el-button>
+ <el-button @click="resetCrop">重置</el-button>
+ </div>
+ </div>
+
+ <!-- 右侧预览区域 -->
+ <div class="preview-area">
+ <div class="preview-title">
+ 已裁剪图片 ({{ croppedImages.length }})
+ </div>
+ <div class="preview-grid">
+ <div
+ v-for="(img, index) in croppedImages"
+ :key="index"
+ class="preview-item"
+ draggable="true"
+ @dragstart="handleImageDragStart($event, img, index)"
+ @dragend="handleImageDragEnd"
+ >
+ <img :src="img.url" alt="cropped" />
+ <div class="preview-overlay">
+ <el-icon
+ :size="16"
+ class="delete-icon"
+ @click="removeCroppedImage(index)"
+ >
+ <Close />
+ </el-icon>
+ </div>
+ <div v-if="img.frameType" class="frame-type-badge">
+ {{ getFrameTypeName(img.frameType) }}
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <template #footer>
+ <el-button @click="handleClose">取消</el-button>
+ <el-button type="primary" @click="handleSave" :loading="saving">
+ 保存
+ </el-button>
+ </template>
+ </el-dialog>
+</template>
+
+<script setup lang="ts">
+import { ref, computed, watch, nextTick, onMounted } from "vue";
+import { Folder, Close } from "@element-plus/icons-vue";
+import "cropperjs";
+
+interface CroppedImage {
+ url: string;
+ blob: Blob;
+ frameType?: string;
+}
+
+interface Props {
+ modelValue: boolean;
+ imageUrl?: string;
+}
+
+interface Emits {
+ (e: "update:modelValue", value: boolean): void;
+ (e: "save", images: { blob: Blob; frameType: string }[]): void;
+}
+
+const props = defineProps<Props>();
+const emit = defineEmits<Emits>();
+
+const dialogVisible = computed({
+ get: () => props.modelValue,
+ set: (val) => emit("update:modelValue", val),
+});
+
+const cropperCanvasRef = ref<any>();
+const cropperImageRef = ref<any>();
+const croppedImages = ref<CroppedImage[]>([]);
+const dragOverFolder = ref<string | null>(null);
+const draggingImageIndex = ref<number | null>(null);
+const saving = ref(false);
+
+const folders = computed(() => [
+ {
+ type: "first",
+ name: "首帧",
+ count: croppedImages.value.filter((img) => img.frameType === "first")
+ .length,
+ },
+ {
+ type: "last",
+ name: "尾帧",
+ count: croppedImages.value.filter((img) => img.frameType === "last").length,
+ },
+ {
+ type: "key",
+ name: "关键帧",
+ count: croppedImages.value.filter((img) => img.frameType === "key").length,
+ },
+]);
+
+const canCrop = computed(() => {
+ return (
+ cropperCanvasRef.value !== undefined && cropperImageRef.value !== undefined
+ );
+});
+watch(
+ () => props.modelValue,
+ (val) => {
+ if (val) {
+ nextTick(() => {
+ console.log("Dialog opened, canvas ref:", cropperCanvasRef.value);
+ console.log("Image ref:", cropperImageRef.value);
+ });
+ }
+ },
+);
+
+const cropImage = async () => {
+ if (!cropperCanvasRef.value) {
+ console.error("Cropper canvas not found");
+ return;
+ }
+
+ try {
+ // 使用 Web Components API 的 $toCanvas 方法获取裁剪后的画布
+ const selection = cropperCanvasRef.value.querySelector("cropper-selection");
+ if (!selection) {
+ console.error("Cropper selection not found");
+ return;
+ }
+
+ // 获取选区的 canvas
+ const canvas = await selection.$toCanvas();
+ if (!canvas) {
+ console.error("Failed to get canvas");
+ return;
+ }
+
+ // 转换为 Blob
+ canvas.toBlob((blob) => {
+ if (!blob) return;
+
+ const url = URL.createObjectURL(blob);
+ croppedImages.value.push({
+ url,
+ blob,
+ frameType: undefined,
+ });
+ console.log("Image cropped successfully");
+ });
+ } catch (error) {
+ console.error("Error cropping image:", error);
+ }
+};
+
+const resetCrop = () => {
+ if (cropperImageRef.value && cropperImageRef.value.$resetTransform) {
+ cropperImageRef.value.$resetTransform();
+ console.log("Crop reset");
+ }
+};
+
+const removeCroppedImage = (index: number) => {
+ const img = croppedImages.value[index];
+ URL.revokeObjectURL(img.url);
+ croppedImages.value.splice(index, 1);
+};
+
+const handleImageDragStart = (
+ event: DragEvent,
+ img: CroppedImage,
+ index: number,
+) => {
+ draggingImageIndex.value = index;
+ if (event.dataTransfer) {
+ event.dataTransfer.effectAllowed = "move";
+ }
+};
+
+const handleImageDragEnd = () => {
+ draggingImageIndex.value = null;
+ dragOverFolder.value = null;
+};
+
+const handleFolderDragOver = (folderType: string) => {
+ dragOverFolder.value = folderType;
+};
+
+const handleFolderDragLeave = () => {
+ dragOverFolder.value = null;
+};
+
+const handleFolderDrop = (event: DragEvent, folderType: string) => {
+ event.preventDefault();
+ dragOverFolder.value = null;
+
+ if (draggingImageIndex.value === null) return;
+
+ const img = croppedImages.value[draggingImageIndex.value];
+ img.frameType = folderType;
+ draggingImageIndex.value = null;
+};
+
+const getFrameTypeName = (type: string) => {
+ const map: Record<string, string> = {
+ first: "首帧",
+ last: "尾帧",
+ key: "关键帧",
+ };
+ return map[type] || type;
+};
+
+const handleClose = () => {
+ croppedImages.value.forEach((img) => {
+ URL.revokeObjectURL(img.url);
+ });
+ croppedImages.value = [];
+ dialogVisible.value = false;
+};
+
+const handleSave = () => {
+ const imagesToSave = croppedImages.value
+ .filter((img) => img.frameType)
+ .map((img) => ({
+ blob: img.blob,
+ frameType: img.frameType!,
+ }));
+
+ if (imagesToSave.length === 0) {
+ return;
+ }
+
+ emit("save", imagesToSave);
+ handleClose();
+};
+</script>
+
+<style scoped>
+.crop-dialog :deep(.el-dialog) {
+ width: 90vw;
+ max-width: 1600px;
+ height: 90vh;
+ margin: 0;
+ display: flex;
+ flex-direction: column;
+}
+
+.crop-dialog :deep(.el-dialog__body) {
+ padding: 16px;
+ flex: 1;
+ overflow: hidden;
+ display: flex;
+}
+
+.crop-container {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ gap: 20px;
+}
+
+.folder-area {
+ display: flex;
+ gap: 16px;
+ padding: 16px;
+ background: var(--bg-secondary);
+ border-radius: 8px;
+ border: 2px dashed var(--border-primary);
+}
+
+.folder-item {
+ flex: 1;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ padding: 16px;
+ background: var(--bg-primary);
+ border: 2px solid var(--border-primary);
+ border-radius: 8px;
+ cursor: pointer;
+ transition: all 0.3s;
+}
+
+.folder-item:hover {
+ border-color: var(--accent);
+ background: var(--bg-card);
+}
+
+.folder-item.drag-over {
+ border-color: var(--accent);
+ background: var(--accent-light);
+ transform: scale(1.05);
+}
+
+.folder-icon {
+ color: var(--accent);
+}
+
+.folder-name {
+ font-weight: 500;
+ color: var(--text-primary);
+}
+
+.content-area {
+ flex: 1;
+ display: flex;
+ gap: 20px;
+ min-height: 0;
+ overflow: hidden;
+}
+
+.crop-area {
+ flex: 1;
+ max-width: 550px;
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ border: 1px solid var(--border-primary);
+ border-radius: 8px;
+ padding: 16px;
+ background: var(--bg-primary);
+ min-height: 0;
+}
+
+.crop-title,
+.preview-title {
+ font-size: 14px;
+ font-weight: 600;
+ color: var(--text-primary);
+ margin-bottom: 8px;
+ flex-shrink: 0;
+}
+
+.crop-canvas-wrapper {
+ background: #000;
+ border-radius: 4px;
+ overflow: hidden;
+ width: 100%;
+ height: 500px;
+ position: relative;
+ flex: 1;
+ min-height: 400px;
+}
+
+.cropper-canvas-element {
+ width: 100%;
+ height: 100%;
+ display: block;
+}
+
+/* Cropper.js 基础样式 */
+.crop-canvas-wrapper :deep(.cropper-container) {
+ direction: ltr;
+ font-size: 0;
+ line-height: 0;
+ position: relative;
+ touch-action: none;
+ user-select: none;
+}
+
+.crop-canvas-wrapper :deep(.cropper-container img) {
+ display: block;
+ height: 100%;
+ image-orientation: 0deg;
+ max-height: none !important;
+ max-width: none !important;
+ min-height: 0 !important;
+ min-width: 0 !important;
+ width: 100%;
+}
+
+.crop-canvas-wrapper :deep(.cropper-wrap-box),
+.crop-canvas-wrapper :deep(.cropper-canvas),
+.crop-canvas-wrapper :deep(.cropper-drag-box),
+.crop-canvas-wrapper :deep(.cropper-crop-box),
+.crop-canvas-wrapper :deep(.cropper-modal) {
+ bottom: 0;
+ left: 0;
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+.crop-canvas-wrapper :deep(.cropper-drag-box) {
+ background-color: #fff;
+ opacity: 0;
+}
+
+.crop-canvas-wrapper :deep(.cropper-modal) {
+ background-color: #000;
+ opacity: 0.5;
+}
+
+.crop-canvas-wrapper :deep(.cropper-view-box) {
+ display: block;
+ height: 100%;
+ outline: 1px solid #39f;
+ outline-color: rgba(51, 153, 255, 0.75);
+ overflow: hidden;
+ width: 100%;
+}
+
+.crop-canvas-wrapper :deep(.cropper-dashed) {
+ border: 0 dashed #eee;
+ display: block;
+ opacity: 0.5;
+ position: absolute;
+}
+
+.crop-canvas-wrapper :deep(.cropper-dashed.dashed-h) {
+ border-bottom-width: 1px;
+ border-top-width: 1px;
+ height: calc(100% / 3);
+ left: 0;
+ top: calc(100% / 3);
+ width: 100%;
+}
+
+.crop-canvas-wrapper :deep(.cropper-dashed.dashed-v) {
+ border-left-width: 1px;
+ border-right-width: 1px;
+ height: 100%;
+ left: calc(100% / 3);
+ top: 0;
+ width: calc(100% / 3);
+}
+
+.crop-canvas-wrapper :deep(.cropper-center) {
+ display: block;
+ height: 0;
+ left: 50%;
+ opacity: 0.75;
+ position: absolute;
+ top: 50%;
+ width: 0;
+}
+
+.crop-canvas-wrapper :deep(.cropper-center::before),
+.crop-canvas-wrapper :deep(.cropper-center::after) {
+ background-color: #eee;
+ content: " ";
+ display: block;
+ position: absolute;
+}
+
+.crop-canvas-wrapper :deep(.cropper-center::before) {
+ height: 1px;
+ left: -3px;
+ top: 0;
+ width: 7px;
+}
+
+.crop-canvas-wrapper :deep(.cropper-center::after) {
+ height: 7px;
+ left: 0;
+ top: -3px;
+ width: 1px;
+}
+
+.crop-canvas-wrapper :deep(.cropper-face),
+.crop-canvas-wrapper :deep(.cropper-line),
+.crop-canvas-wrapper :deep(.cropper-point) {
+ display: block;
+ height: 100%;
+ opacity: 0.1;
+ position: absolute;
+ width: 100%;
+}
+
+.crop-canvas-wrapper :deep(.cropper-face) {
+ background-color: #fff;
+ left: 0;
+ top: 0;
+}
+
+.crop-canvas-wrapper :deep(.cropper-line) {
+ background-color: #39f;
+}
+
+.crop-canvas-wrapper :deep(.cropper-line.line-e) {
+ cursor: ew-resize;
+ right: -3px;
+ top: 0;
+ width: 5px;
+}
+
+.crop-canvas-wrapper :deep(.cropper-line.line-n) {
+ cursor: ns-resize;
+ height: 5px;
+ left: 0;
+ top: -3px;
+}
+
+.crop-canvas-wrapper :deep(.cropper-line.line-w) {
+ cursor: ew-resize;
+ left: -3px;
+ top: 0;
+ width: 5px;
+}
+
+.crop-canvas-wrapper :deep(.cropper-line.line-s) {
+ bottom: -3px;
+ cursor: ns-resize;
+ height: 5px;
+ left: 0;
+}
+
+.crop-canvas-wrapper :deep(.cropper-point) {
+ background-color: #39f;
+ height: 5px;
+ opacity: 0.75;
+ width: 5px;
+}
+
+.crop-canvas-wrapper :deep(.cropper-point.point-e) {
+ cursor: ew-resize;
+ margin-top: -3px;
+ right: -3px;
+ top: 50%;
+}
+
+.crop-canvas-wrapper :deep(.cropper-point.point-n) {
+ cursor: ns-resize;
+ left: 50%;
+ margin-left: -3px;
+ top: -3px;
+}
+
+.crop-canvas-wrapper :deep(.cropper-point.point-w) {
+ cursor: ew-resize;
+ left: -3px;
+ margin-top: -3px;
+ top: 50%;
+}
+
+.crop-canvas-wrapper :deep(.cropper-point.point-s) {
+ bottom: -3px;
+ cursor: s-resize;
+ left: 50%;
+ margin-left: -3px;
+}
+
+.crop-canvas-wrapper :deep(.cropper-point.point-ne) {
+ cursor: nesw-resize;
+ right: -3px;
+ top: -3px;
+}
+
+.crop-canvas-wrapper :deep(.cropper-point.point-nw) {
+ cursor: nwse-resize;
+ left: -3px;
+ top: -3px;
+}
+
+.crop-canvas-wrapper :deep(.cropper-point.point-sw) {
+ bottom: -3px;
+ cursor: nesw-resize;
+ left: -3px;
+}
+
+.crop-canvas-wrapper :deep(.cropper-point.point-se) {
+ bottom: -3px;
+ cursor: nwse-resize;
+ height: 20px;
+ opacity: 1;
+ right: -3px;
+ width: 20px;
+}
+
+.crop-controls {
+ display: flex;
+ gap: 8px;
+ justify-content: center;
+}
+
+.preview-area {
+ flex: 1;
+ min-width: 400px;
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ border: 1px solid var(--border-primary);
+ border-radius: 8px;
+ padding: 16px;
+ background: var(--bg-primary);
+ min-height: 0;
+}
+
+.preview-grid {
+ flex: 1;
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
+ gap: 12px;
+ overflow-y: auto;
+ align-content: start;
+}
+
+.preview-item {
+ position: relative;
+ aspect-ratio: 1;
+ border-radius: 8px;
+ overflow: hidden;
+ cursor: move;
+ border: 2px solid var(--border-primary);
+ transition: all 0.3s;
+}
+
+.preview-item:hover {
+ border-color: var(--accent);
+ transform: translateY(-2px);
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
+}
+
+.preview-item img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ display: block;
+}
+
+.preview-overlay {
+ position: absolute;
+ top: 0;
+ right: 0;
+ padding: 4px;
+ background: rgba(0, 0, 0, 0.6);
+ border-radius: 0 0 0 8px;
+ opacity: 0;
+ transition: opacity 0.3s;
+}
+
+.preview-item:hover .preview-overlay {
+ opacity: 1;
+}
+
+.delete-icon {
+ color: #fff;
+ cursor: pointer;
+}
+
+.delete-icon:hover {
+ color: #f56c6c;
+}
+
+.frame-type-badge {
+ position: absolute;
+ bottom: 4px;
+ left: 4px;
+ padding: 2px 8px;
+ background: var(--accent);
+ color: #fff;
+ font-size: 10px;
+ border-radius: 4px;
+ font-weight: 500;
+}
+</style>
diff --git a/web/src/components/common/ImagePreview.vue b/web/src/components/common/ImagePreview.vue
new file mode 100644
index 0000000..98be402
--- /dev/null
+++ b/web/src/components/common/ImagePreview.vue
@@ -0,0 +1,174 @@
+<template>
+ <div class="image-preview-wrapper">
+ <!-- 缩略图 -->
+ <div
+ class="thumbnail-container"
+ @click="handlePreview"
+ :class="{ 'has-image': hasImage }"
+ >
+ <img v-if="hasImage" :src="imageUrl" :alt="alt" class="thumbnail-image" />
+ <div v-else class="no-image-placeholder">
+ <el-icon :size="size / 2"><Picture /></el-icon>
+ <span v-if="showPlaceholderText">{{ placeholderText }}</span>
+ </div>
+ </div>
+
+ <!-- 放大预览对话框 -->
+ <el-dialog
+ v-model="previewVisible"
+ :width="dialogWidth"
+ align-center
+ :show-close="true"
+ class="image-preview-dialog"
+ @close="handleClose"
+ >
+ <template #header>
+ <div class="preview-header">
+ <span class="preview-title">{{ alt || "图片预览" }}</span>
+ </div>
+ </template>
+
+ <div class="preview-content">
+ <img :src="imageUrl" :alt="alt" class="preview-image" />
+ </div>
+ </el-dialog>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { ref, computed } from "vue";
+import { Picture } from "@element-plus/icons-vue";
+
+interface Props {
+ imageUrl?: string;
+ alt?: string;
+ size?: number;
+ placeholderText?: string;
+ showPlaceholderText?: boolean;
+ dialogWidth?: string;
+}
+
+const props = withDefaults(defineProps<Props>(), {
+ imageUrl: "",
+ alt: "",
+ size: 120,
+ placeholderText: "暂无图片",
+ showPlaceholderText: true,
+ dialogWidth: "800px",
+});
+
+const previewVisible = ref(false);
+
+const hasImage = computed(() => {
+ return props.imageUrl && props.imageUrl.trim() !== "";
+});
+
+const handlePreview = () => {
+ if (hasImage.value) {
+ previewVisible.value = true;
+ }
+};
+
+const handleClose = () => {
+ previewVisible.value = false;
+};
+</script>
+
+<style scoped>
+.image-preview-wrapper {
+ display: inline-block;
+ width: 100%;
+ height: 100%;
+}
+
+.thumbnail-container {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ overflow: hidden;
+ border-radius: var(--radius-md);
+ background: var(--bg-secondary);
+ transition: all var(--transition-fast);
+}
+
+.thumbnail-container.has-image {
+ cursor: pointer;
+}
+
+.thumbnail-container.has-image:hover {
+ transform: scale(1.05);
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
+}
+
+.thumbnail-image {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ display: block;
+}
+
+.no-image-placeholder {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ color: var(--text-muted);
+ padding: 16px;
+ text-align: center;
+}
+
+.no-image-placeholder span {
+ font-size: 12px;
+}
+
+/* 预览对话框样式 */
+.image-preview-dialog :deep(.el-dialog) {
+ border-radius: var(--radius-xl);
+ background: var(--bg-primary);
+}
+
+.image-preview-dialog :deep(.el-dialog__header) {
+ padding: 16px 20px;
+ border-bottom: 1px solid var(--border-primary);
+ margin-right: 0;
+}
+
+.image-preview-dialog :deep(.el-dialog__body) {
+ padding: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: #000;
+}
+
+.preview-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.preview-title {
+ font-size: 16px;
+ font-weight: 600;
+ color: var(--text-primary);
+}
+
+.preview-content {
+ width: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ min-height: 400px;
+ max-height: 80vh;
+}
+
+.preview-image {
+ max-width: 100%;
+ max-height: 80vh;
+ object-fit: contain;
+ display: block;
+}
+</style>
diff --git a/web/src/components/common/index.ts b/web/src/components/common/index.ts
index a9f62e4..cb03f33 100644
--- a/web/src/components/common/index.ts
+++ b/web/src/components/common/index.ts
@@ -13,6 +13,8 @@ export { default as EmptyState } from './EmptyState.vue'
export { default as ProjectCard } from './ProjectCard.vue'
export { default as ThemeToggle } from './ThemeToggle.vue'
export { default as ActionButton } from './ActionButton.vue'
+export { default as ImagePreview } from "./ImagePreview.vue";
+export { default as ImageCropDialog } from "./ImageCropDialog.vue";
// Dialog Components / 弹窗组件
export { default as CreateDramaDialog } from './CreateDramaDialog.vue'
@@ -20,4 +22,4 @@ export { default as AIConfigDialog } from './AIConfigDialog.vue'
// Layout Components / 布局组件
export { default as AppLayout } from './AppLayout.vue'
-export { default as AppHeader } from './AppHeader.vue'
+export { default as AppHeader } from './AppHeader.vue'
\ No newline at end of file
diff --git a/web/src/locales/zh-CN.ts b/web/src/locales/zh-CN.ts
index 4156e0d..eb51986 100644
--- a/web/src/locales/zh-CN.ts
+++ b/web/src/locales/zh-CN.ts
@@ -151,6 +151,19 @@ export default {
projectNamePlaceholder: '请输入项目名称',
projectDesc: '项目描述',
projectDescPlaceholder: '请输入项目描述(可选)',
+ style: '风格',
+ stylePlaceholder: '请选择风格',
+ styles: {
+ ghibli: '吉卜力',
+ guoman: '国漫',
+ wasteland: '末日废土',
+ nostalgia: '怀旧',
+ pixel: '像素艺术',
+ voxel: '方块世界',
+ urban: '都市',
+ guoman3d: '国漫3D',
+ chibi3d: 'Q版3D'
+ },
deleteConfirm: '确定要删除这个项目吗?',
noCover: '暂无封面',
noDescription: '暂无描述',
diff --git a/web/src/types/drama.ts b/web/src/types/drama.ts
index 7b9b91e..5056490 100644
--- a/web/src/types/drama.ts
+++ b/web/src/types/drama.ts
@@ -120,6 +120,7 @@ export interface CreateDramaRequest {
title: string
description?: string
genre?: string
+ style?: string
tags?: string
}
@@ -127,6 +128,7 @@ export interface UpdateDramaRequest {
title?: string
description?: string
genre?: string
+ style?: string
tags?: string
status?: DramaStatus
}
diff --git a/web/src/views/drama/DramaList.vue b/web/src/views/drama/DramaList.vue
index 06f0f93..103bb89 100644
--- a/web/src/views/drama/DramaList.vue
+++ b/web/src/views/drama/DramaList.vue
@@ -7,40 +7,69 @@
<AppHeader :fixed="false">
<template #left>
<div class="page-title">
- <h1>{{ $t('drama.title') }}</h1>
- <span class="subtitle">{{ $t('drama.totalProjects', { count: total }) }}</span>
+ <h1>{{ $t("drama.title") }}</h1>
+ <span class="subtitle">{{
+ $t("drama.totalProjects", { count: total })
+ }}</span>
</div>
</template>
<template #right>
- <el-button type="primary" @click="handleCreate" class="header-btn primary">
+ <el-button
+ type="primary"
+ @click="handleCreate"
+ class="header-btn primary"
+ >
<el-icon>
<Plus />
</el-icon>
- <span class="btn-text">{{ $t('drama.createNew') }}</span>
+ <span class="btn-text">{{ $t("drama.createNew") }}</span>
</el-button>
</template>
</AppHeader>
<!-- Project Grid / 项目网格 -->
- <div v-loading="loading" class="projects-grid" :class="{ 'is-empty': !loading && dramas.length === 0 }">
+ <div
+ v-loading="loading"
+ class="projects-grid"
+ :class="{ 'is-empty': !loading && dramas.length === 0 }"
+ >
<!-- Empty state / 空状态 -->
- <EmptyState v-if="!loading && dramas.length === 0" :title="$t('drama.empty')"
- :description="$t('drama.emptyHint')" :icon="Film">
+ <EmptyState
+ v-if="!loading && dramas.length === 0"
+ :title="$t('drama.empty')"
+ :description="$t('drama.emptyHint')"
+ :icon="Film"
+ >
<el-button type="primary" @click="handleCreate">
<el-icon>
<Plus />
</el-icon>
- {{ $t('drama.createNew') }}
+ {{ $t("drama.createNew") }}
</el-button>
</EmptyState>
<!-- Project Cards / 项目卡片列表 -->
- <ProjectCard v-for="drama in dramas" :key="drama.id" :title="drama.title" :description="drama.description"
- :updated-at="drama.updated_at" :episode-count="drama.total_episodes || 0" @click="viewDrama(drama.id)">
+ <ProjectCard
+ v-for="drama in dramas"
+ :key="drama.id"
+ :title="drama.title"
+ :description="drama.description"
+ :updated-at="drama.updated_at"
+ :episode-count="drama.total_episodes || 0"
+ @click="viewDrama(drama.id)"
+ >
<template #actions>
- <ActionButton :icon="Edit" :tooltip="$t('common.edit')" @click="editDrama(drama.id)" />
- <el-popconfirm :title="$t('drama.deleteConfirm')" :confirm-button-text="$t('common.confirm')"
- :cancel-button-text="$t('common.cancel')" @confirm="deleteDrama(drama.id)">
+ <ActionButton
+ :icon="Edit"
+ :tooltip="$t('common.edit')"
+ @click="editDrama(drama.id)"
+ />
+ <el-popconfirm
+ :title="$t('drama.deleteConfirm')"
+ :confirm-button-text="$t('common.confirm')"
+ :cancel-button-text="$t('common.cancel')"
+ @confirm="deleteDrama(drama.id)"
+ >
<template #reference>
<el-button :icon="Delete" class="action-button danger" link />
</template>
@@ -50,22 +79,75 @@
</div>
<!-- Edit Dialog / 编辑对话框 -->
- <el-dialog v-model="editDialogVisible" :title="$t('drama.editProject')" width="520px"
- :close-on-click-modal="false" class="edit-dialog">
- <el-form :model="editForm" label-position="top" v-loading="editLoading" class="edit-form">
+ <el-dialog
+ v-model="editDialogVisible"
+ :title="$t('drama.editProject')"
+ width="520px"
+ :close-on-click-modal="false"
+ class="edit-dialog"
+ >
+ <el-form
+ :model="editForm"
+ label-position="top"
+ v-loading="editLoading"
+ class="edit-form"
+ >
<el-form-item :label="$t('drama.projectName')" required>
- <el-input v-model="editForm.title" :placeholder="$t('drama.projectNamePlaceholder')" size="large" />
+ <el-input
+ v-model="editForm.title"
+ :placeholder="$t('drama.projectNamePlaceholder')"
+ size="large"
+ />
</el-form-item>
<el-form-item :label="$t('drama.projectDesc')">
- <el-input v-model="editForm.description" type="textarea" :rows="4"
- :placeholder="$t('drama.projectDescPlaceholder')" resize="none" />
+ <el-input
+ v-model="editForm.description"
+ type="textarea"
+ :rows="4"
+ :placeholder="$t('drama.projectDescPlaceholder')"
+ resize="none"
+ />
+ </el-form-item>
+ <el-form-item :label="$t('drama.style')" required>
+ <el-select
+ v-model="editForm.style"
+ :placeholder="$t('drama.stylePlaceholder')"
+ size="large"
+ style="width: 100%"
+ >
+ <el-option :label="$t('drama.styles.ghibli')" value="ghibli" />
+ <el-option :label="$t('drama.styles.guoman')" value="guoman" />
+ <el-option
+ :label="$t('drama.styles.wasteland')"
+ value="wasteland"
+ />
+ <el-option
+ :label="$t('drama.styles.nostalgia')"
+ value="nostalgia"
+ />
+ <el-option :label="$t('drama.styles.pixel')" value="pixel" />
+ <el-option :label="$t('drama.styles.voxel')" value="voxel" />
+ <el-option :label="$t('drama.styles.urban')" value="urban" />
+ <el-option
+ :label="$t('drama.styles.guoman3d')"
+ value="guoman3d"
+ />
+ <el-option :label="$t('drama.styles.chibi3d')" value="chibi3d" />
+ </el-select>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
- <el-button @click="editDialogVisible = false" size="large">{{ $t('common.cancel') }}</el-button>
- <el-button type="primary" @click="saveEdit" :loading="editLoading" size="large">
- {{ $t('common.save') }}
+ <el-button @click="editDialogVisible = false" size="large">{{
+ $t("common.cancel")
+ }}</el-button>
+ <el-button
+ type="primary"
+ @click="saveEdit"
+ :loading="editLoading"
+ size="large"
+ >
+ {{ $t("common.save") }}
</el-button>
</div>
</template>
@@ -73,23 +155,36 @@
<!-- Create Drama Dialog / 创建短剧弹窗 -->
<CreateDramaDialog v-model="createDialogVisible" @created="loadDramas" />
-
</div>
<!-- Sticky Pagination / 吸底分页器 -->
<div v-if="total > 0" class="pagination-sticky">
<div class="pagination-inner">
<div class="pagination-info">
- <span class="pagination-total">{{ $t('drama.totalProjects', { count: total }) }}</span>
+ <span class="pagination-total">{{
+ $t("drama.totalProjects", { count: total })
+ }}</span>
</div>
<div class="pagination-controls">
- <el-pagination v-model:current-page="queryParams.page" v-model:page-size="queryParams.page_size"
- :total="total" :page-sizes="[12, 24, 36, 48]" :pager-count="5" layout="prev, pager, next"
- @size-change="loadDramas" @current-change="loadDramas" />
+ <el-pagination
+ v-model:current-page="queryParams.page"
+ v-model:page-size="queryParams.page_size"
+ :total="total"
+ :page-sizes="[12, 24, 36, 48]"
+ :pager-count="5"
+ layout="prev, pager, next"
+ @size-change="loadDramas"
+ @current-change="loadDramas"
+ />
</div>
<div class="pagination-size">
- <span class="size-label">{{ $t('common.perPage') }}</span>
- <el-select v-model="queryParams.page_size" size="small" class="size-select" @change="loadDramas">
+ <span class="size-label">{{ $t("common.perPage") }}</span>
+ <el-select
+ v-model="queryParams.page_size"
+ size="small"
+ class="size-select"
+ @change="loadDramas"
+ >
<el-option :value="12" label="12" />
<el-option :value="24" label="24" />
<el-option :value="36" label="36" />
@@ -102,9 +197,9 @@
</template>
<script setup lang="ts">
-import { ref, onMounted } from 'vue'
-import { useRouter } from 'vue-router'
-import { ElMessage } from 'element-plus'
+import { ref, onMounted } from "vue";
+import { useRouter } from "vue-router";
+import { ElMessage } from "element-plus";
import {
Plus,
Film,
@@ -112,108 +207,117 @@ import {
Edit,
View,
Delete,
- InfoFilled
-} from '@element-plus/icons-vue'
-import { dramaAPI } from '@/api/drama'
-import type { Drama, DramaListQuery } from '@/types/drama'
-import { AppHeader, ProjectCard, ActionButton, CreateDramaDialog, EmptyState } from '@/components/common'
-
-const router = useRouter()
-const loading = ref(false)
-const dramas = ref<Drama[]>([])
-const total = ref(0)
+ InfoFilled,
+} from "@element-plus/icons-vue";
+import { dramaAPI } from "@/api/drama";
+import type { Drama, DramaListQuery } from "@/types/drama";
+import {
+ AppHeader,
+ ProjectCard,
+ ActionButton,
+ CreateDramaDialog,
+ EmptyState,
+} from "@/components/common";
+
+const router = useRouter();
+const loading = ref(false);
+const dramas = ref<Drama[]>([]);
+const total = ref(0);
const queryParams = ref<DramaListQuery>({
page: 1,
- page_size: 12
-})
+ page_size: 12,
+});
// Create dialog state / 创建弹窗状态
-const createDialogVisible = ref(false)
+const createDialogVisible = ref(false);
// Load drama list / 加载短剧列表
const loadDramas = async () => {
- loading.value = true
+ loading.value = true;
try {
- const res = await dramaAPI.list(queryParams.value)
- dramas.value = res.items || []
- total.value = res.pagination?.total || 0
+ const res = await dramaAPI.list(queryParams.value);
+ dramas.value = res.items || [];
+ total.value = res.pagination?.total || 0;
} catch (error: any) {
- ElMessage.error(error.message || '加载失败')
+ ElMessage.error(error.message || "加载失败");
} finally {
- loading.value = false
+ loading.value = false;
}
-}
+};
// Navigation handlers / 导航处理
-const handleCreate = () => createDialogVisible.value = true
-const viewDrama = (id: string) => router.push(`/dramas/${id}`)
+const handleCreate = () => (createDialogVisible.value = true);
+const viewDrama = (id: string) => router.push(`/dramas/${id}`);
// Edit dialog state / 编辑对话框状态
-const editDialogVisible = ref(false)
-const editLoading = ref(false)
+const editDialogVisible = ref(false);
+const editLoading = ref(false);
const editForm = ref({
- id: '',
- title: '',
- description: ''
-})
+ id: "",
+ title: "",
+ description: "",
+ style: "ghibli",
+});
// Open edit dialog / 打开编辑对话框
const editDrama = async (id: string) => {
- editLoading.value = true
- editDialogVisible.value = true
+ editLoading.value = true;
+ editDialogVisible.value = true;
try {
- const drama = await dramaAPI.get(id)
+ const drama = await dramaAPI.get(id);
editForm.value = {
id: drama.id,
title: drama.title,
- description: drama.description || ''
- }
+ description: drama.description || "",
+ style: drama.style || "ghibli",
+ };
} catch (error: any) {
- ElMessage.error(error.message || '加载失败')
- editDialogVisible.value = false
+ ElMessage.error(error.message || "加载失败");
+ editDialogVisible.value = false;
} finally {
- editLoading.value = false
+ editLoading.value = false;
}
-}
+};
// Save edit changes / 保存编辑更改
const saveEdit = async () => {
if (!editForm.value.title) {
- ElMessage.warning('请输入项目名称')
- return
+ ElMessage.warning("请输入项目名称");
+ return;
}
- editLoading.value = true
+ editLoading.value = true;
try {
await dramaAPI.update(editForm.value.id, {
title: editForm.value.title,
- description: editForm.value.description
- })
- ElMessage.success('保存成功')
- editDialogVisible.value = false
- loadDramas()
+ description: editForm.value.description,
+ style: editForm.value.style,
+ });
+ ElMessage.success("保存成功");
+ editDialogVisible.value = false;
+ loadDramas();
} catch (error: any) {
- ElMessage.error(error.message || '保存失败')
+ ElMessage.error(error.message || "保存失败");
} finally {
- editLoading.value = false
+ editLoading.value = false;
}
-}
+};
// Delete drama / 删除短剧
const deleteDrama = async (id: string) => {
try {
- await dramaAPI.delete(id)
- ElMessage.success('删除成功')
- loadDramas()
+ await dramaAPI.delete(id);
+ ElMessage.success("删除成功");
+ loadDramas();
} catch (error: any) {
- ElMessage.error(error.message || '删除失败')
+ ElMessage.error(error.message || "删除失败");
}
-}
+};
onMounted(() => {
- loadDramas()
-})
+ loadDramas();
+});
</script>
<style scoped>
diff --git a/web/src/views/drama/DramaManagement.vue b/web/src/views/drama/DramaManagement.vue
index 0391576..5e424eb 100644
--- a/web/src/views/drama/DramaManagement.vue
+++ b/web/src/views/drama/DramaManagement.vue
@@ -233,10 +233,11 @@
>
<el-card shadow="hover" class="character-card">
<div class="character-preview">
- <img
+ <ImagePreview
v-if="character.local_path || character.image_url"
- :src="getImageUrl(character)"
+ :image-url="getImageUrl(character)"
:alt="character.name"
+ :size="120"
/>
<el-avatar v-else :size="120">{{
character.name[0]
@@ -244,19 +245,21 @@
</div>
<div class="character-info">
- <h4>{{ character.name }}</h4>
- <el-tag
- :type="character.role === 'main' ? 'danger' : 'info'"
- size="small"
- >
- {{
- character.role === "main"
- ? "Main"
- : character.role === "supporting"
- ? "Supporting"
- : "Minor"
- }}
- </el-tag>
+ <div class="character-name">
+ <h4>{{ character.name }}</h4>
+ <el-tag
+ :type="character.role === 'main' ? 'danger' : 'info'"
+ size="small"
+ >
+ {{
+ character.role === "main"
+ ? "Main"
+ : character.role === "supporting"
+ ? "Supporting"
+ : "Minor"
+ }}
+ </el-tag>
+ </div>
<p class="desc">
{{ character.appearance || character.description }}
</p>
@@ -298,14 +301,12 @@
<el-col :span="6" v-for="scene in scenes" :key="scene.id">
<el-card shadow="hover" class="scene-card">
<div class="scene-preview">
- <img
- v-if="scene.local_path || scene.image_url"
- :src="getImageUrl(scene)"
- :alt="scene.name"
+ <ImagePreview
+ :image-url="getImageUrl(scene)"
+ :alt="scene.location + ' - ' + scene.time"
+ :size="120"
+ :show-placeholder-text="false"
/>
- <div v-else class="scene-placeholder">
- <el-icon :size="48"><Picture /></el-icon>
- </div>
</div>
<div class="scene-info">
@@ -360,14 +361,12 @@
<el-col :span="6" v-for="prop in drama?.props" :key="prop.id">
<el-card shadow="hover" class="scene-card">
<div class="scene-preview">
- <img
- v-if="hasImage(prop)"
- :src="getImageUrl(prop)"
+ <ImagePreview
+ :image-url="getImageUrl(prop)"
:alt="prop.name"
+ :size="120"
+ :show-placeholder-text="false"
/>
- <div v-else class="scene-placeholder">
- <el-icon :size="48"><Box /></el-icon>
- </div>
</div>
<div class="scene-info">
@@ -784,7 +783,12 @@ import { dramaAPI } from "@/api/drama";
import { characterLibraryAPI } from "@/api/character-library";
import { propAPI } from "@/api/prop";
import type { Drama } from "@/types/drama";
-import { AppHeader, StatCard, EmptyState } from "@/components/common";
+import {
+ AppHeader,
+ StatCard,
+ EmptyState,
+ ImagePreview,
+} from "@/components/common";
import { getImageUrl, hasImage } from "@/utils/image";
const router = useRouter();
@@ -1596,9 +1600,16 @@ onMounted(() => {
padding: var(--space-4);
}
+.character-name {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ gap: var(--space-2);
+}
+
.character-info h4,
.scene-info h4 {
- margin: 0 0 var(--space-2) 0;
+ /* margin: 0 0 var(--space-2) 0; */
font-size: 1rem;
font-weight: 600;
color: var(--text-primary);
diff --git a/web/src/views/drama/ProfessionalEditor.vue b/web/src/views/drama/ProfessionalEditor.vue
index 155dd11..249d7e4 100644
--- a/web/src/views/drama/ProfessionalEditor.vue
+++ b/web/src/views/drama/ProfessionalEditor.vue
@@ -1,7 +1,11 @@
<template>
<div class="professional-editor">
<!-- 顶部工具栏 -->
- <AppHeader :fixed="false" :show-logo="false" @config-updated="loadVideoModels">
+ <AppHeader
+ :fixed="false"
+ :show-logo="false"
+ @config-updated="loadVideoModels"
+ >
<template #left>
<el-button text @click="goBack" class="back-btn">
<el-icon>
@@ -9,8 +13,10 @@
</el-icon>
<span>{{ $t("editor.backToEpisode") }}</span>
</el-button>
- <span class="episode-title">{{ drama?.title }} -
- {{ $t("editor.episode", { number: episodeNumber }) }}</span>
+ <span class="episode-title"
+ >{{ drama?.title }} -
+ {{ $t("editor.episode", { number: episodeNumber }) }}</span
+ >
</template>
</AppHeader>
@@ -22,12 +28,17 @@
<h3>{{ $t("storyboard.scriptStructure") }}</h3>
<el-button text :icon="Plus" @click="handleAddStoryboard">{{
$t("storyboard.add")
- }}</el-button>
+ }}</el-button>
</div>
<div class="storyboard-list">
- <div v-for="(shot, index) in storyboards" :key="shot.id" class="storyboard-item"
- :class="{ active: currentStoryboardId === shot.id }" @click="selectStoryboard(shot.id)">
+ <div
+ v-for="(shot, index) in storyboards"
+ :key="shot.id"
+ class="storyboard-item"
+ :class="{ active: currentStoryboardId === shot.id }"
+ @click="selectStoryboard(shot.id)"
+ >
<div class="shot-content">
<div class="shot-header">
<div class="shot-title-row">
@@ -38,12 +49,17 @@
}}</span>
<span class="shot-title">{{
shot.title || $t("storyboard.untitled")
- }}</span>
+ }}</span>
</div>
<div class="shot-actions">
<span class="shot-duration">{{ shot.duration }}s</span>
- <el-button link type="danger" :icon="Delete" @click.stop="handleDeleteStoryboard(shot)"
- class="delete-btn" />
+ <el-button
+ link
+ type="danger"
+ :icon="Delete"
+ @click.stop="handleDeleteStoryboard(shot)"
+ class="delete-btn"
+ />
</div>
</div>
<div class="shot-action" v-if="shot.action">
@@ -56,28 +72,55 @@
<!-- 中间时间线编辑区域 -->
<div class="timeline-area">
- <VideoTimelineEditor ref="timelineEditorRef" v-if="storyboards.length > 0" :scenes="storyboards"
- :episode-id="episodeId.toString()" :drama-id="dramaId.toString()" :assets="videoAssets"
- @select-scene="handleTimelineSelect" @asset-deleted="loadVideoAssets"
- @merge-completed="handleMergeCompleted" />
- <el-empty v-else :description="$t('storyboard.noStoryboard')" class="empty-timeline" />
+ <VideoTimelineEditor
+ ref="timelineEditorRef"
+ v-if="storyboards.length > 0"
+ :scenes="storyboards"
+ :episode-id="episodeId.toString()"
+ :drama-id="dramaId.toString()"
+ :assets="videoAssets"
+ @select-scene="handleTimelineSelect"
+ @asset-deleted="loadVideoAssets"
+ @merge-completed="handleMergeCompleted"
+ />
+ <el-empty
+ v-else
+ :description="$t('storyboard.noStoryboard')"
+ class="empty-timeline"
+ />
</div>
<!-- 右侧编辑面板 -->
<div class="edit-panel">
<el-tabs v-model="activeTab" class="edit-tabs">
<!-- 镜头属性标签 -->
- <el-tab-pane :label="$t('storyboard.shotProperties')" name="shot" v-if="currentStoryboard">
+ <el-tab-pane
+ :label="$t('storyboard.shotProperties')"
+ name="shot"
+ v-if="currentStoryboard"
+ >
<div v-if="currentStoryboard" class="shot-editor-new">
<!-- 场景(Scene) -->
<div class="scene-section">
<div class="section-label">
{{ $t("storyboard.scene") }} (Scene)
- <el-button size="small" text @click="showSceneSelector = true">{{ $t("storyboard.selectScene")
- }}</el-button>
+ <el-button
+ size="small"
+ text
+ @click="showSceneSelector = true"
+ >{{ $t("storyboard.selectScene") }}</el-button
+ >
</div>
- <div class="scene-preview" v-if="hasImage(currentStoryboard.background)" @click="showSceneImage">
- <img :src="getImageUrl(currentStoryboard.background)" alt="场景" style="cursor: pointer" />
+ <div
+ class="scene-preview"
+ v-if="hasImage(currentStoryboard.background)"
+ @click="showSceneImage"
+ >
+ <img
+ :src="getImageUrl(currentStoryboard.background)"
+ alt="场景"
+ style="cursor: pointer"
+ />
<div class="scene-info">
<div>
{{ currentStoryboard.background.location }} ·
@@ -107,27 +150,46 @@
<div class="cast-section">
<div class="section-label">
{{ $t("editor.cast") }} (Cast)
- <el-button size="small" text :icon="Plus" @click="showCharacterSelector = true">{{
- $t("editor.addCharacter") }}</el-button>
+ <el-button
+ size="small"
+ text
+ :icon="Plus"
+ @click="showCharacterSelector = true"
+ >{{ $t("editor.addCharacter") }}</el-button
+ >
</div>
<div class="cast-list">
- <div v-for="char in currentStoryboardCharacters" :key="char.id" class="cast-item active">
+ <div
+ v-for="char in currentStoryboardCharacters"
+ :key="char.id"
+ class="cast-item active"
+ >
<div class="cast-avatar" @click="showCharacterImage(char)">
- <img v-if="hasImage(char)" :src="getImageUrl(char)" :alt="char.name" />
+ <img
+ v-if="hasImage(char)"
+ :src="getImageUrl(char)"
+ :alt="char.name"
+ />
<span v-else>{{ char.name?.[0] || "?" }}</span>
</div>
<div class="cast-name">{{ char.name }}</div>
- <div class="cast-remove" @click.stop="toggleCharacterInShot(char.id)"
- :title="$t('editor.removeCharacter')">
+ <div
+ class="cast-remove"
+ @click.stop="toggleCharacterInShot(char.id)"
+ :title="$t('editor.removeCharacter')"
+ >
<el-icon :size="14">
<Close />
</el-icon>
</div>
</div>
- <div v-if="
- !currentStoryboard?.characters ||
- currentStoryboard.characters.length === 0
- " class="cast-empty">
+ <div
+ v-if="
+ !currentStoryboard?.characters ||
+ currentStoryboard.characters.length === 0
+ "
+ class="cast-empty"
+ >
{{ $t("editor.noCharacters") }}
</div>
</div>
@@ -137,28 +199,48 @@
<div class="cast-section">
<div class="section-label">
{{ $t("editor.props") }} (Props)
- <el-button size="small" text :icon="Plus" @click="showPropSelector = true">{{ $t("editor.addProp")
- }}</el-button>
+ <el-button
+ size="small"
+ text
+ :icon="Plus"
+ @click="showPropSelector = true"
+ >{{ $t("editor.addProp") }}</el-button
+ >
</div>
<div class="cast-list">
- <div v-for="prop in currentStoryboardProps" :key="prop.id" class="cast-item active">
+ <div
+ v-for="prop in currentStoryboardProps"
+ :key="prop.id"
+ class="cast-item active"
+ >
<div class="cast-avatar">
- <img v-if="hasImage(prop)" :src="getImageUrl(prop)" :alt="prop.name" />
+ <img
+ v-if="hasImage(prop)"
+ :src="getImageUrl(prop)"
+ :alt="prop.name"
+ />
<el-icon v-else>
<Box />
</el-icon>
</div>
<div class="cast-name">{{ prop.name }}</div>
- <div class="cast-remove" @click.stop="togglePropInShot(prop.id)" title="移除道具">
+ <div
+ class="cast-remove"
+ @click.stop="togglePropInShot(prop.id)"
+ title="移除道具"
+ >
<el-icon :size="14">
<Close />
</el-icon>
</div>
</div>
- <div v-if="
- !currentStoryboardProps ||
- currentStoryboardProps.length === 0
- " class="cast-empty">
+ <div
+ v-if="
+ !currentStoryboardProps ||
+ currentStoryboardProps.length === 0
+ "
+ class="cast-empty"
+ >
{{ $t("editor.noProps") }}
</div>
</div>
@@ -172,8 +254,12 @@
<div class="settings-grid">
<div class="setting-item">
<label>{{ $t("editor.shotType") }}</label>
- <el-select v-model="currentStoryboard.shot_type" clearable
- :placeholder="$t('editor.shotTypePlaceholder')" @change="saveStoryboardField('shot_type')">
+ <el-select
+ v-model="currentStoryboard.shot_type"
+ clearable
+ :placeholder="$t('editor.shotTypePlaceholder')"
+ @change="saveStoryboardField('shot_type')"
+ >
<el-option label="大远景" value="大远景" />
<el-option label="远景" value="远景" />
<el-option label="全景" value="全景" />
@@ -188,8 +274,12 @@
<div class="setting-item">
<label>{{ $t("editor.movement") }}</label>
- <el-select v-model="currentStoryboard.movement" clearable
- :placeholder="$t('editor.movementPlaceholder')" @change="saveStoryboardField('movement')">
+ <el-select
+ v-model="currentStoryboard.movement"
+ clearable
+ :placeholder="$t('editor.movementPlaceholder')"
+ @change="saveStoryboardField('movement')"
+ >
<el-option label="固定镜头" value="固定镜头" />
<el-option label="推镜" value="推镜" />
<el-option label="拉镜" value="拉镜" />
@@ -209,17 +299,27 @@
<div class="setting-item">
<label>{{ $t("editor.angle") }}</label>
- <el-select v-model="currentStoryboard.angle" clearable :placeholder="$t('editor.anglePlaceholder')"
- @change="saveStoryboardField('angle')">
+ <el-select
+ v-model="currentStoryboard.angle"
+ clearable
+ :placeholder="$t('editor.anglePlaceholder')"
+ @change="saveStoryboardField('angle')"
+ >
<el-option label="平视" value="平视" />
<el-option label="俯视" value="俯视" />
<el-option label="仰视" value="仰视" />
- <el-option label="大俯视(鸟瞰)" value="大俯视(鸟瞰)" />
+ <el-option
+ label="大俯视(鸟瞰)"
+ value="大俯视(鸟瞰)"
+ />
<el-option label="大仰视" value="大仰视" />
<el-option label="正侧面" value="正侧面" />
<el-option label="斜侧面" value="斜侧面" />
<el-option label="背面" value="背面" />
- <el-option label="倾斜(荷兰角)" value="倾斜(荷兰角)" />
+ <el-option
+ label="倾斜(荷兰角)"
+ value="倾斜(荷兰角)"
+ />
<el-option label="主观视角" value="主观视角" />
<el-option label="过肩" value="过肩" />
</el-select>
@@ -232,40 +332,66 @@
<div class="section-label">
{{ $t("editor.action") }} (Action)
</div>
- <el-input v-model="currentStoryboard.action" type="textarea" :rows="3"
- :placeholder="$t('editor.actionPlaceholder')" @blur="saveStoryboardField('action')" />
+ <el-input
+ v-model="currentStoryboard.action"
+ type="textarea"
+ :rows="3"
+ :placeholder="$t('editor.actionPlaceholder')"
+ @blur="saveStoryboardField('action')"
+ />
</div>
<div class="narrative-section">
<div class="section-label">
{{ $t("editor.result") }} (Result)
</div>
- <el-input v-model="currentStoryboard.result" type="textarea" :rows="2"
- :placeholder="$t('editor.resultPlaceholder')" @blur="saveStoryboardField('result')" />
+ <el-input
+ v-model="currentStoryboard.result"
+ type="textarea"
+ :rows="2"
+ :placeholder="$t('editor.resultPlaceholder')"
+ @blur="saveStoryboardField('result')"
+ />
</div>
<div class="dialogue-section">
<div class="section-label">
{{ $t("editor.dialogue") }} (Dialogue)
</div>
- <el-input v-model="currentStoryboard.dialogue" type="textarea" :rows="3"
- :placeholder="$t('editor.dialoguePlaceholder')" @blur="saveStoryboardField('dialogue')" />
+ <el-input
+ v-model="currentStoryboard.dialogue"
+ type="textarea"
+ :rows="3"
+ :placeholder="$t('editor.dialoguePlaceholder')"
+ @blur="saveStoryboardField('dialogue')"
+ />
</div>
<div class="narrative-section">
<div class="section-label">
{{ $t("editor.description") }} (Description)
</div>
- <el-input v-model="currentStoryboard.description" type="textarea" :rows="3"
- :placeholder="$t('editor.descriptionPlaceholder')" @blur="saveStoryboardField('description')" />
+ <el-input
+ v-model="currentStoryboard.description"
+ type="textarea"
+ :rows="3"
+ :placeholder="$t('editor.descriptionPlaceholder')"
+ @blur="saveStoryboardField('description')"
+ />
</div>
<!-- 音效设置 -->
<div class="settings-section">
<div class="section-label">{{ $t("editor.soundEffects") }}</div>
<div class="audio-controls">
- <el-input v-model="currentStoryboard.sound_effect" :placeholder="$t('editor.soundEffectsPlaceholder')"
- size="small" type="textarea" :rows="2" @blur="saveStoryboardField('sound_effect')" />
+ <el-input
+ v-model="currentStoryboard.sound_effect"
+ :placeholder="$t('editor.soundEffectsPlaceholder')"
+ size="small"
+ type="textarea"
+ :rows="2"
+ @blur="saveStoryboardField('sound_effect')"
+ />
</div>
</div>
@@ -273,8 +399,14 @@
<div class="settings-section">
<div class="section-label">{{ $t("editor.bgmPrompt") }}</div>
<div class="audio-controls">
- <el-input v-model="currentStoryboard.bgm_prompt" :placeholder="$t('editor.bgmPromptPlaceholder')"
- size="small" type="textarea" :rows="2" @blur="saveStoryboardField('bgm_prompt')" />
+ <el-input
+ v-model="currentStoryboard.bgm_prompt"
+ :placeholder="$t('editor.bgmPromptPlaceholder')"
+ size="small"
+ type="textarea"
+ :rows="2"
+ @blur="saveStoryboardField('bgm_prompt')"
+ />
</div>
</div>
@@ -282,8 +414,14 @@
<div class="settings-section">
<div class="section-label">{{ $t("editor.atmosphere") }}</div>
<div class="audio-controls">
- <el-input v-model="currentStoryboard.atmosphere" :placeholder="$t('editor.atmospherePlaceholder')"
- size="small" type="textarea" :rows="2" @blur="saveStoryboardField('atmosphere')" />
+ <el-input
+ v-model="currentStoryboard.atmosphere"
+ :placeholder="$t('editor.atmospherePlaceholder')"
+ size="small"
+ type="textarea"
+ :rows="2"
+ @blur="saveStoryboardField('atmosphere')"
+ />
</div>
</div>
</div>
@@ -302,50 +440,78 @@
<el-radio-group v-model="selectedFrameType" size="small">
<el-radio-button label="first">{{
$t("editor.firstFrame")
- }}</el-radio-button>
+ }}</el-radio-button>
<el-radio-button label="last">{{
$t("editor.lastFrame")
- }}</el-radio-button>
+ }}</el-radio-button>
<el-radio-button label="panel">{{
$t("editor.panelFrame")
- }}</el-radio-button>
+ }}</el-radio-button>
<el-radio-button label="action">{{
$t("editor.actionSequence")
- }}</el-radio-button>
+ }}</el-radio-button>
<el-radio-button label="key">{{
$t("editor.keyFrame")
- }}</el-radio-button>
+ }}</el-radio-button>
</el-radio-group>
- <el-input-number v-if="selectedFrameType === 'panel'" v-model="panelCount" :min="2" :max="6"
- size="small" class="panel-count-input" style="margin-left: 10px; margin-top: 12px" />
- <span v-if="selectedFrameType === 'panel'" class="panel-count-label">{{ $t("editor.panelCount")
- }}</span>
+ <el-input-number
+ v-if="selectedFrameType === 'panel'"
+ v-model="panelCount"
+ :min="2"
+ :max="6"
+ size="small"
+ class="panel-count-input"
+ style="margin-left: 10px; margin-top: 12px"
+ />
+ <span
+ v-if="selectedFrameType === 'panel'"
+ class="panel-count-label"
+ >{{ $t("editor.panelCount") }}</span
+ >
</div>
<!-- 提示词区域 -->
<div class="prompt-section">
<div class="section-label">
{{ $t("editor.prompt") }}
- <el-button size="small" type="primary" :disabled="isGeneratingPrompt(
- currentStoryboard?.id,
- selectedFrameType,
- )
- " :loading="isGeneratingPrompt(
- currentStoryboard?.id,
- selectedFrameType,
- )
- " @click="extractFramePrompt" style="margin-left: 10px">
+ <el-button
+ size="small"
+ type="primary"
+ :disabled="
+ isGeneratingPrompt(
+ currentStoryboard?.id,
+ selectedFrameType,
+ )
+ "
+ :loading="
+ isGeneratingPrompt(
+ currentStoryboard?.id,
+ selectedFrameType,
+ )
+ "
+ @click="extractFramePrompt"
+ style="margin-left: 10px"
+ >
{{ $t("editor.extractPrompt") }}
</el-button>
</div>
- <el-input v-model="currentFramePrompt" type="textarea" :rows="8"
- :placeholder="$t('editor.promptPlaceholder')" />
+ <el-input
+ v-model="currentFramePrompt"
+ type="textarea"
+ :rows="8"
+ :placeholder="$t('editor.promptPlaceholder')"
+ />
</div>
<!-- 生成控制 -->
<div class="generation-controls">
- <el-button type="success" :icon="MagicStick" :loading="generatingImage"
- :disabled="!currentFramePrompt" @click="generateFrameImage">
+ <el-button
+ type="success"
+ :icon="MagicStick"
+ :loading="generatingImage"
+ :disabled="!currentFramePrompt"
+ @click="generateFrameImage"
+ >
{{
generatingImage
? $t("editor.generating")
@@ -354,13 +520,16 @@
</el-button>
<el-button :icon="Upload" @click="uploadImage">{{
$t("editor.uploadImage")
- }}</el-button>
+ }}</el-button>
</div>
<!-- 生成结果 -->
- <div class="generation-result" v-if="
- generatedImages.length > 0 || selectedFrameType === 'action'
- ">
+ <div
+ class="generation-result"
+ v-if="
+ generatedImages.length > 0 || selectedFrameType === 'action'
+ "
+ >
<div class="section-label">
{{ $t("editor.generationResult") }} ({{
generatedImages.length
@@ -368,10 +537,13 @@
</div>
<div class="image-grid">
<!-- 动作序列入口按钮 -->
- <div v-if="selectedFrameType === 'action'" class="image-item grid-entry-button"
- @click="showGridEditor = true">
+ <div
+ v-if="selectedFrameType === 'action'"
+ class="image-item grid-entry-button"
+ @click="showGridEditor = true"
+ >
<div class="grid-entry-placeholder">
- <el-icon :size="28" style="color: #ccc;">
+ <el-icon :size="28" style="color: #ccc">
<Plus />
</el-icon>
</div>
@@ -381,25 +553,55 @@
}}</span>
</div> -->
</div>
- <div v-for="img in generatedImages" :key="img.id" class="image-item">
- <el-image v-if="hasImage(img)" :src="getImageUrl(img)" :preview-src-list="generatedImages
- .filter((i) => hasImage(i))
- .map((i) => getImageUrl(i)!)
- " :initial-index="generatedImages
- .filter((i) => i.image_url)
- .findIndex((i) => i.id === img.id)
- " fit="cover" preview-teleported />
+ <div
+ v-for="img in generatedImages"
+ :key="img.id"
+ class="image-item"
+ :class="{
+ 'action-image-item': img.frame_type === 'action',
+ }"
+ >
+ <el-image
+ v-if="hasImage(img)"
+ :src="getImageUrl(img)"
+ :preview-src-list="
+ generatedImages
+ .filter((i) => hasImage(i))
+ .map((i) => getImageUrl(i)!)
+ "
+ :initial-index="
+ generatedImages
+ .filter((i) => i.image_url)
+ .findIndex((i) => i.id === img.id)
+ "
+ fit="cover"
+ preview-teleported
+ />
<div v-else class="image-placeholder">
<el-icon :size="32">
<Picture />
</el-icon>
<p>生成中...</p>
</div>
+ <!-- 动作序列图片裁剪图标 -->
+ <div
+ v-if="img.frame_type === 'action' && hasImage(img)"
+ class="crop-icon-overlay"
+ @click.stop="openCropDialog(img)"
+ >
+ <el-icon :size="24" color="#fff">
+ <Crop />
+ </el-icon>
+ </div>
<div class="image-info">
- <el-tag :type="getStatusType(img.status)" size="small">{{ getStatusText(img.status) }}</el-tag>
+ <el-tag
+ :type="getStatusType(img.status)"
+ size="small"
+ >{{ getStatusText(img.status) }}</el-tag
+ >
<span v-if="img.frame_type" class="frame-type-tag">{{
getFrameTypeText(img.frame_type)
- }}</span>
+ }}</span>
</div>
</div>
</div>
@@ -422,22 +624,47 @@
<div class="video-params-section">
<div class="param-row">
<span class="param-label">{{ $t("video.model") }}</span>
- <el-select v-model="selectedVideoModel" :placeholder="$t('video.selectVideoModel')" size="default"
- style="flex: 1">
- <el-option v-for="model in videoModelCapabilities" :key="model.id" :label="model.name"
- :value="model.id">
- <div style="
+ <el-select
+ v-model="selectedVideoModel"
+ :placeholder="$t('video.selectVideoModel')"
+ size="default"
+ style="flex: 1"
+ >
+ <el-option
+ v-for="model in videoModelCapabilities"
+ :key="model.id"
+ :label="model.name"
+ :value="model.id"
+ >
+ <div
+ style="
display: flex;
justify-content: space-between;
align-items: center;
- ">
+ "
+ >
<span>{{ model.name }}</span>
<div class="model-tags">
- <el-tag v-if="model.supportMultipleImages" size="small" type="success"
- style="margin-left: 4px">多图</el-tag>
- <el-tag v-if="model.supportFirstLastFrame" size="small" type="primary"
- style="margin-left: 4px">首尾帧</el-tag>
- <el-tag size="small" type="info" style="margin-left: 4px">最多{{ model.maxImages }}张</el-tag>
+ <el-tag
+ v-if="model.supportMultipleImages"
+ size="small"
+ type="success"
+ style="margin-left: 4px"
+ >多图</el-tag
+ >
+ <el-tag
+ v-if="model.supportFirstLastFrame"
+ size="small"
+ type="primary"
+ style="margin-left: 4px"
+ >首尾帧</el-tag
+ >
+ <el-tag
+ size="small"
+ type="info"
+ style="margin-left: 4px"
+ >最多{{ model.maxImages }}张</el-tag
+ >
</div>
</div>
</el-option>
@@ -445,20 +672,38 @@
</div>
<!-- 参考图模式选择 -->
- <div v-if="
- selectedVideoModel && availableReferenceModes.length > 0
- " class="param-row">
+ <div
+ v-if="
+ selectedVideoModel && availableReferenceModes.length > 0
+ "
+ class="param-row"
+ >
<span class="param-label">参考图</span>
- <el-select v-model="selectedReferenceMode" placeholder="请选择参考图模式" size="default" style="flex: 1">
- <el-option v-for="mode in availableReferenceModes" :key="mode.value" :label="mode.label"
- :value="mode.value">
- <div style="
+ <el-select
+ v-model="selectedReferenceMode"
+ placeholder="请选择参考图模式"
+ size="default"
+ style="flex: 1"
+ >
+ <el-option
+ v-for="mode in availableReferenceModes"
+ :key="mode.value"
+ :label="mode.label"
+ :value="mode.value"
+ >
+ <div
+ style="
display: flex;
justify-content: space-between;
align-items: center;
- ">
+ "
+ >
<span>{{ mode.label }}</span>
- <span v-if="mode.description" class="mode-description">{{ mode.description }}</span>
+ <span
+ v-if="mode.description"
+ class="mode-description"
+ >{{ mode.description }}</span
+ >
</div>
</el-option>
</el-select>
@@ -467,21 +712,40 @@
<div class="param-row">
<span class="param-label">{{
$t("professionalEditor.duration")
- }}</span>
+ }}</span>
<div style="flex: 1; display: flex; align-items: center">
- <el-slider v-model="videoDuration" :min="4" :max="10" :step="1" show-stops style="flex: 1" />
- <span style="margin-left: 10px; min-width: 40px">{{ videoDuration
- }}{{ $t("professionalEditor.seconds") }}</span>
+ <el-slider
+ v-model="videoDuration"
+ :min="4"
+ :max="10"
+ :step="1"
+ show-stops
+ style="flex: 1"
+ />
+ <span style="margin-left: 10px; min-width: 40px"
+ >{{ videoDuration
+ }}{{ $t("professionalEditor.seconds") }}</span
+ >
</div>
</div>
</div>
<!-- 选择参考图片 -->
- <div v-if="
- selectedReferenceMode && selectedReferenceMode !== 'none'
- " class="reference-images-section" style="margin-top: 0">
- <div class="frame-type-buttons" style="text-align: center; margin-bottom: 8px">
- <el-radio-group v-model="selectedVideoFrameType" size="default">
+ <div
+ v-if="
+ selectedReferenceMode && selectedReferenceMode !== 'none'
+ "
+ class="reference-images-section"
+ style="margin-top: 0"
+ >
+ <div
+ class="frame-type-buttons"
+ style="text-align: center; margin-bottom: 8px"
+ >
+ <el-radio-group
+ v-model="selectedVideoFrameType"
+ size="default"
+ >
<el-radio-button label="first">首帧</el-radio-button>
<el-radio-button label="last">尾帧</el-radio-button>
<el-radio-button label="panel">分镜板</el-radio-button>
@@ -492,19 +756,28 @@
<div class="frame-type-content">
<!-- 首帧 -->
- <div v-show="selectedVideoFrameType === 'first'" class="image-scroll-container" style="
+ <div
+ v-show="selectedVideoFrameType === 'first'"
+ class="image-scroll-container"
+ style="
max-height: 280px;
overflow-y: auto;
overflow-x: hidden;
- ">
+ "
+ >
<!-- 上一镜头尾帧推荐(紧凑版) -->
- <div v-if="previousStoryboardLastFrames.length > 0" class="previous-frame-section">
- <div style="
+ <div
+ v-if="previousStoryboardLastFrames.length > 0"
+ class="previous-frame-section"
+ >
+ <div
+ style="
display: flex;
align-items: center;
gap: 6px;
margin-bottom: 6px;
- ">
+ "
+ >
<el-tag size="small" type="primary">
上一镜头 #{{
previousStoryboard?.storyboard_number
@@ -514,23 +787,35 @@
<span class="hint-text">点击添加为首帧参考</span>
</div>
<div style="display: flex; gap: 8px; flex-wrap: wrap">
- <div v-for="img in previousStoryboardLastFrames" :key="'prev-' + img.id"
- class="reference-item" :class="{
+ <div
+ v-for="img in previousStoryboardLastFrames"
+ :key="'prev-' + img.id"
+ class="reference-item"
+ :class="{
selected: selectedImagesForVideo.includes(img.id),
- }" style="
+ }"
+ style="
position: relative;
border: 2px solid #1890ff;
border-radius: 4px;
overflow: hidden;
cursor: pointer;
- " @click="selectPreviousLastFrame(img)">
- <el-image :src="getImageUrl(img)" fit="cover" style="
+ "
+ @click="selectPreviousLastFrame(img)"
+ >
+ <el-image
+ :src="getImageUrl(img)"
+ fit="cover"
+ style="
width: 60px;
height: 40px;
display: block;
pointer-events: none;
- " />
- <div v-if="selectedImagesForVideo.includes(img.id)" style="
+ "
+ />
+ <div
+ v-if="selectedImagesForVideo.includes(img.id)"
+ style="
position: absolute;
top: 0;
right: 0;
@@ -538,7 +823,8 @@
color: #fff;
font-size: 10px;
padding: 1px 4px;
- ">
+ "
+ >
✓
</div>
</div>
@@ -546,27 +832,44 @@
</div>
<!-- 当前镜头首帧列表 -->
- <div class="reference-grid" style="
+ <div
+ class="reference-grid"
+ style="
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 12px;
max-width: 600px;
- ">
- <div v-for="img in videoReferenceImages.filter(
- (i) =>
- i.status === 'completed' &&
- i.image_url &&
- i.frame_type === 'first',
- )" :key="img.id" class="reference-item" :class="{
- selected: selectedImagesForVideo.includes(img.id),
- }" style="position: relative" @click="handleImageSelect(img.id)">
- <el-image :src="getImageUrl(img)" fit="cover" style="
+ "
+ >
+ <div
+ v-for="img in videoReferenceImages.filter(
+ (i) =>
+ i.status === 'completed' &&
+ i.image_url &&
+ i.frame_type === 'first',
+ )"
+ :key="img.id"
+ class="reference-item"
+ :class="{
+ selected: selectedImagesForVideo.includes(img.id),
+ }"
+ style="position: relative"
+ @click="handleImageSelect(img.id)"
+ >
+ <el-image
+ :src="getImageUrl(img)"
+ fit="cover"
+ style="
max-width: 120px;
width: 100%;
display: block;
pointer-events: none;
- " />
- <div class="preview-icon" @click.stop="previewImage(getImageUrl(img))" style="
+ "
+ />
+ <div
+ class="preview-icon"
+ @click.stop="previewImage(getImageUrl(img))"
+ style="
position: absolute;
top: 4px;
right: 4px;
@@ -579,50 +882,76 @@
justify-content: center;
cursor: pointer;
z-index: 10;
- ">
+ "
+ >
<el-icon :size="14" color="#fff">
<ZoomIn />
</el-icon>
</div>
</div>
</div>
- <el-empty v-if="
- !videoReferenceImages.some(
- (i) =>
- i.status === 'completed' &&
- i.image_url &&
- i.frame_type === 'first',
- ) && previousStoryboardLastFrames.length === 0
- " description="暂无首帧图片" size="small" />
+ <el-empty
+ v-if="
+ !videoReferenceImages.some(
+ (i) =>
+ i.status === 'completed' &&
+ i.image_url &&
+ i.frame_type === 'first',
+ ) && previousStoryboardLastFrames.length === 0
+ "
+ description="暂无首帧图片"
+ size="small"
+ />
</div>
<!-- 关键帧 -->
- <div v-show="selectedVideoFrameType === 'key'" class="image-scroll-container" style="
+ <div
+ v-show="selectedVideoFrameType === 'key'"
+ class="image-scroll-container"
+ style="
max-height: 280px;
overflow-y: auto;
overflow-x: hidden;
- ">
- <div class="reference-grid" style="
+ "
+ >
+ <div
+ class="reference-grid"
+ style="
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 12px;
max-width: 600px;
- ">
- <div v-for="img in videoReferenceImages.filter(
- (i) =>
- i.status === 'completed' &&
- i.image_url &&
- i.frame_type === 'key',
- )" :key="img.id" class="reference-item" :class="{
- selected: selectedImagesForVideo.includes(img.id),
- }" style="position: relative" @click="handleImageSelect(img.id)">
- <el-image :src="getImageUrl(img)" fit="cover" style="
+ "
+ >
+ <div
+ v-for="img in videoReferenceImages.filter(
+ (i) =>
+ i.status === 'completed' &&
+ i.image_url &&
+ i.frame_type === 'key',
+ )"
+ :key="img.id"
+ class="reference-item"
+ :class="{
+ selected: selectedImagesForVideo.includes(img.id),
+ }"
+ style="position: relative"
+ @click="handleImageSelect(img.id)"
+ >
+ <el-image
+ :src="getImageUrl(img)"
+ fit="cover"
+ style="
max-width: 120px;
width: 100%;
display: block;
pointer-events: none;
- " />
- <div class="preview-icon" @click.stop="previewImage(getImageUrl(img))" style="
+ "
+ />
+ <div
+ class="preview-icon"
+ @click.stop="previewImage(getImageUrl(img))"
+ style="
position: absolute;
top: 4px;
right: 4px;
@@ -635,50 +964,76 @@
justify-content: center;
cursor: pointer;
z-index: 10;
- ">
+ "
+ >
<el-icon :size="14" color="#fff">
<ZoomIn />
</el-icon>
</div>
</div>
</div>
- <el-empty v-if="
- !videoReferenceImages.some(
- (i) =>
- i.status === 'completed' &&
- i.image_url &&
- i.frame_type === 'key',
- )
- " description="暂无关键帧图片" size="small" />
+ <el-empty
+ v-if="
+ !videoReferenceImages.some(
+ (i) =>
+ i.status === 'completed' &&
+ i.image_url &&
+ i.frame_type === 'key',
+ )
+ "
+ description="暂无关键帧图片"
+ size="small"
+ />
</div>
<!-- 尾帧 -->
- <div v-show="selectedVideoFrameType === 'last'" class="image-scroll-container" style="
+ <div
+ v-show="selectedVideoFrameType === 'last'"
+ class="image-scroll-container"
+ style="
max-height: 280px;
overflow-y: auto;
overflow-x: hidden;
- ">
- <div class="reference-grid" style="
+ "
+ >
+ <div
+ class="reference-grid"
+ style="
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 12px;
max-width: 600px;
- ">
- <div v-for="img in videoReferenceImages.filter(
- (i) =>
- i.status === 'completed' &&
- i.image_url &&
- i.frame_type === 'last',
- )" :key="img.id" class="reference-item" :class="{
- selected: selectedImagesForVideo.includes(img.id),
- }" style="position: relative" @click="handleImageSelect(img.id)">
- <el-image :src="getImageUrl(img)" fit="cover" style="
+ "
+ >
+ <div
+ v-for="img in videoReferenceImages.filter(
+ (i) =>
+ i.status === 'completed' &&
+ i.image_url &&
+ i.frame_type === 'last',
+ )"
+ :key="img.id"
+ class="reference-item"
+ :class="{
+ selected: selectedImagesForVideo.includes(img.id),
+ }"
+ style="position: relative"
+ @click="handleImageSelect(img.id)"
+ >
+ <el-image
+ :src="getImageUrl(img)"
+ fit="cover"
+ style="
max-width: 120px;
width: 100%;
display: block;
pointer-events: none;
- " />
- <div class="preview-icon" @click.stop="previewImage(getImageUrl(img))" style="
+ "
+ />
+ <div
+ class="preview-icon"
+ @click.stop="previewImage(getImageUrl(img))"
+ style="
position: absolute;
top: 4px;
right: 4px;
@@ -691,50 +1046,76 @@
justify-content: center;
cursor: pointer;
z-index: 10;
- ">
+ "
+ >
<el-icon :size="14" color="#fff">
<ZoomIn />
</el-icon>
</div>
</div>
</div>
- <el-empty v-if="
- !videoReferenceImages.some(
- (i) =>
- i.status === 'completed' &&
- i.image_url &&
- i.frame_type === 'last',
- )
- " description="暂无尾帧图片" size="small" />
+ <el-empty
+ v-if="
+ !videoReferenceImages.some(
+ (i) =>
+ i.status === 'completed' &&
+ i.image_url &&
+ i.frame_type === 'last',
+ )
+ "
+ description="暂无尾帧图片"
+ size="small"
+ />
</div>
<!-- 分镜板 -->
- <div v-show="selectedVideoFrameType === 'panel'" class="image-scroll-container" style="
+ <div
+ v-show="selectedVideoFrameType === 'panel'"
+ class="image-scroll-container"
+ style="
max-height: 280px;
overflow-y: auto;
overflow-x: hidden;
- ">
- <div class="reference-grid" style="
+ "
+ >
+ <div
+ class="reference-grid"
+ style="
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 12px;
max-width: 600px;
- ">
- <div v-for="img in videoReferenceImages.filter(
- (i) =>
- i.status === 'completed' &&
- i.image_url &&
- i.frame_type === 'panel',
- )" :key="img.id" class="reference-item" :class="{
- selected: selectedImagesForVideo.includes(img.id),
- }" style="position: relative" @click="handleImageSelect(img.id)">
- <el-image :src="getImageUrl(img)" fit="cover" style="
+ "
+ >
+ <div
+ v-for="img in videoReferenceImages.filter(
+ (i) =>
+ i.status === 'completed' &&
+ i.image_url &&
+ i.frame_type === 'panel',
+ )"
+ :key="img.id"
+ class="reference-item"
+ :class="{
+ selected: selectedImagesForVideo.includes(img.id),
+ }"
+ style="position: relative"
+ @click="handleImageSelect(img.id)"
+ >
+ <el-image
+ :src="getImageUrl(img)"
+ fit="cover"
+ style="
max-width: 120px;
width: 100%;
display: block;
pointer-events: none;
- " />
- <div class="preview-icon" @click.stop="previewImage(getImageUrl(img))" style="
+ "
+ />
+ <div
+ class="preview-icon"
+ @click.stop="previewImage(getImageUrl(img))"
+ style="
position: absolute;
top: 4px;
right: 4px;
@@ -747,50 +1128,76 @@
justify-content: center;
cursor: pointer;
z-index: 10;
- ">
+ "
+ >
<el-icon :size="14" color="#fff">
<ZoomIn />
</el-icon>
</div>
</div>
</div>
- <el-empty v-if="
- !videoReferenceImages.some(
- (i) =>
- i.status === 'completed' &&
- i.image_url &&
- i.frame_type === 'panel',
- )
- " description="暂无分镜板图片" size="small" />
+ <el-empty
+ v-if="
+ !videoReferenceImages.some(
+ (i) =>
+ i.status === 'completed' &&
+ i.image_url &&
+ i.frame_type === 'panel',
+ )
+ "
+ description="暂无分镜板图片"
+ size="small"
+ />
</div>
<!-- 动作序列 -->
- <div v-show="selectedVideoFrameType === 'action'" class="image-scroll-container" style="
+ <div
+ v-show="selectedVideoFrameType === 'action'"
+ class="image-scroll-container"
+ style="
max-height: 280px;
overflow-y: auto;
overflow-x: hidden;
- ">
- <div class="reference-grid" style="
+ "
+ >
+ <div
+ class="reference-grid"
+ style="
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 12px;
max-width: 600px;
- ">
- <div v-for="img in videoReferenceImages.filter(
- (i) =>
- i.status === 'completed' &&
- i.image_url &&
- i.frame_type === 'action',
- )" :key="img.id" class="reference-item" :class="{
- selected: selectedImagesForVideo.includes(img.id),
- }" style="position: relative" @click="handleImageSelect(img.id)">
- <el-image :src="getImageUrl(img)" fit="cover" style="
+ "
+ >
+ <div
+ v-for="img in videoReferenceImages.filter(
+ (i) =>
+ i.status === 'completed' &&
+ i.image_url &&
+ i.frame_type === 'action',
+ )"
+ :key="img.id"
+ class="reference-item"
+ :class="{
+ selected: selectedImagesForVideo.includes(img.id),
+ }"
+ style="position: relative"
+ @click="handleImageSelect(img.id)"
+ >
+ <el-image
+ :src="getImageUrl(img)"
+ fit="cover"
+ style="
max-width: 120px;
width: 100%;
display: block;
pointer-events: none;
- " />
- <div class="preview-icon" @click.stop="previewImage(getImageUrl(img))" style="
+ "
+ />
+ <div
+ class="preview-icon"
+ @click.stop="previewImage(getImageUrl(img))"
+ style="
position: absolute;
top: 4px;
right: 4px;
@@ -803,48 +1210,73 @@
justify-content: center;
cursor: pointer;
z-index: 10;
- ">
+ "
+ >
<el-icon :size="14" color="#fff">
<ZoomIn />
</el-icon>
</div>
</div>
</div>
- <el-empty v-if="
- !videoReferenceImages.some(
- (i) =>
- i.status === 'completed' &&
- i.image_url &&
- i.frame_type === 'action',
- )
- " description="暂无动作序列图片" size="small" />
+ <el-empty
+ v-if="
+ !videoReferenceImages.some(
+ (i) =>
+ i.status === 'completed' &&
+ i.image_url &&
+ i.frame_type === 'action',
+ )
+ "
+ description="暂无动作序列图片"
+ size="small"
+ />
</div>
</div>
</div>
<!-- 参考图片设置 -->
- <div v-if="
- selectedReferenceMode && selectedReferenceMode !== 'none'
- " class="reference-config-section" style="margin-top: 24px">
+ <div
+ v-if="
+ selectedReferenceMode && selectedReferenceMode !== 'none'
+ "
+ class="reference-config-section"
+ style="margin-top: 24px"
+ >
<!-- 图片框配置区 -->
- <div class="image-slots-container" style="margin-top: 16px; margin-bottom: 24px">
+ <div
+ class="image-slots-container"
+ style="margin-top: 16px; margin-bottom: 24px"
+ >
<!-- 单图模式 -->
- <div v-if="selectedReferenceMode === 'single'" style="text-align: center">
+ <div
+ v-if="selectedReferenceMode === 'single'"
+ style="text-align: center"
+ >
<div class="reference-mode-title">单图参考</div>
<div style="display: inline-block">
- <div class="image-slot" @click="
- selectedImagesForVideo.length > 0 &&
- removeSelectedImage(selectedImagesForVideo[0])
- ">
- <img v-if="selectedImageObjects[0]" :src="getImageUrl(selectedImageObjects[0])" alt=""
- style="width: 100%; height: 100%; object-fit: cover" />
+ <div
+ class="image-slot"
+ @click="
+ selectedImagesForVideo.length > 0 &&
+ removeSelectedImage(selectedImagesForVideo[0])
+ "
+ >
+ <img
+ v-if="selectedImageObjects[0]"
+ :src="getImageUrl(selectedImageObjects[0])"
+ alt=""
+ style="width: 100%; height: 100%; object-fit: cover"
+ />
<div v-else class="image-slot-placeholder">
<el-icon :size="32" color="#c0c4cc">
<Plus />
</el-icon>
<div class="slot-hint">点击上方选择图片</div>
</div>
- <div v-if="selectedImageObjects[0]" class="image-slot-remove">
+ <div
+ v-if="selectedImageObjects[0]"
+ class="image-slot-remove"
+ >
<el-icon :size="16" color="#fff">
<Close />
</el-icon>
@@ -854,32 +1286,48 @@
</div>
<!-- 首尾帧模式 -->
- <div v-else-if="selectedReferenceMode === 'first_last'" style="text-align: center">
+ <div
+ v-else-if="selectedReferenceMode === 'first_last'"
+ style="text-align: center"
+ >
<div class="reference-mode-title">首尾帧</div>
- <div style="
+ <div
+ style="
display: flex;
gap: 20px;
justify-content: center;
align-items: center;
- ">
+ "
+ >
<div>
<div class="frame-label">首帧</div>
- <div class="image-slot" @click="
- firstFrameSlotImage &&
- removeSelectedImage(firstFrameSlotImage.id)
- ">
- <img v-if="firstFrameSlotImage" :src="firstFrameSlotImage.image_url" alt="" style="
+ <div
+ class="image-slot"
+ @click="
+ firstFrameSlotImage &&
+ removeSelectedImage(firstFrameSlotImage.id)
+ "
+ >
+ <img
+ v-if="firstFrameSlotImage"
+ :src="firstFrameSlotImage.image_url"
+ alt=""
+ style="
width: 100%;
height: 100%;
object-fit: cover;
- " />
+ "
+ />
<div v-else class="image-slot-placeholder">
<el-icon :size="32" color="#c0c4cc">
<Plus />
</el-icon>
<div class="slot-hint">选择首帧</div>
</div>
- <div v-if="firstFrameSlotImage" class="image-slot-remove">
+ <div
+ v-if="firstFrameSlotImage"
+ class="image-slot-remove"
+ >
<el-icon :size="16" color="#fff">
<Close />
</el-icon>
@@ -891,22 +1339,33 @@
</el-icon>
<div>
<div class="frame-label">尾帧</div>
- <div class="image-slot" @click="
- lastFrameSlotImage &&
- removeSelectedImage(lastFrameSlotImage.id)
- ">
- <img v-if="lastFrameSlotImage" :src="lastFrameSlotImage.image_url" alt="" style="
+ <div
+ class="image-slot"
+ @click="
+ lastFrameSlotImage &&
+ removeSelectedImage(lastFrameSlotImage.id)
+ "
+ >
+ <img
+ v-if="lastFrameSlotImage"
+ :src="lastFrameSlotImage.image_url"
+ alt=""
+ style="
width: 100%;
height: 100%;
object-fit: cover;
- " />
+ "
+ />
<div v-else class="image-slot-placeholder">
<el-icon :size="32" color="#c0c4cc">
<Plus />
</el-icon>
<div class="slot-hint">选择尾帧</div>
</div>
- <div v-if="lastFrameSlotImage" class="image-slot-remove">
+ <div
+ v-if="lastFrameSlotImage"
+ class="image-slot-remove"
+ >
<el-icon :size="16" color="#fff">
<Close />
</el-icon>
@@ -917,25 +1376,36 @@
</div>
<!-- 多图模式 -->
- <div v-else-if="selectedReferenceMode === 'multiple'" style="text-align: center">
- <div style="
+ <div
+ v-else-if="selectedReferenceMode === 'multiple'"
+ style="text-align: center"
+ >
+ <div
+ style="
margin-bottom: 12px;
font-size: 13px;
color: #606266;
font-weight: 500;
- ">
+ "
+ >
多图参考 ({{ selectedImagesForVideo.length }}/{{
currentModelCapability?.maxImages || 6
}})
</div>
- <div style="
+ <div
+ style="
display: flex;
gap: 12px;
justify-content: center;
flex-wrap: wrap;
- ">
- <div v-for="index in currentModelCapability?.maxImages ||
- 6" :key="index" class="image-slot image-slot-small" style="
+ "
+ >
+ <div
+ v-for="index in currentModelCapability?.maxImages ||
+ 6"
+ :key="index"
+ class="image-slot image-slot-small"
+ style="
position: relative;
width: 80px;
height: 52px;
@@ -944,27 +1414,38 @@
overflow: hidden;
cursor: pointer;
background: #fff;
- " @click="
+ "
+ @click="
selectedImageObjects[index - 1] &&
removeSelectedImage(
selectedImageObjects[index - 1].id,
)
- ">
- <img v-if="selectedImageObjects[index - 1]" :src="selectedImageObjects[index - 1].image_url"
- alt="" style="width: 100%; height: 100%; object-fit: cover" />
+ "
+ >
+ <img
+ v-if="selectedImageObjects[index - 1]"
+ :src="selectedImageObjects[index - 1].image_url"
+ alt=""
+ style="width: 100%; height: 100%; object-fit: cover"
+ />
<div v-else class="image-slot-placeholder">
<el-icon :size="20" color="#c0c4cc">
<Plus />
</el-icon>
- <div style="
+ <div
+ style="
margin-top: 4px;
font-size: 10px;
color: #909399;
- ">
+ "
+ >
{{ index }}
</div>
</div>
- <div v-if="selectedImageObjects[index - 1]" class="image-slot-remove">
+ <div
+ v-if="selectedImageObjects[index - 1]"
+ class="image-slot-remove"
+ >
<el-icon :size="14" color="#fff">
<Close />
</el-icon>
@@ -976,37 +1457,61 @@
</div>
<!-- 生成控制 -->
- <div class="generation-controls" style="margin-top: 32px; text-align: center">
- <el-button type="primary" :icon="VideoCamera" :loading="generatingVideo" :disabled="!selectedVideoModel ||
- (selectedReferenceMode !== 'none' &&
- selectedImagesForVideo.length === 0)
- " @click="generateVideo">
+ <div
+ class="generation-controls"
+ style="margin-top: 32px; text-align: center"
+ >
+ <el-button
+ type="primary"
+ :icon="VideoCamera"
+ :loading="generatingVideo"
+ :disabled="
+ !selectedVideoModel ||
+ (selectedReferenceMode !== 'none' &&
+ selectedImagesForVideo.length === 0)
+ "
+ @click="generateVideo"
+ >
{{ generatingVideo ? "生成中..." : "生成视频" }}
</el-button>
</div>
<!-- 生成的视频列表 -->
- <div class="generation-result" v-if="generatedVideos.length > 0" style="margin-top: 24px">
- <div class="section-label" style="
+ <div
+ class="generation-result"
+ v-if="generatedVideos.length > 0"
+ style="margin-top: 24px"
+ >
+ <div
+ class="section-label"
+ style="
font-size: 13px;
font-weight: 600;
margin-bottom: 12px;
display: flex;
align-items: center;
gap: 6px;
- ">
+ "
+ >
<span></span>
生成结果 ({{ generatedVideos.length }})
</div>
- <div class="image-grid" style="
+ <div
+ class="image-grid"
+ style="
display: grid;
grid-template-columns: repeat(
auto-fill,
minmax(140px, 1fr)
);
gap: 10px;
- ">
- <div v-for="video in generatedVideos" :key="video.id" class="image-item video-item" style="
+ "
+ >
+ <div
+ v-for="video in generatedVideos"
+ :key="video.id"
+ class="image-item video-item"
+ style="
position: relative;
border-radius: 8px;
overflow: hidden;
@@ -1015,32 +1520,46 @@
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
cursor: pointer;
transition: all 0.2s ease;
- ">
- <div class="video-thumbnail" v-if="video.video_url" style="
+ "
+ >
+ <div
+ class="video-thumbnail"
+ v-if="video.video_url"
+ style="
position: relative;
width: 100%;
aspect-ratio: 16/9;
overflow: hidden;
cursor: pointer;
- " @mouseenter="
+ "
+ @mouseenter="
(e) =>
- (e.currentTarget.querySelector(
- '.play-overlay',
- ).style.opacity = '1')
- " @mouseleave="
+ (e.currentTarget.querySelector(
+ '.play-overlay',
+ ).style.opacity = '1')
+ "
+ @mouseleave="
(e) =>
- (e.currentTarget.querySelector(
- '.play-overlay',
- ).style.opacity = '0')
- " @click="playVideo(video)">
- <video :src="getVideoUrl(video)" preload="metadata" style="
+ (e.currentTarget.querySelector(
+ '.play-overlay',
+ ).style.opacity = '0')
+ "
+ @click="playVideo(video)"
+ >
+ <video
+ :src="getVideoUrl(video)"
+ preload="metadata"
+ style="
width: 100%;
height: 100%;
object-fit: cover;
display: block;
pointer-events: none;
- " />
- <div class="play-overlay" style="
+ "
+ />
+ <div
+ class="play-overlay"
+ style="
position: absolute;
top: 0;
left: 0;
@@ -1052,15 +1571,23 @@
background: rgba(0, 0, 0, 0.3);
opacity: 0;
transition: opacity 0.2s;
- ">
- <el-icon :size="32" color="#fff" style="
+ "
+ >
+ <el-icon
+ :size="32"
+ color="#fff"
+ style="
filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
- ">
+ "
+ >
<VideoPlay />
</el-icon>
</div>
</div>
- <div v-else class="image-placeholder" style="
+ <div
+ v-else
+ class="image-placeholder"
+ style="
width: 100%;
aspect-ratio: 16/9;
display: flex;
@@ -1074,13 +1601,16 @@
#e8ecf0 100%
);
color: #909399;
- ">
+ "
+ >
<el-icon :size="32">
<VideoCamera />
</el-icon>
<p style="margin: 0; font-size: 11px">生成中...</p>
</div>
- <div class="image-info" style="
+ <div
+ class="image-info"
+ style="
position: absolute;
bottom: 0;
left: 0;
@@ -1096,19 +1626,32 @@
justify-content: space-between;
align-items: center;
gap: 4px;
- ">
- <div style="display: flex; align-items: center; gap: 4px">
- <el-tag :type="getStatusType(video.status)" size="small" style="
+ "
+ >
+ <div
+ style="display: flex; align-items: center; gap: 4px"
+ >
+ <el-tag
+ :type="getStatusType(video.status)"
+ size="small"
+ style="
font-size: 10px;
height: 20px;
padding: 0 6px;
- ">{{ getStatusText(video.status) }}</el-tag>
+ "
+ >{{ getStatusText(video.status) }}</el-tag
+ >
</div>
<div style="display: flex; gap: 4px">
- <el-button v-if="
- video.status === 'completed' && video.video_url
- " type="success" size="small" :loading="addingToAssets.has(video.id)"
- @click.stop="addVideoToAssets(video)">
+ <el-button
+ v-if="
+ video.status === 'completed' && video.video_url
+ "
+ type="success"
+ size="small"
+ :loading="addingToAssets.has(video.id)"
+ @click.stop="addVideoToAssets(video)"
+ >
{{
addingToAssets.has(video.id)
? "添加中..."
@@ -1136,9 +1679,15 @@
<el-tab-pane :label="$t('video.videoMerge')" name="merges">
<div class="tab-content">
<div class="merges-list" v-loading="loadingMerges">
- <el-empty v-if="videoMerges.length === 0" :description="$t('video.noMergeRecords')" :image-size="120">
+ <el-empty
+ v-if="videoMerges.length === 0"
+ :description="$t('video.noMergeRecords')"
+ :image-size="120"
+ >
<template #description>
- <div style="color: #909399; font-size: 14px; margin-top: 12px">
+ <div
+ style="color: #909399; font-size: 14px; margin-top: 12px"
+ >
<p style="margin: 0">{{ $t("video.noMergeYet") }}</p>
<p style="margin: 8px 0 0 0; font-size: 12px">
{{ $t("video.mergeInstructions") }}
@@ -1147,8 +1696,12 @@
</template>
</el-empty>
<div v-else class="merge-items">
- <div v-for="merge in videoMerges" :key="merge.id" class="merge-item"
- :class="'merge-status-' + merge.status">
+ <div
+ v-for="merge in videoMerges"
+ :key="merge.id"
+ class="merge-item"
+ :class="'merge-status-' + merge.status"
+ >
<!-- 状态指示条 -->
<div class="status-indicator"></div>
@@ -1159,18 +1712,29 @@
<div class="title-section">
<el-icon :size="20" class="title-icon">
<VideoCamera v-if="merge.status === 'completed'" />
- <Loading v-else-if="merge.status === 'processing'" class="rotating" />
- <WarningFilled v-else-if="merge.status === 'failed'" />
+ <Loading
+ v-else-if="merge.status === 'processing'"
+ class="rotating"
+ />
+ <WarningFilled
+ v-else-if="merge.status === 'failed'"
+ />
<Clock v-else />
</el-icon>
<h3 class="merge-title">{{ merge.title }}</h3>
</div>
- <el-tag :type="merge.status === 'completed'
- ? 'success'
- : merge.status === 'failed'
- ? 'danger'
- : 'warning'
- " effect="dark" size="large" round>
+ <el-tag
+ :type="
+ merge.status === 'completed'
+ ? 'success'
+ : merge.status === 'failed'
+ ? 'danger'
+ : 'warning'
+ "
+ effect="dark"
+ size="large"
+ round
+ >
{{
merge.status === "pending"
? "等待中"
@@ -1234,7 +1798,10 @@
</div>
<!-- 错误提示 -->
- <div class="merge-error" v-if="merge.status === 'failed' && merge.error_msg">
+ <div
+ class="merge-error"
+ v-if="merge.status === 'failed' && merge.error_msg"
+ >
<el-alert type="error" :closable="false" show-icon>
<template #title>
<div style="font-size: 13px; line-height: 1.5">
@@ -1246,19 +1813,35 @@
<!-- 操作按钮 -->
<div class="merge-actions">
- <template v-if="
- merge.status === 'completed' && merge.merged_url
- ">
- <el-button type="primary" :icon="VideoCamera" @click="
- downloadVideo(merge.merged_url, merge.title)
- " round>
+ <template
+ v-if="
+ merge.status === 'completed' && merge.merged_url
+ "
+ >
+ <el-button
+ type="primary"
+ :icon="VideoCamera"
+ @click="
+ downloadVideo(merge.merged_url, merge.title)
+ "
+ round
+ >
下载视频
</el-button>
- <el-button :icon="View" @click="previewMergedVideo(merge.merged_url)" round>
+ <el-button
+ :icon="View"
+ @click="previewMergedVideo(merge.merged_url)"
+ round
+ >
在线预览
</el-button>
</template>
- <el-button type="danger" :icon="Delete" @click="deleteMerge(merge.id)" round>
+ <el-button
+ type="danger"
+ :icon="Delete"
+ @click="deleteMerge(merge.id)"
+ round
+ >
删除
</el-button>
</div>
@@ -1273,31 +1856,60 @@
</div>
<!-- 角色选择器对话框 -->
- <el-dialog v-model="showCharacterImagePreview" :title="previewCharacter?.name" width="600px">
+ <el-dialog
+ v-model="showCharacterImagePreview"
+ :title="previewCharacter?.name"
+ width="600px"
+ >
<div class="character-image-preview" v-if="previewCharacter">
- <img v-if="previewCharacter.local_path" :src="getImageUrl(previewCharacter)" :alt="previewCharacter.name" />
+ <img
+ v-if="previewCharacter.local_path"
+ :src="getImageUrl(previewCharacter)"
+ :alt="previewCharacter.name"
+ />
<el-empty v-else description="暂无图片" />
</div>
<!-- ... -->
</el-dialog>
<!-- 场景大图预览对话框 -->
- <el-dialog v-model="showSceneImagePreview" :title="currentStoryboard?.background
- ? `${currentStoryboard.background.location} · ${currentStoryboard.background.time}`
- : '场景预览'
- " width="800px">
- <div class="scene-image-preview" v-if="currentStoryboard?.background?.image_url">
+ <el-dialog
+ v-model="showSceneImagePreview"
+ :title="
+ currentStoryboard?.background
+ ? `${currentStoryboard.background.location} · ${currentStoryboard.background.time}`
+ : '场景预览'
+ "
+ width="800px"
+ >
+ <div
+ class="scene-image-preview"
+ v-if="currentStoryboard?.background?.image_url"
+ >
<img :src="currentStoryboard.background.image_url" alt="场景" />
</div>
</el-dialog>
<!-- 角色选择对话框 -->
- <el-dialog v-model="showCharacterSelector" title="添加角色到镜头" width="800px">
+ <el-dialog
+ v-model="showCharacterSelector"
+ title="添加角色到镜头"
+ width="800px"
+ >
<div class="character-selector-grid">
- <div v-for="char in availableCharacters" :key="char.id" class="character-card"
- :class="{ selected: isCharacterInCurrentShot(char.id) }" @click="toggleCharacterInShot(char.id)">
+ <div
+ v-for="char in availableCharacters"
+ :key="char.id"
+ class="character-card"
+ :class="{ selected: isCharacterInCurrentShot(char.id) }"
+ @click="toggleCharacterInShot(char.id)"
+ >
<div class="character-avatar-large">
- <img v-if="char.local_path" :src="getImageUrl(char)" :alt="char.name" />
+ <img
+ v-if="char.local_path"
+ :src="getImageUrl(char)"
+ :alt="char.name"
+ />
<span v-else>{{ char.name?.[0] || "?" }}</span>
</div>
<div class="character-info">
@@ -1320,12 +1932,25 @@
</el-dialog>
<!-- 道具选择对话框 -->
- <el-dialog v-model="showPropSelector" :title="$t('editor.addPropToShot')" width="800px">
+ <el-dialog
+ v-model="showPropSelector"
+ :title="$t('editor.addPropToShot')"
+ width="800px"
+ >
<div class="character-selector-grid">
- <div v-for="prop in availableProps" :key="prop.id" class="character-card"
- :class="{ selected: isPropInCurrentShot(prop.id) }" @click="togglePropInShot(prop.id)">
+ <div
+ v-for="prop in availableProps"
+ :key="prop.id"
+ class="character-card"
+ :class="{ selected: isPropInCurrentShot(prop.id) }"
+ @click="togglePropInShot(prop.id)"
+ >
<div class="character-avatar-large">
- <img v-if="prop.local_path" :src="getImageUrl(prop)" :alt="prop.name" />
+ <img
+ v-if="prop.local_path"
+ :src="getImageUrl(prop)"
+ :alt="prop.name"
+ />
<el-icon v-else :size="32">
<Box />
</el-icon>
@@ -1349,17 +1974,26 @@
<template #footer>
<el-button @click="showPropSelector = false">{{
$t("common.close")
- }}</el-button>
+ }}</el-button>
</template>
</el-dialog>
<!-- 场景选择对话框 -->
<el-dialog v-model="showSceneSelector" title="选择场景背景" width="800px">
<div class="scene-selector-grid">
- <div v-for="scene in availableScenes" :key="scene.id" class="scene-card"
- :class="{ selected: currentStoryboard?.scene_id === scene.id }" @click="selectScene(scene.id)">
+ <div
+ v-for="scene in availableScenes"
+ :key="scene.id"
+ class="scene-card"
+ :class="{ selected: currentStoryboard?.scene_id === scene.id }"
+ @click="selectScene(scene.id)"
+ >
<div class="scene-image">
- <img v-if="hasImage(scene)" :src="getImageUrl(scene)" :alt="scene.location" />
+ <img
+ v-if="hasImage(scene)"
+ :src="getImageUrl(scene)"
+ :alt="scene.location"
+ />
<el-icon v-else :size="48" color="#ccc">
<Picture />
</el-icon>
@@ -1376,15 +2010,27 @@
</el-dialog>
<!-- 视频预览对话框 -->
- <el-dialog v-model="showVideoPreview" title="视频预览" width="800px" :close-on-click-modal="true" destroy-on-close>
+ <el-dialog
+ v-model="showVideoPreview"
+ title="视频预览"
+ width="800px"
+ :close-on-click-modal="true"
+ destroy-on-close
+ >
<div class="video-preview-container" v-if="previewVideo">
- <video v-if="previewVideo.video_url" :src="getVideoUrl(previewVideo)" controls autoplay style="
+ <video
+ v-if="previewVideo.video_url"
+ :src="getVideoUrl(previewVideo)"
+ controls
+ autoplay
+ style="
width: 100%;
max-height: 70vh;
display: block;
background: #000;
border-radius: 8px;
- " />
+ "
+ />
<div v-else style="text-align: center; padding: 40px">
<el-icon :size="48" color="#ccc">
<VideoCamera />
@@ -1392,31 +2038,42 @@
<p style="margin-top: 16px; color: #909399">视频生成中...</p>
</div>
<div class="video-meta">
- <div style="
+ <div
+ style="
display: flex;
justify-content: space-between;
align-items: center;
- ">
+ "
+ >
<div>
<el-tag :type="getStatusType(previewVideo.status)" size="small">{{
getStatusText(previewVideo.status)
- }}</el-tag>
- <span v-if="previewVideo.duration" style="margin-left: 12px; color: #606266; font-size: 14px">{{
- $t("professionalEditor.duration") }}:
+ }}</el-tag>
+ <span
+ v-if="previewVideo.duration"
+ style="margin-left: 12px; color: #606266; font-size: 14px"
+ >{{ $t("professionalEditor.duration") }}:
{{ previewVideo.duration
- }}{{ $t("professionalEditor.seconds") }}</span>
+ }}{{ $t("professionalEditor.seconds") }}</span
+ >
</div>
- <el-button v-if="previewVideo.video_url" size="small"
- @click="window.open(previewVideo.video_url, '_blank')">
+ <el-button
+ v-if="previewVideo.video_url"
+ size="small"
+ @click="window.open(previewVideo.video_url, '_blank')"
+ >
{{ $t("professionalEditor.downloadVideo") }}
</el-button>
</div>
- <div v-if="previewVideo.prompt" style="
+ <div
+ v-if="previewVideo.prompt"
+ style="
margin-top: 12px;
font-size: 12px;
color: #606266;
line-height: 1.6;
- ">
+ "
+ >
<strong>提示词:</strong>{{ previewVideo.prompt }}
</div>
</div>
@@ -1424,8 +2081,20 @@
</el-dialog>
<!-- 宫格图片编辑器组件 -->
- <GridImageEditor v-model="showGridEditor" :storyboard-id="currentStoryboard?.id || 0" :drama-id="dramaId"
- :all-images="allGeneratedImages" @success="handleGridImageSuccess" />
+ <GridImageEditor
+ v-model="showGridEditor"
+ :storyboard-id="currentStoryboard?.id || 0"
+ :drama-id="dramaId"
+ :all-images="allGeneratedImages"
+ @success="handleGridImageSuccess"
+ />
+
+ <!-- 图片裁剪对话框 -->
+ <ImageCropDialog
+ v-model="showCropDialog"
+ :image-url="cropImageUrl"
+ @save="handleCropSave"
+ />
</div>
</template>
@@ -1467,6 +2136,7 @@ import {
Delete,
Connection,
Box,
+ Crop,
} from "@element-plus/icons-vue";
import { dramaAPI } from "@/api/drama";
import { propAPI } from "@/api/prop";
@@ -1485,7 +2155,7 @@ import type { VideoMerge } from "@/api/videoMerge";
import VideoTimelineEditor from "@/components/editor/VideoTimelineEditor.vue";
import GridImageEditor from "@/components/editor/GridImageEditor.vue";
import type { Drama, Episode, Storyboard } from "@/types/drama";
-import { AppHeader } from "@/components/common";
+import { AppHeader, ImageCropDialog } from "@/components/common";
import { getImageUrl, hasImage, getVideoUrl } from "@/utils/image";
const route = useRoute();
@@ -1550,6 +2220,11 @@ const showGridEditor = ref(false);
// 所有已生成的图片(用于宫格编辑器选择)
const allGeneratedImages = ref<ImageGeneration[]>([]);
+// 图片裁剪对话框状态
+const showCropDialog = ref(false);
+const cropImageUrl = ref<string>("");
+const cropImageData = ref<ImageGeneration | null>(null);
+
// 视频生成相关状态
const videoDuration = ref(5); // 默认5秒,会根据镜头duration自动更新
const selectedVideoFrameType = ref<FrameType>("first");
@@ -3196,6 +3871,59 @@ const handleGridImageSuccess = async () => {
}
};
+// 打开裁剪对话框
+const openCropDialog = (img: ImageGeneration) => {
+ cropImageData.value = img;
+ cropImageUrl.value = getImageUrl(img) || "";
+ showCropDialog.value = true;
+};
+
+// 处理裁剪保存
+const handleCropSave = async (images: { blob: Blob; frameType: string }[]) => {
+ if (!currentStoryboard.value || !cropImageData.value) return;
+
+ try {
+ // 将 Blob 转换为 base64 data URL
+ const convertBlobToBase64 = (blob: Blob): Promise<string> => {
+ return new Promise((resolve, reject) => {
+ const reader = new FileReader();
+ reader.onloadend = () => resolve(reader.result as string);
+ reader.onerror = reject;
+ reader.readAsDataURL(blob);
+ });
+ };
+
+ // 上传裁剪后的图片并创建新的图片生成记录
+ for (const img of images) {
+ // 将 Blob 转换为 base64
+ const imageUrl = await convertBlobToBase64(img.blob);
+
+ // 调用上传接口
+ await imageAPI.uploadImage({
+ storyboard_id: currentStoryboard.value.id,
+ drama_id: Number(dramaId),
+ frame_type: img.frameType,
+ image_url: imageUrl,
+ prompt: cropImageData.value.prompt || "",
+ });
+ }
+
+ ElMessage.success("裁剪图片保存成功");
+
+ // 刷新图片列表
+ if (currentStoryboard.value) {
+ await loadStoryboardImages(
+ currentStoryboard.value.id.toString(),
+ selectedFrameType.value,
+ );
+ await loadAllGeneratedImages();
+ }
+ } catch (error) {
+ console.error("Failed to save cropped images:", error);
+ ElMessage.error("保存裁剪图片失败");
+ }
+};
+
const goBack = () => {
router.replace({
name: "EpisodeWorkflowNew",
@@ -3328,7 +4056,7 @@ const startMergePolling = () => {
if (!hasProcessingTasks) {
stopMergePolling();
}
- } catch (error) { }
+ } catch (error) {}
}, 3000); // 每3秒轮询一次
};
@@ -3762,7 +4490,6 @@ onBeforeUnmount(() => {
// 脉冲动画
@keyframes pulse {
-
0%,
100% {
opacity: 1;
@@ -4319,7 +5046,6 @@ onBeforeUnmount(() => {
border-left: 3px solid var(--accent);
.shot-content {
-
.shot-number,
.shot-title {
color: var(--accent) !important;
@@ -4528,9 +5254,11 @@ onBeforeUnmount(() => {
content: "";
width: 3px;
height: 14px;
- background: linear-gradient(to bottom,
- var(--accent),
- var(--accent-hover));
+ background: linear-gradient(
+ to bottom,
+ var(--accent),
+ var(--accent-hover)
+ );
border-radius: 2px;
}
}
@@ -4581,10 +5309,12 @@ onBeforeUnmount(() => {
position: absolute;
width: 200%;
height: 200%;
- background: linear-gradient(45deg,
- transparent 30%,
- rgba(255, 255, 255, 0.3) 50%,
- transparent 70%);
+ background: linear-gradient(
+ 45deg,
+ transparent 30%,
+ rgba(255, 255, 255, 0.3) 50%,
+ transparent 70%
+ );
animation: shimmer 2s infinite;
top: -50%;
left: -50%;
@@ -4611,10 +5341,12 @@ onBeforeUnmount(() => {
left: 0;
right: 0;
padding: 6px 8px;
- background: linear-gradient(to top,
- rgba(0, 0, 0, 0.75),
- rgba(0, 0, 0, 0.2) 70%,
- transparent);
+ background: linear-gradient(
+ to top,
+ rgba(0, 0, 0, 0.75),
+ rgba(0, 0, 0, 0.2) 70%,
+ transparent
+ );
display: flex;
justify-content: space-between;
align-items: center;
@@ -4743,10 +5475,12 @@ onBeforeUnmount(() => {
position: absolute;
width: 200%;
height: 200%;
- background: linear-gradient(45deg,
- transparent 30%,
- rgba(255, 255, 255, 0.3) 50%,
- transparent 70%);
+ background: linear-gradient(
+ 45deg,
+ transparent 30%,
+ rgba(255, 255, 255, 0.3) 50%,
+ transparent 70%
+ );
animation: shimmer 2s infinite;
top: -50%;
left: -50%;
@@ -4773,10 +5507,12 @@ onBeforeUnmount(() => {
left: 0;
right: 0;
padding: 6px 8px;
- background: linear-gradient(to top,
- rgba(0, 0, 0, 0.75),
- rgba(0, 0, 0, 0.2) 70%,
- transparent);
+ background: linear-gradient(
+ to top,
+ rgba(0, 0, 0, 0.75),
+ rgba(0, 0, 0, 0.2) 70%,
+ transparent
+ );
display: flex;
justify-content: space-between;
align-items: center;
@@ -5311,7 +6047,6 @@ onBeforeUnmount(() => {
}
@keyframes pulse {
-
0%,
100% {
opacity: 1;
@@ -5356,11 +6091,43 @@ onBeforeUnmount(() => {
overflow-y: auto;
}
+/* 动作序列图片裁剪图标样式 */
+.action-image-item {
+ position: relative;
+}
+
+.crop-icon-overlay {
+ position: absolute;
+ top: 8px;
+ right: 8px;
+ width: 36px;
+ height: 36px;
+ background: rgba(0, 0, 0, 0.7);
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ cursor: pointer;
+ opacity: 0;
+ transition: all 0.3s ease;
+ z-index: 10;
+}
+
+.action-image-item:hover .crop-icon-overlay {
+ opacity: 1;
+}
+
+.crop-icon-overlay:hover {
+ background: var(--accent);
+ transform: scale(1.1);
+}
+
/* 宫格图片入口按钮样式 */
.grid-entry-button {
cursor: pointer;
transition: all 0.3s ease;
border: none !important;
+ min-height: 84px;
}
.grid-entry-button:hover {