feat: 在机器人组和标签组件中添加禁用右键菜单功能,优化用户交互体验
This commit is contained in:
parent
b266180e45
commit
86489c326c
@ -17,6 +17,7 @@ type Props = {
|
|||||||
showGroupEdit?: boolean;
|
showGroupEdit?: boolean;
|
||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
current?: string;
|
current?: string;
|
||||||
|
disableContextMenu?: boolean;
|
||||||
};
|
};
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
const editor = inject(props.token)!;
|
const editor = inject(props.token)!;
|
||||||
@ -87,6 +88,10 @@ const selectRobot = (id: RobotInfo['id'], checked: boolean) => {
|
|||||||
|
|
||||||
// 处理机器人右键点击
|
// 处理机器人右键点击
|
||||||
const handleRobotRightClick = (event: MouseEvent, robot: RobotInfo) => {
|
const handleRobotRightClick = (event: MouseEvent, robot: RobotInfo) => {
|
||||||
|
if (props.disableContextMenu) {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 为事件目标添加机器人标识
|
// 为事件目标添加机器人标识
|
||||||
if (event.target && event.target instanceof HTMLElement) {
|
if (event.target && event.target instanceof HTMLElement) {
|
||||||
event.target.setAttribute('data-robot-id', robot.id);
|
event.target.setAttribute('data-robot-id', robot.id);
|
||||||
|
|||||||
@ -17,6 +17,7 @@ type Props = {
|
|||||||
showLabelEdit?: boolean;
|
showLabelEdit?: boolean;
|
||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
current?: string;
|
current?: string;
|
||||||
|
disableContextMenu?: boolean;
|
||||||
};
|
};
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
const editor = inject(props.token)!;
|
const editor = inject(props.token)!;
|
||||||
@ -86,6 +87,10 @@ const selectRobot = (id: RobotInfo['id'], checked: boolean) => {
|
|||||||
|
|
||||||
// 处理机器人右键点击
|
// 处理机器人右键点击
|
||||||
const handleRobotRightClick = (event: MouseEvent, robot: RobotInfo) => {
|
const handleRobotRightClick = (event: MouseEvent, robot: RobotInfo) => {
|
||||||
|
if (props.disableContextMenu) {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 为事件目标添加机器人标识
|
// 为事件目标添加机器人标识
|
||||||
if (event.target && event.target instanceof HTMLElement) {
|
if (event.target && event.target instanceof HTMLElement) {
|
||||||
event.target.setAttribute('data-robot-id', robot.id);
|
event.target.setAttribute('data-robot-id', robot.id);
|
||||||
|
|||||||
@ -354,6 +354,7 @@ const handleAutoCreateStorageCancel = () => {
|
|||||||
:current="current?.id"
|
:current="current?.id"
|
||||||
@change="selectRobot"
|
@change="selectRobot"
|
||||||
show-group-edit
|
show-group-edit
|
||||||
|
:disable-context-menu="true"
|
||||||
/>
|
/>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane key="1.5" :tab="$t('机器人标签')">
|
<a-tab-pane key="1.5" :tab="$t('机器人标签')">
|
||||||
@ -364,6 +365,7 @@ const handleAutoCreateStorageCancel = () => {
|
|||||||
:editable="editable"
|
:editable="editable"
|
||||||
:current="current?.id"
|
:current="current?.id"
|
||||||
@change="selectRobot"
|
@change="selectRobot"
|
||||||
|
:disable-context-menu="true"
|
||||||
/>
|
/>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane key="2" :tab="$t('库位')">
|
<a-tab-pane key="2" :tab="$t('库位')">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user