@@ -20,33 +20,19 @@ export const exportDescriptionMapping = {
20
20
[ ExportType . MASK ] : '面向图像分割(多边形)任务' ,
21
21
} ;
22
22
23
- const availableOptions = {
24
- [ MediaType . IMAGE ] : [
25
- {
26
- label : ExportType . JSON ,
27
- value : ExportType . JSON ,
28
- } ,
29
- {
30
- label : ExportType . COCO ,
31
- value : ExportType . COCO ,
32
- } ,
33
- {
34
- label : ExportType . MASK ,
35
- value : ExportType . MASK ,
36
- } ,
37
- ] ,
38
- [ MediaType . VIDEO ] : [
39
- {
40
- label : ExportType . JSON ,
41
- value : ExportType . JSON ,
42
- } ,
43
- ] ,
44
- [ MediaType . AUDIO ] : [
45
- {
46
- label : ExportType . JSON ,
47
- value : ExportType . JSON ,
48
- } ,
49
- ] ,
23
+ const optionMapping = {
24
+ [ ExportType . JSON ] : {
25
+ label : ExportType . JSON ,
26
+ value : ExportType . JSON ,
27
+ } ,
28
+ [ ExportType . COCO ] : {
29
+ label : ExportType . COCO ,
30
+ value : ExportType . COCO ,
31
+ } ,
32
+ [ ExportType . MASK ] : {
33
+ label : ExportType . MASK ,
34
+ value : ExportType . MASK ,
35
+ } ,
50
36
} ;
51
37
52
38
export default function ExportPortal ( { taskId, sampleIds, mediaType, tools, children } : ExportPortalProps ) {
@@ -99,24 +85,34 @@ export default function ExportPortal({ taskId, sampleIds, mediaType, tools, chil
99
85
} ) ;
100
86
} , [ children , handleOpenModal ] ) ;
101
87
102
- // cuboid 不需要导出coco和mask
103
- const containsCuboidTool = useMemo ( ( ) => {
104
- return tools ?. find ( ( item ) => item . tool === 'cuboidTool' ) ;
105
- } , [ tools ] ) ;
106
-
107
88
const options = useMemo ( ( ) => {
89
+ const result = [ optionMapping [ ExportType . JSON ] ] ;
90
+
108
91
if ( ! mediaType ) {
109
- return [ ] ;
92
+ return result ;
110
93
}
111
94
112
- if ( containsCuboidTool && mediaType === MediaType . IMAGE ) {
113
- return availableOptions [ MediaType . IMAGE ] . filter (
114
- ( option ) => option . value !== ExportType . COCO && option . value !== ExportType . MASK ,
115
- ) ;
95
+ const onlyPolygonTool = tools ?. length === 1 && tools [ 0 ] . tool === 'polygonTool' ;
96
+ const onlyRectTool = tools ?. length === 1 && tools [ 0 ] . tool === 'rectTool' ;
97
+ const polygonOrRectTool =
98
+ tools ?. length === 2 &&
99
+ tools . find ( ( item ) => item . tool === 'polygonTool' ) &&
100
+ tools . find ( ( item ) => item . tool === 'rectTool' ) ;
101
+
102
+ // coco: rect, polygon
103
+ // mask: polygon
104
+ if ( mediaType === MediaType . IMAGE ) {
105
+ if ( polygonOrRectTool || onlyPolygonTool || onlyRectTool ) {
106
+ result . push ( optionMapping [ ExportType . COCO ] ) ;
107
+ }
108
+
109
+ if ( onlyPolygonTool ) {
110
+ result . push ( optionMapping [ ExportType . MASK ] ) ;
111
+ }
116
112
}
117
113
118
- return availableOptions [ mediaType || MediaType . IMAGE ] ;
119
- } , [ containsCuboidTool , mediaType ] ) ;
114
+ return result ;
115
+ } , [ mediaType , tools ] ) ;
120
116
121
117
return (
122
118
< >
0 commit comments