feat: 增强上下文菜单逻辑,新增右键菜单状态管理,防止在右键菜单显示时更新选中状态

This commit is contained in:
xudan 2025-09-10 10:50:08 +08:00
parent dedb444200
commit fba02ccd66
3 changed files with 9 additions and 1 deletions

View File

@ -290,6 +290,11 @@ const current = ref<{ type: 'robot' | 'point' | 'line' | 'area'; id: string }>()
watch( watch(
() => editor.value?.selected.value[0], () => editor.value?.selected.value[0],
(v) => { (v) => {
//
if (contextMenuState.value.isRightClickActive) {
return;
}
const pen = editor.value?.getPenById(v); const pen = editor.value?.getPenById(v);
if (pen?.id) { if (pen?.id) {
current.value = { type: <'point' | 'line' | 'area'>pen.name, id: pen.id }; current.value = { type: <'point' | 'line' | 'area'>pen.name, id: pen.id };

View File

@ -120,6 +120,7 @@ export function handleContextMenu(
x: parsedData.position.x, x: parsedData.position.x,
y: parsedData.position.y, y: parsedData.position.y,
eventData: parsedData, eventData: parsedData,
isRightClickActive: true, // 标记右键菜单正在显示
...menuConfig, // 展开具体配置 ...menuConfig, // 展开具体配置
}); });
@ -152,6 +153,7 @@ export function handleContextMenuFromPenData(
x: parsedData.position.x, x: parsedData.position.x,
y: parsedData.position.y, y: parsedData.position.y,
eventData: parsedData, eventData: parsedData,
isRightClickActive: true, // 标记右键菜单正在显示
...menuConfig, // 展开具体配置 ...menuConfig, // 展开具体配置
}); });

View File

@ -11,6 +11,7 @@ export interface ContextMenuState {
eventData?: any; eventData?: any;
storageLocations?: any[]; storageLocations?: any[];
robotInfo?: any; robotInfo?: any;
isRightClickActive?: boolean; // 新增:标记右键菜单是否正在显示,用于阻止选中状态更新
} }
/** /**
@ -66,7 +67,7 @@ export function createContextMenuManager() {
* *
*/ */
function close() { function close() {
setState({ visible: false }); setState({ visible: false, isRightClickActive: false });
} }
return { return {