feat(annotation): 添加分段索引支持和优化标注编辑器

- 在前端 lsf.html 中添加 segmentIndex 字段解析逻辑
- 在 LabelStudioTextEditor 中添加分段索引相关类型定义和处理函数
- 使用 useCallback 优化组件中的异步函数性能
- 添加对驼峰命名和下划线命名的数据字段兼容处理
- 实现分段模式下的标注状态更新功能
- 添加任务 ID 验证防止过期保存请求
- 在后端 editor.py 中添加分段索引字段支持
- 统一前后端数据传输格式确保字段一致性
This commit is contained in:
2026-01-22 17:14:37 +08:00
parent c638182c72
commit 1eee1e248e
3 changed files with 154 additions and 40 deletions

View File

@@ -200,6 +200,18 @@
// 最小化对齐 Label Studio Server 的字段(DataMate 侧会原样存储)
const taskId = typeof currentTask?.id === "number" ? currentTask.id : Number(currentTask?.id) || null;
const fileId = currentTask?.data?.file_id || currentTask?.data?.fileId || null;
const segmentIndexValue =
currentTask?.data?.segment_index ??
currentTask?.data?.segmentIndex ??
currentTask?.data?.dm_segment_index ??
currentTask?.data?.dmSegmentIndex ??
null;
const segmentIndex =
segmentIndexValue === null || segmentIndexValue === undefined
? null
: Number.isFinite(Number(segmentIndexValue))
? Number(segmentIndexValue)
: null;
annotationPayload.id = typeof annotationPayload.id === "number" ? annotationPayload.id : taskId || 1;
annotationPayload.task = taskId;
@@ -209,6 +221,7 @@
return {
taskId,
fileId,
segmentIndex,
annotation: annotationPayload,
};
}