feat(tool): hide all object

This commit is contained in:
zhangheng
2026-04-10 11:14:06 +08:00
parent bd32d5318d
commit 6aff25a38f

View File

@@ -355,13 +355,10 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
if (operationMap) {
const objList = operationMap.get(operationId)
if (objList && objList.length) {
let hideFlag = true
objList.forEach(([id]) => {
const objStatus =
useObjectStore.getState().pathStatus[`${imgId}${id}`]
if (objStatus && !objStatus["HIDE"]) {
hideFlag = false
}
const hideFlag = objList.every(([id]) => {
return useObjectStore.getState().pathStatus[`${imgId}${id}`]?.["HIDE"]
? true
: false
})
updateOperationStatus(imgId + operationId, "HIDE", hideFlag)
}
@@ -401,6 +398,39 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
[activeImage]
)
const activeImageOperations = labelState.get(activeImage) || []
const isObjectHidden = (imageId: string, objectId: number) => {
return pathStatus[imageId + objectId]?.["HIDE"] ?? false
}
const isOperationHidden = (imageId: string, operationId: string) => {
const operationChildren = storeLabel.get(imageId)?.get(operationId) || []
return (
operationChildren.length > 0 &&
operationChildren.every(([objectId]) => isObjectHidden(imageId, objectId))
)
}
const totalObjectCount = activeImageOperations.reduce(
(count, operationId) => {
return (
count + (storeLabel.get(activeImage)?.get(operationId)?.length || 0)
)
},
0
)
const areAllObjectsHidden =
totalObjectCount > 0 &&
activeImageOperations.every((operationId) => {
const operationChildren =
storeLabel.get(activeImage)?.get(operationId) || []
return operationChildren.every(([objectId]) =>
isObjectHidden(activeImage, objectId)
)
})
// const renderObjectName = useCallback((name: string, input: string) => {
// const index = name?.indexOf(input);
// const beforeStr = name?.substring(0, index);
@@ -509,9 +539,22 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
<Box h="100%" w="100%">
<Flex direction="column" h="100%" gap="xs">
<Flex justify="space-between" align="center" px="md" py="xs">
<Group gap="xs">
<ActionIcon
variant="subtle"
aria-label={areAllObjectsHidden ? "显示全部对象" : "隐藏全部对象"}
onClick={() => {
if (!totalObjectCount) return
activeImageOperations.forEach((operationId) => {
operationHide(operationId, !areAllObjectsHidden)
})
}}>
{areAllObjectsHidden ? <EyeOff size={16} /> : <Eye size={16} />}
</ActionIcon>
<Title order={4} size="h4">
</Title>
</Group>
<Group gap="xs">
<TextInput
w={96}
@@ -566,13 +609,11 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
}}>
<ScrollArea style={{ flex: 1 }} px="md">
<Stack gap="xs" pb="md">
{labelState.get(activeImage) &&
labelState.get(activeImage)?.map((operationId) => {
{activeImageOperations.map((operationId) => {
const operationSchema = getOperationSchema(operationId)
const isCollapsed =
operationStatus[activeImage + operationId]?.["COLLAPSE"]
const isHide =
operationStatus[activeImage + operationId]?.HIDE
const isHide = isOperationHidden(activeImage, operationId)
const hasSubAttrError = getOperationSubAttrStatus(operationId)
const operationLabel = operationSchema?.label_class
const operationChildren =
@@ -613,14 +654,8 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
<ActionIcon
variant="subtle"
size="sm"
onClick={() =>
operationHide(operationId, !isHide)
}>
{!isHide ? (
<Eye size={16} />
) : (
<EyeOff size={16} />
)}
onClick={() => operationHide(operationId, !isHide)}>
{!isHide ? <Eye size={16} /> : <EyeOff size={16} />}
</ActionIcon>
<Group
gap={8}
@@ -851,8 +886,7 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
{
userOpts.find(
(item) =>
item.value ===
child[2]?.uid
item.value === child[2]?.uid
)?.label
}
</Text>
@@ -865,9 +899,7 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
</Group>
{child[2]?.first_modified_uid && (
<Group gap={4}>
<Text size="xs">
</Text>
<Text size="xs"></Text>
<Text size="xs">
{
userOpts.find(
@@ -883,17 +915,13 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
(child[2]
?.first_modified_timestamp ||
0) * 1000
).format(
"YYYY-MM-DD HH:mm:ss"
)}
).format("YYYY-MM-DD HH:mm:ss")}
</Text>
</Group>
)}
{child[2]?.last_modified_uid && (
<Group gap={4}>
<Text size="xs">
</Text>
<Text size="xs"></Text>
<Text size="xs">
{
userOpts.find(
@@ -909,9 +937,7 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
(child[2]
?.last_modified_timestamp ||
0) * 1000
).format(
"YYYY-MM-DD HH:mm:ss"
)}
).format("YYYY-MM-DD HH:mm:ss")}
</Text>
</Group>
)}