feat: 在运动监控页面中新增右键菜单状态管理,优化画布事件处理逻辑,提升用户交互体验
This commit is contained in:
parent
49f87fd1cb
commit
83e4d68af7
@ -390,6 +390,7 @@ onMounted(() => {
|
|||||||
editorStore.setEditor(editor as ShallowRef<EditorService>);
|
editorStore.setEditor(editor as ShallowRef<EditorService>);
|
||||||
|
|
||||||
storageLocationService.value = new StorageLocationService(editor.value, props.sid);
|
storageLocationService.value = new StorageLocationService(editor.value, props.sid);
|
||||||
|
container.value?.addEventListener('pointerdown', handleCanvasPointerDown, true);
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
@ -450,6 +451,13 @@ onUnmounted(() => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
container.value?.removeEventListener('pointerdown', handleCanvasPointerDown, true);
|
||||||
|
|
||||||
|
if (rightClickGuardTimer) {
|
||||||
|
clearTimeout(rightClickGuardTimer);
|
||||||
|
rightClickGuardTimer = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
// 移除全局事件监听器
|
// 移除全局事件监听器
|
||||||
document.removeEventListener('click', handleGlobalClick);
|
document.removeEventListener('click', handleGlobalClick);
|
||||||
document.removeEventListener('keydown', handleGlobalKeydown);
|
document.removeEventListener('keydown', handleGlobalKeydown);
|
||||||
@ -555,6 +563,28 @@ const show = ref<boolean>(true);
|
|||||||
// 右键菜单状态管理 - 使用组合式函数
|
// 右键菜单状态管理 - 使用组合式函数
|
||||||
const contextMenuManager = createContextMenuManager();
|
const contextMenuManager = createContextMenuManager();
|
||||||
const contextMenuState = ref<ContextMenuState>(contextMenuManager.getState());
|
const contextMenuState = ref<ContextMenuState>(contextMenuManager.getState());
|
||||||
|
let rightClickGuardTimer: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guard selection state before Meta2D processes the contextmenu event.
|
||||||
|
*/
|
||||||
|
const handleCanvasPointerDown = (event: PointerEvent) => {
|
||||||
|
if (event.button !== 2) return;
|
||||||
|
|
||||||
|
contextMenuManager.setState({ isRightClickActive: true });
|
||||||
|
|
||||||
|
if (rightClickGuardTimer) {
|
||||||
|
clearTimeout(rightClickGuardTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
rightClickGuardTimer = setTimeout(() => {
|
||||||
|
rightClickGuardTimer = undefined;
|
||||||
|
if (!contextMenuState.value.visible) {
|
||||||
|
contextMenuManager.setState({ isRightClickActive: false });
|
||||||
|
}
|
||||||
|
}, 200);
|
||||||
|
};
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
// 返回到父级 iframe 的场景卡片
|
// 返回到父级 iframe 的场景卡片
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user