feat(shortcut): b/m

This commit is contained in:
zhangheng
2026-04-03 18:51:59 +08:00
parent e4aae0a7af
commit 7c700bf952
2 changed files with 305 additions and 3 deletions

View File

@@ -1467,6 +1467,7 @@ const LabelPage = ({
}
setActiveOperation(selectedContext.operationId)
usePaperStore.getState().setContinuePolygonTarget(null)
setEditMode(true)
setDrawOption("default")
useKeyboardStore.getState().setDrawAction(mode)
@@ -1566,6 +1567,47 @@ const LabelPage = ({
[]
)
const handleContinueSelectedPolygon = useCallback(() => {
const selectedContext = resolveSelectedObjectContext()
if (!selectedContext) {
notifications.show({
color: "yellow",
message: "请先选中单个对象",
})
return
}
if (selectedContext.objectType !== "polygon") {
notifications.show({
color: "yellow",
message: "继续标注快捷键仅支持 polygon 类型对象",
})
return
}
setEditMode(true)
setDrawOption("default")
setPressA(false)
setActiveOperation(selectedContext.operationId)
useKeyboardStore.getState().setDrawAction("none")
usePaperStore.getState().setContinuePolygonTarget({
imageId: selectedContext.imageId,
operationId: selectedContext.operationId,
objectId: selectedContext.objectId,
})
usePaperStore.getState().setPaperMode("polygon")
notifications.show({
color: "green",
message: "已进入继续标注模式",
})
}, [
resolveSelectedObjectContext,
setActiveOperation,
setDrawOption,
setEditMode,
setPressA,
])
const hasShapeSegments = useCallback((shape: any) => {
if (!shape) return false
if (shape instanceof paper.CompoundPath) {
@@ -2039,13 +2081,23 @@ const LabelPage = ({
useEffect(() => {
const down = (e: KeyboardEvent) => {
// console.log(e, e.key);
if (focusInput || isView) return
if (focusInput) return
console.log(e.key)
const mode = usePaperStore.getState().mode
const lowerKey = e.key.toLowerCase()
if (e.repeat && ["a", "d", "h", ",", "."].includes(lowerKey)) return
if (e.repeat && ["a", "b", "d", "h", "m", ",", "."].includes(lowerKey))
return
if (!e.ctrlKey && !e.metaKey && !e.altKey && lowerKey === "m") {
e.preventDefault()
const topState = useTopToolsStore.getState()
topState.setMagnetFlag(!topState.magnetFlag)
return
}
if (isView) return
if (!e.ctrlKey && !e.metaKey && !e.altKey && lowerKey === "h") {
e.preventDefault()
@@ -2065,6 +2117,12 @@ const LabelPage = ({
return
}
if (!e.ctrlKey && !e.metaKey && !e.altKey && lowerKey === "b") {
e.preventDefault()
handleContinueSelectedPolygon()
return
}
if (
!e.ctrlKey &&
!e.metaKey &&
@@ -2335,6 +2393,7 @@ const LabelPage = ({
getOperationSchema,
handleToggleHideSelectedObject,
handleMergeSelectedObjects,
handleContinueSelectedPolygon,
handleShortcut,
isView,
projectDetail?.label_type,
@@ -2360,6 +2419,7 @@ const LabelPage = ({
useEffect(() => {
useKeyboardStore.getState().setCopyDataIds([])
useKeyboardStore.getState().setDrawAction("none")
usePaperStore.getState().setContinuePolygonTarget(null)
drawShortcutSnapshotRef.current = null
}, [activeImage])