feat: 在机器人组和标签组件中添加禁用右键菜单功能,优化用户交互体验

This commit is contained in:
xudan 2025-09-29 09:12:36 +08:00
parent b266180e45
commit 86489c326c
3 changed files with 12 additions and 0 deletions

View File

@ -17,6 +17,7 @@ type Props = {
showGroupEdit?: boolean;
editable?: boolean;
current?: string;
disableContextMenu?: boolean;
};
const props = defineProps<Props>();
const editor = inject(props.token)!;
@ -87,6 +88,10 @@ const selectRobot = (id: RobotInfo['id'], checked: boolean) => {
//
const handleRobotRightClick = (event: MouseEvent, robot: RobotInfo) => {
if (props.disableContextMenu) {
event.preventDefault();
return;
}
//
if (event.target && event.target instanceof HTMLElement) {
event.target.setAttribute('data-robot-id', robot.id);

View File

@ -17,6 +17,7 @@ type Props = {
showLabelEdit?: boolean;
editable?: boolean;
current?: string;
disableContextMenu?: boolean;
};
const props = defineProps<Props>();
const editor = inject(props.token)!;
@ -86,6 +87,10 @@ const selectRobot = (id: RobotInfo['id'], checked: boolean) => {
//
const handleRobotRightClick = (event: MouseEvent, robot: RobotInfo) => {
if (props.disableContextMenu) {
event.preventDefault();
return;
}
//
if (event.target && event.target instanceof HTMLElement) {
event.target.setAttribute('data-robot-id', robot.id);

View File

@ -354,6 +354,7 @@ const handleAutoCreateStorageCancel = () => {
:current="current?.id"
@change="selectRobot"
show-group-edit
:disable-context-menu="true"
/>
</a-tab-pane>
<a-tab-pane key="1.5" :tab="$t('机器人标签')">
@ -364,6 +365,7 @@ const handleAutoCreateStorageCancel = () => {
:editable="editable"
:current="current?.id"
@change="selectRobot"
:disable-context-menu="true"
/>
</a-tab-pane>
<a-tab-pane key="2" :tab="$t('库位')">