You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

1.7 KiB

插入分镜位置计算修正

问题描述

插入新分镜功能存在位置计算错误:

  • 第1次插入位置正确
  • 后续插入都偏移一个位置,没有考虑新插入的分镜对位置计算的影响

根本原因

使用 storyboard.orderIndex + 1 计算插入位置,但 orderIndex 是分镜创建时的原始值,不会随着新分镜插入而实时更新。

修复方案

改用基于数组索引的位置计算:

修复前

// 第一个按钮
onClick={() => handleInsertStoryboard(1)}

// 分镜后按钮
onClick={() => handleInsertStoryboard(storyboard.orderIndex + 1)}

修复后

// 第一个按钮
onClick={() => handleInsertStoryboard(1)}

// 分镜后按钮
onClick={() => handleInsertStoryboard(index + 2)}

逻辑说明

  • 第一个按钮handleInsertStoryboard(1) - 始终插入到第一个位置
  • 分镜后按钮handleInsertStoryboard(index + 2) - 插入到当前分镜后面
    • index 是当前分镜在 sortedStoryboards 数组中的索引(从0开始)
    • index + 1 是当前分镜的显示位置(从1开始)
    • index + 2 是插入到当前分镜后面的位置

示例场景

假设有3个分镜:[分镜1, 分镜2, 分镜3]

  1. 点击分镜1后的插入按钮:

    • index = 0
    • 插入位置 = 0 + 2 = 2
    • 结果:[分镜1, 新分镜, 分镜2, 分镜3]
  2. 点击分镜2后的插入按钮:

    • index = 1
    • 插入位置 = 1 + 2 = 3
    • 结果:[分镜1, 分镜2, 新分镜, 分镜3]

修复时间

2026-01-12

验证方法

  1. 连续多次插入分镜
  2. 验证每次插入位置是否与按钮位置匹配
  3. 确认分镜序号正确更新