修正GT未知类别舍弃模板传递
- GT Mask 导入请求改用与预览一致的 GT 模板 id,避免未激活模板时后端无法识别未知 maskid。 - 补充回归测试覆盖未显式激活模板但模板列表存在时,舍弃未知类别仍传入模板 id。
This commit is contained in:
@@ -1729,7 +1729,18 @@ describe('VideoWorkspace', () => {
|
||||
]);
|
||||
apiMock.importGtMask.mockResolvedValueOnce([]);
|
||||
apiMock.getProjectAnnotations.mockResolvedValueOnce([]).mockResolvedValueOnce([]);
|
||||
useStore.setState({ activeTemplateId: '2' });
|
||||
useStore.setState({
|
||||
activeTemplateId: null,
|
||||
templates: [{
|
||||
id: '2',
|
||||
name: '当前模板',
|
||||
classes: [
|
||||
{ id: 'known', name: '已定义', color: '#ff0000', zIndex: 10, maskId: 1 },
|
||||
{ id: 'reserved-unclassified', name: '待分类', color: '#000000', zIndex: 0, maskId: 0 },
|
||||
],
|
||||
rules: [],
|
||||
}],
|
||||
});
|
||||
|
||||
render(<VideoWorkspace />);
|
||||
await waitFor(() => expect(useStore.getState().frames).toHaveLength(1));
|
||||
|
||||
@@ -687,6 +687,7 @@ export function VideoWorkspace({ onNavigateToAI }: { onNavigateToAI?: () => void
|
||||
const activeTemplateForGt = useMemo(() => (
|
||||
templates.find((template) => String(template.id) === String(activeTemplateId)) || templates[0] || null
|
||||
), [activeTemplateId, templates]);
|
||||
const gtImportTemplateId = activeTemplateForGt?.id ? String(activeTemplateForGt.id) : activeTemplateId;
|
||||
const gtTemplateClasses = useMemo(() => (
|
||||
normalizeClassMaskIds(activeTemplateForGt?.classes || [])
|
||||
), [activeTemplateForGt?.classes]);
|
||||
@@ -1485,7 +1486,7 @@ export function VideoWorkspace({ onNavigateToAI }: { onNavigateToAI?: () => void
|
||||
setIsImportingGt(true);
|
||||
setStatusMessage('正在导入 GT Mask...');
|
||||
try {
|
||||
const imported = await importGtMask(file, currentProject.id, currentFrame.id, activeTemplateId, {
|
||||
const imported = await importGtMask(file, currentProject.id, currentFrame.id, gtImportTemplateId, {
|
||||
unknownColorPolicy,
|
||||
});
|
||||
await hydrateSavedAnnotations(currentProject.id, frames);
|
||||
|
||||
Reference in New Issue
Block a user