feat: 增强上下文菜单逻辑,新增右键菜单状态管理,防止在右键菜单显示时更新选中状态
This commit is contained in:
parent
dedb444200
commit
fba02ccd66
@ -290,6 +290,11 @@ const current = ref<{ type: 'robot' | 'point' | 'line' | 'area'; id: string }>()
|
||||
watch(
|
||||
() => editor.value?.selected.value[0],
|
||||
(v) => {
|
||||
// 如果右键菜单正在显示,则不更新选中状态
|
||||
if (contextMenuState.value.isRightClickActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pen = editor.value?.getPenById(v);
|
||||
if (pen?.id) {
|
||||
current.value = { type: <'point' | 'line' | 'area'>pen.name, id: pen.id };
|
||||
|
@ -120,6 +120,7 @@ export function handleContextMenu(
|
||||
x: parsedData.position.x,
|
||||
y: parsedData.position.y,
|
||||
eventData: parsedData,
|
||||
isRightClickActive: true, // 标记右键菜单正在显示
|
||||
...menuConfig, // 展开具体配置
|
||||
});
|
||||
|
||||
@ -152,6 +153,7 @@ export function handleContextMenuFromPenData(
|
||||
x: parsedData.position.x,
|
||||
y: parsedData.position.y,
|
||||
eventData: parsedData,
|
||||
isRightClickActive: true, // 标记右键菜单正在显示
|
||||
...menuConfig, // 展开具体配置
|
||||
});
|
||||
|
||||
|
@ -11,6 +11,7 @@ export interface ContextMenuState {
|
||||
eventData?: any;
|
||||
storageLocations?: any[];
|
||||
robotInfo?: any;
|
||||
isRightClickActive?: boolean; // 新增:标记右键菜单是否正在显示,用于阻止选中状态更新
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,7 +67,7 @@ export function createContextMenuManager() {
|
||||
* 关闭菜单
|
||||
*/
|
||||
function close() {
|
||||
setState({ visible: false });
|
||||
setState({ visible: false, isRightClickActive: false });
|
||||
}
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user